Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
I am trying to fix the ordering only on 1 category but its still displaying from the first post
I am displaying only posts from category with id=1 but in template and i did the order_by but still on template its showing from the first post not from the latest class LajmetListView(ListView): model = Lajmet model = Kategori template_name = 'main/lajme-home.html' # <app>/<model>_<viewtype>.html context_object_name = 'lajmet' def get_context_data(self, **kwargs): context = super(LajmetListView, self).get_context_data(**kwargs) context['lajmet'] = Lajmet.objects.order_by('-data_e_postimit') context['trilajmet'] = Kategori.objects.get(pk=1) return context {% for lajmet in trilajmet.lajmet_set.all %} {% if forloop.counter < 5 %} <div class="single_iteam"> <a href="pages/single_page.html"> <img src="media/{{lajmet.fotografit}}" alt=""></a> <div class="slider_article"> <h2><a class="slider_tittle" href="pages/single_page.html">{{lajmet.titulli}}</a></h2> <p>{{lajmet.detajet}}</p> <p>{{lajmet.data_e_postimit}}</p> </div> </div> {% endif %} {% endfor %} -
Exit status 1 error while installing mod_wsgi
I am getting following error while installing mod_wsgi using pip3. I downloaded it once mistakenly before installing Apache, then it threw error for Apache's unavailability and didn't install. Then I installed Apache using command brew install apache2 and then did pip3 install mod_wsgi --no-cache-dir so that it don't take up the cached image, but it didn't work and got following error. Any help is much appreciated. Thanks! Collecting mod_wsgi Downloading mod_wsgi-4.7.1.tar.gz (498 kB) |████████████████████████████████| 498 kB 4.6 MB/s ERROR: Command errored out with exit status 1: command: /usr/local/opt/python@3.9/bin/python3.9 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/0f/3wwtkx4d6m94zpmq0r5rw5c80000gn/T/pip-install-lygp82k1/mod-wsgi_ef198f9a817445a7b3cf53dd590fbdb2/setup.py'"'"'; __file__='"'"'/private/var/folders/0f/3wwtkx4d6m94zpmq0r5rw5c80000gn/T/pip-install-lygp82k1/mod-wsgi_ef198f9a817445a7b3cf53dd590fbdb2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/0f/3wwtkx4d6m94zpmq0r5rw5c80000gn/T/pip-pip-egg-info-2q3u8hgc cwd: /private/var/folders/0f/3wwtkx4d6m94zpmq0r5rw5c80000gn/T/pip-install-lygp82k1/mod-wsgi_ef198f9a817445a7b3cf53dd590fbdb2/ Complete output (5 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/private/var/folders/0f/3wwtkx4d6m94zpmq0r5rw5c80000gn/T/pip-install-lygp82k1/mod-wsgi_ef198f9a817445a7b3cf53dd590fbdb2/setup.py", line 490, in <module> target_version = tuple(map(int, target.split('.'))) AttributeError: 'int' object has no attribute 'split' ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. -
s3 aws user authentication in django
Hi I'm using Arvan cloud (arvancloud.com/en) cloud storage in my porject (very similar to S3 AWS). and aslo I'm using django-storages and boto3 libraries. my project is a online learning platform (like udemy). and I have courses and lessons. so I should authenticate the users who want to download or see the contents (video or document) if he/she bought the course it is possible to see or download the contents. my question is how can i authenticate users? (So that they can not illegally access the content) How about query string expiration? (I tried to reduce the expiration time but it did not work!) these are my codes: # this is models.py for course app. User = get_user_model() class Category(models.Model): name = models.CharField(max_length=50, unique=True) slug = models.SlugField(null=True, blank=True, unique=True) sub_category = models.ForeignKey('self', on_delete=models.CASCADE, related_name='sub_categories') def __str__(self): return f'{self.name}' def save(self, *arg, **kwargs): self.slug = slugify(self.name) return super().save(*arg, **kwargs) class Course(models.Model): teachers = models.ForeignKey(User, on_delete=models.CASCADE, related_name='courses') name = models.CharField(max_length=100, unique=True) slug = models.SlugField(null=True, blank=True, unique=True) cover = models.ImageField(upload_to='files/course_covers/', storage=CourseMediaStorage()) description = models.TextField(max_length=512) requirements = models.TextField(max_length=120) price = models.DecimalField(max_digits=5, decimal_places=2) is_free = models.BooleanField(default=False) def __str__(self): return self.name def save(self, *args, **kwargs): if self.is_free: self.price = Decimal('0') self.slug = slugify(self.name) return super().save(*args, **kwargs) … -
Add 1 to a database value when button is pressed using Django
I have a django model that looks like this: class Character(models.Model): character_Name = models.CharField(max_length=50) user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) level = models.PositiveSmallIntegerField(validators=[MaxValueValidator(20), MinValueValidator(1)], default=1) def __str__(self): return self.character_Name with an html file(main.html) that looks like this: <!DOCTYPE html> <html lang="en"> <body> <h1>{{ characters.character_Name }}</h1> <h4>Level: {{ characters.level }}</h4> <button onclick="increase_level()"> + 1 </button> </body> a function in views.py that looks like this: def main(request): if request.user.is_authenticated: characters = Character.objects.filter(user=request.user).order_by('character_Name').first return render(request, 'main.html', {'characters': characters}) else: return redirect('account creation') and its path from urls.py: path('main', views.main, name='main'), How can I implement the press of the button updating the page and the database by leveling up by 1? -
error 404 (Not Found) when trying to get local JSON file with AJAX method on django project
I'm trying to access my database from a JS file. In order to do so I serialized all my models objects into local JSON files and now I'm trying to read this files with the AJAX method (wich I've never tried before), but it's failing to find them. My directories look something like this: /RecipeSite (...) /reading /writing (...) /static/writing/ /css /scss /js forms.js /json test.json (...) In my writing/js/forms.js i have this code: (...) $.ajax({ type: "GET", dataType: "json", url: "/test.json", success: function(data) { console.log(data); } }); (...) but when i run it, the console shows GET http://127.0.0.1:8000/test.json 404 (Not Found) -
Overriding the create method of Django Rest Framework Serialization
I am creating a Django backend where I am using Django Rest Framework for building REST API. I have nested serialization, and when I try to serialize the data I have to override the create function of the ModelSerializers. I'm a bit scared that this is going to cause a problem or a loophole in the backend's security as I am not using the default validation when creating an object. SO IS IT NORMAL TO DO SO? # THIS IS MY MODELS.PY from django.db import models from django.contrib.auth.models import User class UnivStudent(models.Model): """ A class based model for storing the records of a university student Note: A OneToOne relation is established for each student with User model. """ user = models.OneToOneField(User) subject_major = models.CharField(name="subject_major", max_length=60) # THIS IS MY SERIALIZERS.PY from rest_framework import serializers, status from models import * class UserSerializer(serializers.ModelSerializer): class Meta: model = User fields = ('username', 'first_name', 'last_name', 'email') class StudentSerializer(serializers.ModelSerializer): """ A student serializer to return the student details """ user = UserSerializer(required=True) class Meta: model = UnivStudent fields = ('user', 'subject_major',) def create(self, validated_data): """ Overriding the default create method of the Model serializer. :param validated_data: data containing all the details of student :return: returns … -
how to deploy android app on server and additional convert django to apk
I am very new to android application development; I want to know how to deploy an app and how much it cost to deploy as an additional question, I am fairly good at Django so I want to ask can I convert the Django web application into apk file and how; just share an example link -
django-polymorphic - have attribute accessor resolve to final polymorphic child class
I am using django-polymorphic I have a class Base(PolymorphicModel): # some fields class Child(Base): # some field class Foo(models.Model): fk = models.ForeignKey(Base, null=True, on_delete=models.SET_NULL) And I use them as child = Child.objects.create(..) foo = Foo.objects.create(fk=child, ...) later when I want to access foo.fk # this gives a Base class obj instead of a child class obj via polymorphism i want to get foo.fk as the Child object, but I instead get the Base object. I have to do : Child.objects.get(id=foo.fk.id) Is there a way to get the attribute accessor foo.fk resolve to Child class directly? -
One object across many apps in django
Some time ago I started to learn python and I created commandline application that manages your home bar and cocktails recipes (you can add alcohol bottles to it, add recipes, check if you have ingredients to create given cocktail and so on) that uses sqlite3 database. Class called BarmanShell is kind of api of this app which contains every function user could use. __init__ of that class contains db connection and data validation based on xml files. Now, as I'm learning django, I would like to reuse it in web version of this application. In this django project I have app myshelf that must use some BarmanShell functionality. def myshelf_view(request, *args, **kwargs): if request.method == "GET": barman = BarmanShell() # do some thigs with stat to create context barman = BarmanShell() could be done only once, not every GET request. But I cannot move it up from myshelf_view function as it contains some sql queries and following error is produced: SQLite objects created in a thread can only be used in that same thread. Also, I cannot move its creation to django_project/urls.py and then import it in myshelf/views.py barman = BarmanShell() # in urls.py from django_project.urls import barman # in … -
Django NoReverseMatch Error while navigating to Category Page
I'm getting Noreverse match error for sports_detail when i click on category, What i'm doing is when i click on category all posts related mapped to that category will get render on sport_category page using List view. What i'm not getting is why i'm getting Noreverse match error for sports_details. Same thing i did for My blogs section and it's working fine, but not sure why it's not working for Sports section. Any Help in what i'm doing wrong. i tried removing p from url but still not working modified url below, path('sports/<str:name>', SportsCategory.as_view(), name="categories"), Code: https://pastebin.com/TsN8UcKW -
Can I Get Hired?
it was about 6 month ago that I started to learn programming . I started with Html, css, js, then sass and finally Django and Django rest framework . Now I wonder if I can get Hired as a junior developer with this level of understanding.I ask the guys in business to look at my github account and answer my question. and where should I concentrate next ? appreciate your help in advance my github account : dusty2035 -
Django website refuses to connect after changing URL [closed]
I created a website using Django and deployed it on Linode but I'm having a problem now that I am ready to change the website from using the Linode provided hostname to my own URL. I imported my domain into Linodes domain manager, set an A record to point to the IP address of the Linode, set the reverse DNS, updated ALLOWED_HOSTS in Django settings to include the new hostname, disabled the website through apache changed the ServerName then re enabled the site, and restarted the apache service as well as the VM and the site sill gives me a refused to connect. When I ping the server it responds with the correct hostname and if I use wget it can get the plain HTML from the site. is there someplace else I need to update the website name after I've enabled the site? -
Django Template filter the query set already rendered
I have model class TransHeader(models.Model): th_type = models.CharField(max_length=200) th_code = models.CharField(max_length=200) th_status=models.CharField(max_length=1,default=0) my view: class SalTransactions(TemplateView): template_name = "wstore/sales_transactions.html" def get_context_data(self, **kwargs): context = {} if kwargs['post']=='UNPOSTED': context['transactions'] = TransHeader.objects.filter(th_type=kwargs['transtype']) .filter(th_status='0') else: context['transactions'] = TransHeader.objects.filter(th_type=kwargs['transtype']) return context my url line: path('saltransactions/<str:transtype>/<str:post>',views.SalTransactions.as_view(), name='saltransactions'), my link through menu is working fine showing all records with given trans type: <a class="nav-link" href="{% url 'saltransactions' transtype='INV' post='ALL' %}">Sales</a> <a class="nav-link" href="{% url 'saltransactions' transtype='ADJ' post='ALL' %}">Stock Adjustment</a> But when I filter to show rocords having th_status='0' only I am using the following link in template: <a href="{% url 'saltransactions' transtype=?????" post='UNPOSTED' %}" >Unposted</a> my problem is how to pass INV or ADJ to transtype from the queryset. If I assign transtype='INV' it is filtering INV queryset in both types. So that I can use one view, one template for all type of transactions (INV/ADJ) Thanks for your help -
Pass DateRangePicker values to views file in Django
I'm trying to use Date Range Picker to let the users pick a date range which can be used to filter the results of a function in my views.py file. How can I pass the values from the JavaScript function to my views.py file? Do I need to use a form or can this be done without it? my_template.html {% block content %} <form method="post" action=""> {% csrf_token %} <div id="reportrange"> <i class="fa fa-calendar"></i> <span></span> <i class="fa fa-caret-down"></i> </div> <button type="submit" class="btn btn-success">Send</button> </form> {% endblock content %} {% block javascripts %} <script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script> <script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css"/> <script type="text/javascript"> $(function () { var start = moment().subtract(29, 'days'); var end = moment(); function cb(start, end) { $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY')); } $('#reportrange').daterangepicker({ startDate: start, endDate: end, ranges: { 'Today': [moment(), moment()], 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], 'Last 7 Days': [moment().subtract(6, 'days'), moment()], 'Last 30 Days': [moment().subtract(29, 'days'), moment()], 'This Month': [moment().startOf('month'), moment().endOf('month')], 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] } }, cb); cb(start, end); }); </script> {% endblock javascripts %} -
social django 'NoneType' object has no attribute 'city_set'
I'm having an error('NoneType' object has no attribute 'city_set') when I try to update my users profile if I log in with facebook account. I assume the problem caused by: there is no country and city selected at first. There is no problem with normal registation and updating the profile of the user but social_django breaks the rules. I'm using abstractbaseuser model and I have a country-city models side of it. I tried many ways to figure it out but those didn't help. Many thanks for your time in advance... settings.py """ Django settings for project_folder project. Generated by 'django-admin startproject' using Django 3.0.6. For more information on this file, see https://docs.djangoproject.com/en/3.0/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.0/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '7aa*ng4p*o!9h4%hyfgu=9xy69aumg6hzbz3g)1mf^4!+gi+e0' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # apps 'apps.daily_brief', 'apps.users', 'apps.crm', # side-apps … -
How to insert different different email mysql in django
I am new in django .. i have to created three id in that userid same but emailid should be diffrent i want i am sending three emaild it showing me one email id 3 times i am not understanding to store different different email id in id 1, id 2, id 3, but user name is same please help me how to save i amnot understanding in view.py i am add for loop relation database but its taking same mail id please help me how to do i amnot undestanding please................ I am new in django .. i have to created three id in that userid same but emailid should be diffrent i want i am sending three emaild it showing me one email id 3 times i am not understanding to store different different email id in id 1, id 2, id 3, but user name is same please help me how to save i amnot understanding in view.py i am add for loop relation database but its taking same mail id please help me how to do i amnot undestanding please. # views.py def trade_references(request): #print('trade_reference', request.session.get('email')) if request.method == 'POST' and request.session.has_key('email'): print('trade_reference',request.session.get('email')) # arg1 = … -
How to pass the Django's session cookie in ingress-nginx-controller to a different service/endpoint?
Related ingress manifest (for the Kubernetes' controller, not the one provided by NGINX) looks like this: apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: annotations: cert-manager.io/issuer: myissuer kubernetes.io/ingress.class: "nginx" nginx.ingress.kubernetes.io/upstream-hash-by: "$cookie_mycookie" nginx.ingress.kubernetes.io/use-regex: "true" nginx.ingress.kubernetes.io/default-backend: custom-backend nginx.ingress.kubernetes.io/custom-http-errors: "404,503" name: myingress spec: rules: - host: example.com http: paths: - backend: serviceName: svc1 servicePort: 80 path: /.* - backend: serviceName: svc2 servicePort: 80 path: /some-path/.* tls: - hosts: - example.com secretName: example-com-mycert After a user is authenticated in a Django app, a cookie is added. For the ingress from the above, if I switch to an endpoint /some-path/ then the original session cookie is not preserved and the user is logged out. How can I preserve the user session cookie so my Gunicorn backend behind svc2 can securely accept the user authenticated in the backend behind svc1? -
Pass data form in Django
I'm having a trouble on how can I pass data from html into views.py based on selected row button in my html and also I want to pass through POST. It would be great if anybody could figure out where I am doing something wrong. thank you so much in advance sample.Html <div class="row"> {% csrf_token %} {% for folder in folder_list %} Folder title: <span id="titles" name="titles" >{{folder.title}}</span></p> Date upload: <span id="date_upload" name="date_upload">{{folder.date_upload}}</span> <a href="{% url 'view_gallery' %}" name="idd" value="{{ folder.id }}">Open</a> {% endfor %} </div> views.py @login_required(login_url='log_permission') def view_gallery(request): if request.method == 'POST': print("makibaoh") idd = request.POST.get('idd') title = request.POST.get('title') date_upload = request.POST.get('date_upload') image = gallery_photos.objects.filter(gallery_info_id = idd) data = {'photos':image} return render(request, 'view_gallery.html', data) -
Django use of form input without calling form
it might be dumb question, but is it okey to use input without calling form. my form class st_image(forms.ModelForm): pro_img =forms.ImageField(widget=forms.FileInput(attrs={"id" :"upload_image", "class":"form-control image"})) class Meta: model=CustomUser fields= [ 'pro_img'] my View def st_profile_img(request): pk = request.user.id obj = get_object_or_404(CustomUser, pk=pk) form=st_image(request.POST or None,request.FILES or None, instance=obj) if request.method == 'POST': if(form.is_valid()): form.save() messages.success(request, "Амжилттай бүртгэлээ") return HttpResponseRedirect(reverse('st_profile')) else: messages.error(request, "Зөвхөн зураг хийнэ үү") return HttpResponseRedirect(reverse('st_profile')) My template <form method="POST" action="{% url 'st_profile_img' %}" enctype="multipart/form-data" id="image-form"> {% csrf_token %} <label for="upload_image" class="text-center student-profile-img"> <img id="uploaded_image" class="image-responsive" src="{{ user.pro_img.url }}" alt=""> <div class="overlay"> <div class="text">Засах</div> </div> <input type="file" name="pro_img" class="image" id="upload_image" oninput="uploadImage()" style="display: none;" accept="image/x-png,image/jpeg" /> </label> </form> as you can see i didn't use {{form}} so is it okay use input like this(with using same name with expected form input)? Or is there any correct way to call input name using form? (other than request.POST.get and not using attrs) -
overriden clean() function in form.py doesn't work in views.py while authentication in Django
practicing authentication features with Django. It works without assigning cleaned_data to super().clean() in clean() function, but I don't know if it's properly working, so to check which part I am encountering an error, wrote the print('not valid') in views.py and it's printed on terminal. it seems that it doesn't go to next step at form.is_valid(): part. which part should I change to go further at is_valid() part? form.py class AuthenticationForm(forms.ModelForm): password = forms.CharField(label='Password', widget=forms.PasswordInput) class Meta: model = CustomUser fields = ['email', 'password'] def clean(self): cleaned_data = super(AuthenticationForm, self).clean() email = cleaned_data.get('email') password = cleaned_data.get('password') if not authenticate(email=email, password=password): print('not authenticated') raise forms.ValidationError("It's invalid information, please try it again.") return cleaned_data views.py def login_view(request): form = AuthenticationForm() if request.method == 'POST': form = AuthenticationForm(request.POST) if form.is_valid(): email = form.cleaned_data.get('email') password = form.cleaned_data.get('password') user = authenticate(email=email, password=password) if user is not None: login(request, user) return redirect('blogs:home') else: return redirect('accounts:login') else: print('not vailid') context = {'form':form} return render(request, 'accounts/login.html', context) -
Cashing Django page for fast loading
In my Django application I used Per-Site cache method to make fast when I load a page. In settings.py I did the following: MIDDLEWARE = [ 'django.middleware.cache.UpdateCacheMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.cache.FetchFromCacheMiddleware', ] CACHE_MIDDLEWARE_ALIAS = 'default' CACHE_MIDDLEWARE_SECONDS = '604800' CACHE_MIDDLEWARE_KEY_PREFIX = '' but what is happening is that when I make a change on database table, I cannot see the effect in the front end. But going back in the database it is fine. For example I change the name from Peter to Mary, on my template I still see Peter but in the database there is Mary. It seems that I need to synch my cache and the database. Below is what I found over internet, but I do not know where to place this function. is in in views.py? in models? or anywhere else? Please assist from django.db.models.signals import post_save @receiver(post_save, sender=BlogPost) def clear_cache(sender, instance, created, **kwargs): if instance.published_on is not None: cache.delete('feed') -
How can I set CSS class for django-filter generated elements?
I am using django-filter(little library for django elements filtering). And I want to know how can I add some CSS classes to that generated HTML elements. Here is code for filters.py. Thank you from Armenia nice person :) class Filter(django_filters.FilterSet): CHOICES = ( ('ascending', 'По дате (А-Я)'), ('descending', 'По дате (Я-А)'), ) CHOICES2 = ( ('price_low', 'По цене по возрастанию'), ('price_high', 'По цене по убыванию'), ) orderDate = django_filters.ChoiceFilter(choices=CHOICES, method='filter_by_date', label='') orderPrice = django_filters.ChoiceFilter(choices=CHOICES2, method='filter_by_price', label='') category = django_filters.ModelChoiceFilter(field_name='category', queryset=Category.objects.all()) class Meta: model = Product fields = { 'price': ['gt', 'lt'], 'category': [], } def filter_by_date(self, queryset, name, value): expr = 'date' if value == 'ascending' else '-date' return queryset.order_by(expr) def filter_by_price(self, queryset, name, value): expr = 'price' if value == 'price_low' else '-price' return queryset.order_by(expr) -
Django API issue || TypeError at /api Field 'id' expected a number but got
Django API Issue I would so love some help! Been day now trying to sort this issue :( Thank you When there is NO data in the USERaffylinks table the API looks GREAT - see image 1 all is good here - image 1 But after adding data MANUALLY VIA the API POST page - I get the error : TypeError at /api/affypartnerlinks/ Field 'id' expected a number but got <USERaffiliates: David Anttonbb>. ... The above exception (int() argument must be a string, a bytes-like object or a number, not 'USERaffiliates') was the direct cause of the following exception: See image 2 Error Thank you for your help :) MODELS class USERaffiliates(models.Model): owneruserid = models.ForeignKey(User, on_delete=models.CASCADE, default=1) #if no registered user admin owns = 1 user_category = models.BigIntegerField(null=True, default=None, blank=True ) #id key from USERcategories registered_email = models.EmailField(null=True) site_name = models.CharField(max_length=40, null=True) def __str__(self): return self.site_name class USERaffylinks(models.Model): owner_link_useraffyid = models.ForeignKey(USERaffiliates, on_delete=models.CASCADE) #link(s) for each partner stores the id from USERaffiliates owner_link_short = models.CharField(max_length=27, null=True, default=None, blank=True) #short URL allowed ONLY owner_link_long = models.URLField(max_length=100, null=True, default=None, blank=True) #long full URL Y linked_from_typedesc = models.CharField(max_length=12, null=True, default=None, blank=True) owner_link_desc = models.CharField(max_length=30, null=True, default=None, blank=True) owner_link_note = models.CharField(max_length=50, null=True, default=None, blank=True) date_added … -
Page not found (404) http://127.0.0.1:8000/about
I'm getting page not found error but everything is ok please tell me how to solve I am getting the same error with login, about, register urls.py from django.urls import path from blog import views urlpatterns = [ path('', views.home, name='home'), path('login/', views.login, name='login'), path('register/', views.register, name='register'), path('about/', views.about, name='about'), ] setting urls.py from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('', include('blog.urls')), ] views.py def login(request): return render(request, 'blog/login.html') def register(request): return render(request, 'blog/register.html') def about(request): return render(request, 'blog/about.html') login.html {% extends 'base.html' %} {% block title %} login {% endblock %} {% block content %} login {% endblock %} -
How to make PDF viewer in Python/Django?
I'm trying to make an pdf viewer which will be so much user friendly and people will fill that they are reading books in real life. I can't find any updated module in github. I want to make it from scratch without any paid api.