Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
ValidationError during aggregation dealing, invalid date format
I'm working with django 1.6 and I get error in the last line of my code: start__gte=min_date, start__lte=max_date) Here is error: [U "'start__min' value has an invalid format and must be of the form YYYY-MM-DD HH: MM [: ss [.uuuuuuu]] [TZ]" Here is my function: def person_coming_events(person): active_seasons = Season.objects.filter(is_active=True) min_date, max_date = active_seasons.aggregate(Min('start'), Max('end')) production_ids = SeasonProduction.objects.filter(season__in=active_seasons).values_list('production_id', flat=True) return Activity.objects.filter(production_id__in=production_ids, cast__person=person, start__gte=min_date, start__lte=max_date) -
Django form with a text and checkboxes
I just started with Django (i have some experience with python) and i struggle to understand it. I followed the tutorial, completed i successfully, but i cant move on. The tutorial concluded in a form with 2 radio buttons. I was able to modify the radio buttons to checkboxes, and i figured out how to handle if multiple checkboxes are selected. Now i added a textfiled, and i am completely lost. How can i pass multiple arguments to the definition vote? Are they from the details.html? I tried something like this: ... <form action="{% url 'polls:vote' question.id name %}" method="post"> ... But it did not help. I also tried to add multiple inputs to vote def and multiple return statements to result def. How does this line work in views.py?: selected_choice = request.POST.getlist('choice') What is choice and where does it come from? At the details.html all the values are choice.id or something other stuff. My models.py: import datetime from django.db import models from django.utils import timezone # Create your models here. class Name(models.Model): def __str__(self): return self.name_text name_text = models.TextField(max_length=50) pub_date = models.DateTimeField('Jelentkezes ideje') class Question(models.Model): def __str__(self): return self.question_text def was_published_recently(self): return self.pub_date >= timezone.now() - datetime.timedelta(days=1) question_text = β¦ -
Print just changed fields in django models
On my app I am using django-reversion and django-reversion-compare apps extensions to controll object version. When I update object outside admin I would like set_comment() with just updated fields. How can I access to list of updated fields and set they as comment of that reversion? I understand when I compare object version I see which fields was changed, but I want have preview in table history of changes. I was trying do this by django-dirtyfields, but it was return all fields. Add objects: with reversion.create_revision(): # create or update if exists p = Product(reference='010101', name='new name') p.save() Model: class Product(models.Model): reference = models.CharField(max_length=8, unique=True, primary_key=True) name = models.CharField(max_length=60, null=True) -
How to get the latest ID from different class in Django
I saw all the conversations about this issue, but I can't solve it. I am new in this Python-Django programming so if anyone can help me? :) This is my views.py class HistoryProjectCreate(CreateView): template_name = 'layout/create_proj_history.html' model = ProjectHistory project = Project.objects.latest('id') user = User.id fields = ['user', 'project', 'user_start_date'] success_url = reverse_lazy('git_project:index') Var project has to return latest project ID from database, and I have to use it ID in my html form: <form class="form-horizontal" action="" method="post" enctype="multipart/form-data"> {% csrf_token %} <label for="user"></label> <input id="user" type="text" name="user" value="{{ user.id }}" ><br> <label for="project">Project title: </label> <input id="project" type="text" name="project" value="{{ project.id }}" ><br> <!--Here - "project.id" I need latest project ID--> <label for="user_start_date">Start date: </label> <input id="user_start_date" type="date" name="user_start_date" value="{{ projectHistory.user_start_date }}" ><br> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <button type="submit" class="btn btn-success">Submit</button> </div> </div> </form> I am not sure if project = Project.objects.latest('id') is correct statement for getting the latest ID from Project table... -
Django: How to direclty load the data from the method in the view to Html page without any request
I have a method which sends the data to HTML page direclt without any request. views.py def SendSentence(): sentence = "Hello World" html = render_to_string('Display.html', Context({'Sentence': sentence})) return HttpResponse(html) Display.html <html> <head> </head> <body> {% csrf_token %} The data is ...{{ Sentence }}... </body> </html> Kindly let me know Is this possible? or let me know how to get the response directly from the view.py to a html page when it is called -
How can I persist an authenticated API object across different Celery tasks?
How can I persist an API object across different Celery tasks? I have one API object per user with an authenticated session (python requests) to make API calls. A user_id, csrftoken, etc. is sent with each request. I need to schedule different tasks in Celery to perform API requests without re-authenticating for each task. How can I do this? -
Install Django on machine without internet access
I have VM with Win7. Python is running in Version 2.7. Now I want to install Django. I download django as tar.gz from official website. Then I move the file to VM and try to install with... C:\Users\TestUser>pip install D:\Django-1.10.5.tar.gz But it not work. I get this output: Processing d:\django-1.10.5.tar.gz Building wheels for collected packages: Django Running setup.py bdist_wheel for Django Stored in directory: C:\Users\TestUser\AppData\Local\pip\Cache\wheels\78\62\f a\c970671f67ec027f6445dc8ed9a3155e774c0e75ca63dd291b Successfully built Django Installing collected packages: Django Exception: Traceback (most recent call last): File "D:\TestUser\Programm\Python27\lib\site-packages\pip\basecommand.py", lin e 223, in main status = self.run(options, args) File "D:\TestUser\Programm\Python27\lib\site-packages\pip\commands\install.py" , line 298, in run root=options.root_path, File "D:\TestUser\Programm\Python27\lib\site-packages\pip\req\req_set.py", lin e 622, in install **kwargs File "D:\TestUser\Programm\Python27\lib\site-packages\pip\req\req_install.py", line 808, in install self.move_wheel_files(self.source_dir, root=root) File "D:\TestUser\Programm\Python27\lib\site-packages\pip\req\req_install.py", line 1003, in move_wheel_files isolated=self.isolated, File "D:\TestUser\Programm\Python27\lib\site-packages\pip\wheel.py", line 339, in move_wheel_files clobber(source, lib_dir, True) File "D:\TestUser\Programm\Python27\lib\site-packages\pip\wheel.py", line 323, in clobber os.utime(destfile, (st.st_atime, st.st_mtime)) WindowsError: [Error 87] Falscher Parameter: 'D:\\TestUser\\Programm\\Python27\\ Lib\\site-packages\\django\\shortcuts.py' What's wrong? Thanks. Eric -
Apache, mod_wsgi - Forbidden. Don't have permission
I'm getting an error when trying typing in http://localhost:8080/ in my browser. It tells me: Forbidden You don't have permission to access / on this server. I am probably not setting the path's correctly. So that's why I'm asking for help here. My httpd config file have the following: Listen 8080 LoadModule wsgi_module "c:/anaconda3/lib/site-packages/mod_wsgi/server/mod_wsgi.cp35-win_amd64.pyd" WSGIPythonHome "c:/anaconda3" WSGIScriptAlias / C:/Users/Rasmus/workspace/MainSite/src/MainSite/wsgi.py WSGIPythonPath C:/Users/Rasmus/workspace/MainSite/src/MainSite <Directory C:/Users/Rasmus/workspace/MainSite/src/MainSite> <Files wsgi.py> Order deny,allow Allow from all </Files> </Directory> I have red a bunch of stackoverflow questions similar, and they seem to get solved by setting different permissions in the Directory tag. But I've tried alot of different combinations. And I don't think that's the problem. Because if I remove the WSGIScriptAlias and WSGIPythonPath I will get the page "It works!". The path I copied directly from my workspace enviornment. And my directory in C:/Users/Rasmus/workspace/MainSite/ look like this: specs: apache 2.4.25 win-64 mod_wsgi 4.5.14 python 3.5 -
django-tables2 cannot sort on certain fields
I have a Django model defined as follows: class DummyModel(models.Model): name = models.CharField(max_length=100, name='Name') description = models.CharField(name='Description', max_length=150) time_points = models.PositiveIntegerField(name="Time Points") more_text = models.CharField(max_length=100, name="More Text") class Meta: db_table = "dummy" I would like to later do some customization so I have a table class as well: class DummyTable(tables.Table): class Meta: model = DummyModel attrs = {'class': 'paleblue'} I have a corresponding view which is as follows: @login_required(login_url="login/") def review(request): table = DummyTable(DummyModel.objects.all()) RequestConfig(request).configure(table) return render(request, 'review.html', {'reviews': table}) Finally, I render it ion my template using: {% block content %} {% load static %} {% load render_table from django_tables2 %} <div class="function-container"> {% render_table reviews %} </div> {% endblock %} Now this renders fine but when i try to sort the time Points column (by clicking on the column header), it comes with the error: Invalid order_by arguments: [u'Time Points'] Request Method: GET Request URL: http://127.0.0.1:8000/review/?sort=Time+Points Django Version: 1.10.5 Exception Type: FieldError Exception Value: Invalid order_by arguments: [u'Time Points'] However, if I point the browser to http://127.0.0.1:8000/review/?sort=time_points, this works. So, somehow the correct field name is not passed. I tried changing the name and adding verbose_namne fields as: time_points = models.PositiveIntegerField(name="time_points", verbose_name="Time Points") However, this returns in no β¦ -
Django Rest Framework - normal PUT json data returns FIleUpload parse error
For some reason I get the error below when trying to do a PUT call with jquery to my REST API. {"detail":"FileUpload parse error - none of upload handlers can handle the stream"} This is the view: class GateView(APIView): def get_object(self, pk): try: return Gate.objects.get(pk=pk) except Gate.DoesNotExist: raise Http404 def get(self, request, coords, format=None): results = [] try: pa_distances = [] for pa in Gate.objects.all(): point = Point(float(coords.split(',')[0]),float(coords.split(',')[1])) polygon = shape(pa.polygone['features'][0]['geometry']) if polygon.contains(point): results = [pa] break except Exception, e: print e pass serializer = GateSerializer(results, many=True) return JSONResponse(serializer.data) def put(self, request, coords, format=None): gate = self.get_object(coords) print gate serializer = GateSerializer(gate, data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) jQuery: $.ajax({ url: '/protected-area/' + type + '/' + pk + '/', //Your api url type: 'PUT', //type is any HTTP method data: {name: feature.getProperties().name}, //Data as js object success:function(){ } }); Serialiser : class GateSerializer(serializers.ModelSerializer): protected_area = serializers.ReadOnlyField(source='protected_area.name') class Meta: model = Gate fields = ('protected_area', 'name') -
How to send heatbeats / ping over django channels
We have Django Channels running with Daphne and redis. Before we had ws4redis running and it supports a heartbeat message out of the box. Our client code depends on this heartbeat to confirm an active connection, but django does not care if it is still active or not. Because of this we don't need to keep track of everything server side but we do need the heartbeat. How do I send a heartbeat / ping message using channels or daphne? I can't find any docs on this. -
Styling django modelform like the administration forms
Is it possible in any way to easily use the styles from the Django admin with my modelforms? I've currently added the form.css file but I've yet to dynamically generate the relevant classes. -
Django REST framework: AttributeError: 'User' object has no attribute 'books'
http://127.0.0.1:8000/app_restFramework/users/ , return text AttributeError at /app_restFramework/users/ 'User' object has no attribute 'books' models.py class User(models.Model): username = models.CharField(max_length=100) class Book(models.Model): name = models.CharField(max_length=100) author = models.CharField(max_length=100) publisher = models.CharField(max_length=100) time = models.CharField(max_length=100) owner = models.ManyToManyField(User) serializers.py from app_restFramework.models import Book,User class UserSerializer(serializers.ModelSerializer): books = serializers.PrimaryKeyRelatedField(many = True, read_only = True) class Meta: model = User fields = ('id', 'username', 'books') views.py class UserList(generics.ListCreateAPIView): queryset = User.objects.all() serializer_class = UserSerializer urls.py url(r'^app_restFramework/users/$', app_restFramework.views.UserList.as_view() ), -
python-social-auth with django Twitter error
I'm trying to use python-social-auth for authentication and I'm running into some problems with Facebook and Twitter (Google is working). For Twitter I am getting the error: ValueError at /login/twitter/ Only unicode objects are escapable. Got None of type <type 'NoneType'>. I have followed all the steps here. Here's my template link: <a href="{% url 'social:begin' 'twitter'%}?next={{ index }}" class="btn btn-social-icon btn-twitter"><span class="fa fa-twitter"></span></a> Here's my url.py: url('', include('social_django.urls', namespace='social')), And some info from settings.py INSTALLED_APPS = [ ... 'social_django', ] TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ ... 'social_django.context_processors.backends', 'social_django.context_processors.login_redirect', ], }, }, ] AUTHENTICATION_BACKENDS = ( 'social_core.backends.google.GoogleOAuth2', 'social_core.backends.facebook.FacebookOAuth2', 'social_core.backends.twitter.TwitterOAuth', 'django.contrib.auth.backends.ModelBackend', ) I'm getting the following traceback error: Traceback: File "/home/henry/Documents/Ian/env/local/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner 39. response = get_response(request) File "/home/henry/Documents/Ian/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request) File "/home/henry/Documents/Ian/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/henry/Documents/Ian/env/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 57. response = view_func(request, *args, **kwargs) File "/home/henry/Documents/Ian/env/local/lib/python2.7/site-packages/social_django/utils.py" in wrapper 50. return func(request, backend, *args, **kwargs) File "/home/henry/Documents/Ian/env/local/lib/python2.7/site-packages/social_django/views.py" in auth 19. return do_auth(request.backend, redirect_name=REDIRECT_FIELD_NAME) File "/home/henry/Documents/Ian/env/local/lib/python2.7/site-packages/social_core/actions.py" in do_auth 27. return backend.start() File "/home/henry/Documents/Ian/env/local/lib/python2.7/site-packages/social_core/backends/base.py" in start 34. return self.strategy.redirect(self.auth_url()) File "/home/henry/Documents/Ian/env/local/lib/python2.7/site-packages/social_core/backends/oauth.py" in auth_url 166. token = self.set_unauthorized_token() File "/home/henry/Documents/Ian/env/local/lib/python2.7/site-packages/social_core/backends/oauth.py" in set_unauthorized_token 222. token β¦ -
How to send the data to Loading Html page directly without any request while the data is getting processed in views.py in Django
I am having a method in the Django view which has a loop. Each sentence from the loop is getting processed and the final output is sent to the html. Meanwhile i would like to show that the particular sentence is getting processed on the same html page. views.py def get_String(request): Parameter = request.POST.get('search_Key') Data1 = data.objects.all() for item in Data1: print(item.Sentence) Output1 = returnResult1(Parameter ,item.Sentence) Output2 = returnResult2(Parameter ,item.Sentence) return HttpResponse(json.dumps({"searched_key":Parameter,"Result1": Output1,"Result2":Output2}),content_type="application/json") The sentence one by one getting processed and the final output is shown. Meanwhile I need to show that, the current item.Sentence is only getting processed in the below HTML which is actually shown at the time of processing. Loading.html <html> <head> </head> <body> {% csrf_token %} <div id="progress1"><font size="2"> Loading... the processing sentence is: {{ List }}</font> </div> </body> </html> Kindly let me know how to send the Sentence directly from views.py to Loading.html page without any request. -
Filter Album with empty set of tracks Django-Model
I have two models: class Album(models.Model): album_name = models.CharField(max_length=100) artist = models.CharField(max_length=100) class Track(models.Model): album = models.ForeignKey(Album, related_name='tracks', on_delete=models.CASCADE) order = models.IntegerField() title = models.CharField(max_length=100) duration = models.IntegerField() Now how can i get the collection of Album with empty set of tracks? -
Django queries to retrieve specific attribute
max_shoots = player.objects.all().aggregate(Max('Num_baskets')['Num_baskets__max'] name1 = player.objects.get(Num_baskets=max_shoots) return render( request, 'index.html', context={'max_shoots':max_shoots, 'name':name1 }, ) Here player is our class name. we need to retrieve a specific attribute(eg:roll no. of a 'name1').could you please help me to solve it.using max_shoots that we already retrieved. I want to know Django query to retrieve above information. -
celery custom library in task file causing ImportError: cannot import name 'foo'
I am trying to use a custom library in a celery task file,but whenever I am try to start the worker there is a ImportError: cannot import name 'foo' error. These are the versions of django and celery I am using, along with an example of the custom python library that is being installed from a git repo. celery==4.0.2 -e git+https://gitlab.com/my-repo#egg=foo Django==1.10.5 If I don't try in import the custom library, the celery and the worker process runs without any issues. This is what the project structure looks like. . βββ app β βββ admin.py β βββ apps.py β βββ connect_test.py β βββ forms.py β βββ __init__.py β βββ models.py β βββ tasks.py β βββ tests.py β βββ urls.py β βββ views.py βββ db.sqlite3 βββ web_project βββ celery.py βββ __init__.py βββ settings.py βββ urls.py βββ wsgi.py thanks -
Form submission not generating new Post object
I'm currently creating a Social platform with Django. Right now, I'm developing their Dashboard and want endusers to be able to publish their own posts. This is my Post model: class Post(models.Model): user = models.ForeignKey(User) posted = models.DateTimeField(auto_now_add=True) content = models.CharField(max_length=150) Likes = models.IntegerField(default=0) def __str__(self): return self.user.username My Form for the Post model: class Post_form(forms.ModelForm): class Meta: model = Post fields = ( 'content', ) def __init__(self, *args, **kwargs): super(Post_form, self).__init__(*args, **kwargs) self.fields['content'].label = "" self.fields['content'].widget.attrs={ 'id': 'id_content', 'class': 'myCustomClass', 'name': 'name_content', 'placeholder': 'What are you thinking about?', } When the form gets submitted, it correctly generates a POST request with the value of the content field. When I save my form in the view, no new post gets generated. What am I doing wrong? My views.py: def dashboard_view(request): if request.POST: form = Post_form(data=request.POST, instance=request.user) if form.is_valid(): form.save() // <- no new post gets generated after saving return redirect(reverse('dashboard')) else: return redirect(reverse('settings')) else: form = Post_form gebruikers = User.objects.all() all_posts = Post.objects.all().order_by('-posted') return render(request, 'Dashboard/index.html', {'gebruiker':gebruikers, 'posts':all_posts, 'form': form},) -
How add russian language in LIKE
Got code if request.POST.get('search'): search = request.POST.get('search') i have in search ΠΏΠΈΡΡΠ° -Russian literals next i try do query with LIKE if search: shops = shops.filter( name__icontains=search) Internal Server Error: /sort_rest_filter/ Traceback (most recent call last): File "C:\Python27\lib\site-packages\django\core\handlers\exception.py", line 39, in inner response = get_response(request) File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "E:\PhytonProgects\natarelke\catalog\views.py", line 28, in filter_ajax_check response_data = ffunc.get_filer_data(request, response_data) File "E:\PhytonProgects\natarelke\catalog\filer_functions.py", line 112, in get_filer_data print(shops.query) UnicodeEncodeError: 'ascii' codec can't encode characters in position 811-813: ordinal not in range(128) i think my problem in UTF-8 - asc encoding How i can fix it? -
Cannot able to send Email on Django 1.10?
I am facing a problem on sending mail on Django version 1.10 and the following erron can be appear in my console. Error for res in getaddrinfo(host, port, 0, SOCK_STREAM): gaierror: [Errno -2] Name or service not known My code is, settings.py EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST='smtp.gmail.com' EMAIL_PORT = 587 EMAIL_HOST_USER = 'mymail@gmail.com' EMAIL_HOST_PASSWORD = '************' DEFAULT_EMAIL_FROM = 'mymail@gmail.com' EMAIL_USE_TLS = True views.py from django.shortcuts import render from django.core.mail import EmailMessage from django.core.mail import send_mail def contact(request): if request.method == 'POST': print "----------------" email = EmailMessage('title', 'body', to=['mymail@gmail.com']) email.send() print"--------------------stop" return render(request, 'contact/contact.html') return render(request, 'contact/contact.html') -
starting first django project error
I installed and downloaded django on my windows 10 using C:\Users\User>py -m pip install django from command prompt .I am stuck as how to create my first project . I tried these two after watching video tutorials C:\Users\User>django-admin startproject hockeywb and C:\Users\User>py -m pip django-admin startproject website but in both cases i got errors . -
system check error when try to run server in django
i am newbie in django framework trying to build template for upload image in filesystem and show this image on page. first i get error first i get error in File "/home/tac/Desktop/myproject/myapp/urls.py", line 5, in <module> url(r'^$', 'list', name='list'), File "/usr/local/lib/python2.7/dist-packages/django/conf/urls/init.py", line 85, in url raise TypeError('view must be a callable or a list/tuple in the case of include().') TypeError: view must be a callable or a list/tuple in the case of include(). somehow I solve this error but after that i face another error enter image description here -
Reading GeoJSON keys and values from a feature
Im using openlayers to create, display and edit features on the map. Features are saved as a JSONField in Django. Post Save I adda key django_pk to the JSON. How can I get this djanog_pk directly from the feature? I need to do this so wehn the feature is edited, I know what feature to update in django. My JS code below: <script> var raster = new ol.layer.Tile({ source: new ol.source.OSM() }); var source = new ol.source.Vector({wrapX: false}); var vector = new ol.layer.Vector({ source: source }); var format = new ol.format.GeoJSON(); var select = new ol.interaction.Select({ wrapX: false }); var modify = new ol.interaction.Modify({ features: select.getFeatures() }); var map = new ol.Map({ interactions: ol.interaction.defaults().extend([select, modify]), layers: [raster, vector], target: 'map', view: new ol.View({ center: [-11000000, 4600000], zoom: 4 }) }); var features = new ol.source.Vector({ projection: 'EPSG:4326' }); {% for polygon in polygons.0.gates %} console.log(format.readFeature({{ polygon|safe }}).getProperties())) {% endfor %} features.addFeature(format.readFeature({{ polygons.0.protected_area|safe }})); {% for polygon in polygons.0.gates %} features.addFeature(format.readFeature({{ polygon|safe }})); console.log(format.readFeature({{ polygon|safe }})) {% endfor %} var featureOverlay = new ol.layer.Vector({ source: features, style: new ol.style.Style({ fill: new ol.style.Fill({ color: 'rgba(255, 255, 255, 0.2)' }), stroke: new ol.style.Stroke({ color: '#ff78d1', width: 2 }), image: new ol.style.Circle({ radius: 6, β¦ -
Referer checking failed ( Referer is insecure while host is secure)
I am stuck at this error. I deployed my code on a production server and it is running on port 80. When I try to log in on the admin page. It gives me 403 error as shown in the image. What could be possibly the reason? Is there some problem in my Django code or in nginx configuration? setting.py file import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SECRET_KEY = 'xxx' DEBUG = True ALLOWED_HOSTS = ['*'] INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] ROOT_URLCONF = 'project.urls' WSGI_APPLICATION = 'project.wsgi.application' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, "static/") nginx conf is: server { listen 80; server_name www.example.com; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; location /static/ { alias /example/path/to/static/; } location / { include /etc/nginx/sites-available/uwsgi_params; uwsgi_pass unix:/path/to/project/yo.sock; uwsgi_param UWSGI_SCHEME https; uwsgi_pass_header X_FORWARDED_PROTO; proxy_set_header X-Forwarded-Proto https; } } How β¦