Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Sending email to gmail from local machine using django allauth app
I am trying to send a real email from my local to gmail using django allauth app.I can see the verification email through the console. MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: Please Confirm Your E-mail Address From: myemail@gmail.com To: useremail@gmail.com Date: Tue, 08 Aug 2017 15:23:19 -0000 Message-ID: <20170808152319.1056.31735@Lenovo-PC> From and to email are real gmail account. I was going through django-allauth - Send email verification using Gmail account and settings.py contains the settings for gmail. EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_HOST_USER = DEFAULT_FROM_EMAIL = 'myemail@gmail.com' EMAIL_HOST_PASSWORD = '******' if DEBUG: EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" But for some reason I am not getting the emails in my gmail account. Any help is highly appreciated. -
Python Django custom logging Handler
I have a custom log Handler which I have attached to Django settings.py::LOGGING congif dict. The goal is to call another function defined in the CustomHandler::emit method whenever a log of level error occurs. Here is the configuration of custom logging Handler: # file path: utilities.log.py class CallClogs(Handler): """ An exception loggers that will call a specific C-function to log events in a single file which contains logs that are generated by django server and also the background process some of the C functions perform """ def __init__(self): # run the regular Handler __init__ Handler.__init__(self) print('####################') def emit(self, record): # get all the parameters to pass on to # the c function # clean the data from the logger # call the C Code a wait for the response print("Called C logger", record.getMessage()) c_logger(0, record.getMessage()) LOGGING config dict in settings.py LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse', }, 'require_debug_true': { '()': 'django.utils.log.RequireDebugTrue', }, }, 'formatters': { 'django.server': { '()': 'django.utils.log.ServerFormatter', 'format': '[%(server_time)s] %(message)s', } }, 'handlers': { 'console': { 'level': 'INFO', 'filters': ['require_debug_true'], 'class': 'logging.StreamHandler', }, 'django.server': { 'level': 'INFO', 'class': 'logging.StreamHandler', 'formatter': 'django.server', }, 'mail_admins': { 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler' }, … -
Display image in django template through nginx
I want to display a protected image in a django template but it is in a protected directory. This is my nginx configuration file: server { listen 80; server_name server_name; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { autoindex off; alias /home/mario/static/; } location /media/ { internal; alias /home/mario/media/; } location / { include proxy_params; proxy_pass http://unix:/home/mario/dev/django-project/project/project.sock; } } The image is in the media location. I can view a full-size image with this function: def view_image(request): response = HttpResponse() response['Content-Type'] = "" response['X-Accel-Redirect'] = '/media/image.jpg' return response I can also download the image with this function: def download_image(request): image = '/media/image.jpg' response = HttpResponse() response["Content-Disposition"] = "attachment; filename={}".format(image) response['X-Accel-Redirect'] = image return response This is the html page: {% extends "base.html" %} {% block head_title %}Gallery | {{ block.super}}{% endblock head_title %} {% block content %} <h1>{{ object.title }} <small> {{ object.category }}</small></h1> <p>{{ object.location }}</p> <p>{{ object.timestamp }}, Updated {{ object.updated|timesince }} ago</p> {% if object.image %} <img src="{{object.image.url}}" alt="Image"> {% else %} <p>No image loaded</p> {% endif %} {% endblock %} If there is not the internal option in the nginx configuration all works perfectly but it would be unsecure. There is any … -
Django: Changing the index site? (home page)
The index site on my Django homepage stopped working because of a problem that will take a very long time to fix. The site can't be down for that long so I am trying to change the index site so that if you go to the primary url you will atleast end up on the website. What I have done is change the urls.py file in the primary application, where I simply replaced the line url(r'^', include('news.urls', namespace='news')), to url(r'^', include('events.urls', namespace='events')), in the urlpatterns list, where news is the faulty page and events is the page that I want to be shown. However, after pushing this to live nothing changed, and for some reason my local Django development server is not working. Did I do anything wrong, or is there anything else I have to do as well? Thanks. -
How to import a project as a lib in a Django project?
I currently have two independent Python projects, one of them is a Django project. I want to import my first project into my Django project as a library (or an app?). I tried to create a Python package in the Django project at the same level as the other apps but it does not recognize it as a package that I can freely use in my views for example. Is that a configuration issue or should I do differently? -
Django- restrict users to access urls
i'm creating a app.it has manytomany field to store data about class and students. models.py class class_room(models.model): user = models.ForeignKey(User,related_name = 'classroom') title = models.charField(max_length=50) students=models.ManyToManyField(User,related_name='commits',\ symmetrical=FAlSE) urls.py url(r'^class/(?p<title>[-\w]+)/(?p<id>[\d]+)/',views.list,name ='list'), Basically one user(Teacher) can create many class_room .Each class_room have one title and many students following in that class. problem is: Each class_room have unique url. Eg (mywebsite.com/science/88/) this link is access only for following students not for anonymous user.This is a loop hole if any non following students try some random url like this they could see the page (mywebsite.com/maths/2500/). How to restrict a student from access a page which he is not following? -
Display a relative link in Django admin
I have a model 'Articles'. Any authors can write a new article in the Django admin panel. Once the article is written and saved, the author do not publish it yet. What I would like to do is, when the author wants to edit the article, there is a link like this : <a href="/myapp/read/id_article">Preview the article</a> where id_article is a variable. By this way, an author could see the render of the current article before to publish it. This is my model : class Articles(models.Model): title = models.CharField(max_length=50, null=False, verbose_name="Titre") text = HTMLField() image = models.FileField(upload_to='media/articles/', validators=[validate_file_extension], blank=True, null=True, verbose_name="Image de présentation") games = models.ForeignKey(Games, verbose_name="Jeux", blank=True, null=True) author = models.ForeignKey(User, verbose_name="Auteur") is_statut = models.BooleanField(default=True, verbose_name="Statut") published = models.BooleanField(default=True, verbose_name="Publié") date = models.DateTimeField(auto_now_add=True, auto_now=False, verbose_name="Date de création") update = models.DateTimeField(auto_now=True, verbose_name="Dernière modification") def __str__(self): return self.title And this is what I have for now for my Admin view : class ArticlesAdmin(admin.ModelAdmin): list_display = ('date', 'title', 'author', 'games', 'is_statut', 'published', 'update') fieldsets = ( ('Général', { 'fields': ('title', 'author', 'is_statut', 'published') }), ('Choisir une image de présentation', { 'fields': ('image',)}), ('En rapport avec le jeu :', { 'fields': ('games',)}), ('Contenu de l\'article', { 'fields': ('text',)}), ) admin.site.register(Articles, ArticlesAdmin) Thanks for … -
The Right Way to Account for Daylight Savings Time in Python (Django)
I've been working in Django (1.11) and Python (3.5.3) with tracking events that repeat from week to week or month to month, and have encountered a small issue when the jump across a DST change occurs. As an example, say a movie is shown every Wednesday at 2pm. At a certain point in November, the time currently switches to 1pm when the DST is no longer active. That isn't the desired behavior - if an event is at 2pm, it should remain at 2pm regardless of DST. Right now, I'm handling it with: new_start_date = old_start_date.replace(tzinfo=None) + datetime.timedelta(weeks=1) And it works, but I also know it throws a warning in the background. Is there a better way to account for that hour discrepancy? -
django orm delete object derived from another model
I have the following issue : class A (models.Model): name = models.CharField(max_length=80, default="") class B(A): another_name = models.CharField(max_length=80, default="") How is it possible to get A automatically deleted if B is deleted ? If I work with a foreign_key and DELETE_CASCADE all is fine, but with derived models not. -
python django allauth terminal error
I am new to django so I followed books and I tried to implement django AllAuth after putting the right codes in the appropriate place I got an error when I tried to run the server. ERROR Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/Users/Olar/Desktop/tryTen/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line utility.execute() File "/Users/Olar/Desktop/tryTen/lib/python2.7/site-packages/django/core/management/__init__.py", line 307, in execute settings.INSTALLED_APPS File "/Users/Olar/Desktop/tryTen/lib/python2.7/site-packages/django/conf/__init__.py", line 56, in __getattr__ self._setup(name) File "/Users/Olar/Desktop/tryTen/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup self._wrapped = Settings(settings_module) File "/Users/Olar/Desktop/tryTen/lib/python2.7/site-packages/django/conf/__init__.py", line 110, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/Users/Olar/Desktop/tryTen/src/tryTen/settings.py", line 164 SyntaxError: Non-ASCII character '\xe2' in file /Users/Olar/Desktop/tryTen/src/tryTen/settings.py on line 164, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details I am running python 3.5 -
files is empty.How can I fix this?
I wrote file upload system like def upload_save(request): photo_id = request.POST.get("p_id", "") if (photo_id): photo_obj = Post.objects.get(id=photo_id) else: photo_obj = Post() files = request.FILES.getlist("files[]") print (request.FILES) photo_obj.image = files[0] photo_obj.save() photos = Post.objects.all() context = { 'photos': photos, } return render(request, 'registration/accounts/photo.html', context) Now,when files of files = request.FILES.getlist("files[]") is empty,error happens.So,I think I should write if-else statement is for the case that file is empty,but I do not know how I can write it.How should I write this? I think it is like files = request.FILES.getlist("files[]") print (request.FILES) if files != null : photo_obj.image = files[0] photo_obj.save() photos = Post.objects.all() context = { 'photos': photos, } return render(request, 'registration/accounts/photo.html', context) else: print("ERROR") -
Django: Generate form from dictionary
I'm currently working on a django-app where users have the option to select synonyms for a select number of words. These words are then replaced all over the website by these synonyms these synonymes are defined as a separate model: class TransportSynonyms(models.Model): user= models.ForeignKey(user) key = models.CharField(max_length=255) value = models.CharField(max_length=255) This process is done in part with template tags, and as such the number of words that can be 'synonymed' is limited. For example, the following words can be replaced by synonymes: 'train', 'plane'. And appear like so in the html template: {% get_trans "train" %} {% get_trans "plane" %} I now want to give user the ability to define synonymes for themselves, without the admin view. I created a few pages using a ListView as an overview (so the users could see which words they can change) with individual buttons that led to EditViews. However, I'm since user have no synonyms linked to them by default, the ListView appears empty. I could solve that by passing a list from the view, but that list wont have the required '.id' values and would be worthless for linking to the EditViews. I have to find a way to fill the ListView … -
How to customize html produced by django form fields
I am writing a form in Django (Django 1.11.2, python 3.5.3). I am unhappy with html it produces - I found better input element in some external library. I have forms.py: class ReportForm(forms.Form): fromTime = forms.DateField(label="Od") toTime = forms.DateField(label="Do") and html template: <form action="/report/selectDocument" method="post"> {% csrf_token %} <table>{{ form.as_table }}</table> <input type="submit" value="Submit" /> </form> Which together produces: <input type="text" name="fromTime" required id="id_fromTime" /> .... <input type="text" name="toTime" required id="id_toTime" /> While I would like to get: <input data-dependent-validation='{"from": "date-to", "prop": "max"}' type="date" id="fromTime" placeholder="RRRR-MM-DD" /> <input data-dependent-validation='{"from": "date-from", "prop": "min"}' type="date" id="toTime" placeholder="RRRR-MM-DD" /> How to tell django to produce such html for form fields? Change can be global, but I would prefer it to be per-field. The changes look small, but I want to achieve something like this: http://fiddle.jshell.net/KEfEX/37/ I can hardcode custom input elements, but I would prefer to use django forms. Forms however produce quite poor date input - user must write the date using keyboard instead of selecting with mouse (I know about widget=forms.SelectDateWidget(), but solution from fiddle is even better). -
Django UserCreationForm with one password
I'm wondering if I could make UseCreationForm without password confirmation (only password1). Code I'm working with: #forms.py class UserRegistrationForm(UserCreationForm): email = forms.EmailField(max_length=200, help_text='Required') class Meta: model = User fields = ('username', 'email', 'password1', 'password2') #views.py class HomeView(View): template_name = 'home.html' def get(self, request): queryset = Profile.objects.filter(verified=True) form = UserRegistrationForm() context = { 'object_list': queryset, 'form':form, 'num_of_users': User.objects.all().count() } return render(request, self.template_name, context) The problem is, that when I make forms.py as that: class UserRegistrationForm(UserCreationForm): email = forms.EmailField(max_length=200, help_text='Required') class Meta: model = User fields = ('username', 'email', 'password1') Form has also field password2. Any solution of that? -
How to get session values in settings file using Django and Python
I have one issue. I need to get the session value into settings.py file using Django and Python. I am explaining my code below. settings.py """ Django settings for carClinic project. """ import os from datetime import datetime, timedelta """ Build paths inside the project like this: os.path.join(BASE_DIR, ...) """ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) """ SECURITY WARNING: keep the secret key used in production secret! """ SECRET_KEY = 'e8rq8bj5=w6cyiw&37s2kdys&$mg9m8agh@-%c6_+-jpu-21y=' """ 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', 'bookingservice' ] 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', ] ROOT_URLCONF = 'carClinic.urls' 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', ], }, }, ] WSGI_APPLICATION = 'carClinic.wsgi.application' """ Database """ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } """ Password validation """ 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', }, ] """ Internationalization """ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True MAX_AGE = timedelta(seconds=3600) … -
Django - model Inheritance - store that shares a common stock
I'm making a store (for the lols), i want to make it so that if i have an item i have a stock and possible multiple listings of that item. So basically i want to have some properties like: How many is left, Name, weight, and so on But then i want some other properties to be different like the price. So the idea is that i can have different listings like: 1 car for 200 dollars and 2 cars for 175 dollars. But i want them to have the same stock pool so when someone purchases the item they both get updated. I can't find any convenient way of doing this in django, it would seem i need some kind of mix between proxy and multi table inheritance. So my question is did i missunderstand the whole concept of inheritance (e.g is this possible with inheritance) in django, do i have to find another way of doing this, maybe it isn't possible or just too overkill to implement? Thanks -
how to make advance search in django?
currently i am working in Django and more precisely in filter method. according to my knowledge filter works like this. if i search "Apple iphone 7 plus" than it will find whole sentence in my records where it occurs but i want to modify this filter in following manner. i want to split the query in words and then find those words in document to search, like upper query should return those records which contains "apple" && "iphone" && "7" && "plus". can anybody tell me how can i improve my query. which builtin function in django can help me. my recent code looks like is following. @api_view(['GET']) def Filter_Mobiles(request,query): print(query) try: que = Q(SNR_Title__icontains=query ) Mobile_all = Mobile_DB.objects.filter(que) except Mobile_DB.DoesNotExist: return Response(status=status.HTTP_404_NOT_FOUND) please ignore syntax mistakes. how can i modify this. is there any built in function to help me? please suggest me changes. Thanks in advance. -
django text editor in admin panel
I would like to get your mind. Until now, I used TinyMCE to create some blog's article in my Django admin panel. But It's not really a good choice, I think there are better text editor. Do you know them ? What do you currently use ? But I want something easy to setup if possible. Thank you -
Slow database connection times with MS Azure
I am running a linux VM and a high-throughput MS SQL server in the same geographical location in Azure (East US). The drivers involved are ODBC for SQL server 13 and database API pyodbc (Django). It takes significantly longer than one would expect to obtain a simple connection to our database (on the order of >50 ms). I've tried everything from reinstalling drivers/switching database API's/upgrading the SQL server to no avail - I've not seen the connection-acquiring time be faster than 51 ms. What am I doing wrong and how can this be fixed? -
python django - ImportError: No module named lib
i'm a newbie in this field. I develops web application with google app engine using django framework. i have a troubleshot about python lib dir problem... ImportError: no module named... ROOT ├── lib │ ├── django │ ├── pytz │ ├── wanttousing_lib │ └── ... ├── mysite │ ├── __init__.py │ ├── settings.py │ ├── controllers.py │ ├── models.py │ ├── views.py │ ├── templates │ │ └── like │ │ ├── index.html │ │ └── _likehelpers.html │ └── .... ├── test │ ├── like │ │ ├── models_tests.py │ │ └── controllers_tests.py │ └── .... ├── static │ ├── css │ └── js ├── app.yaml ├── manage.py ├── appengine_config.py └── requirements.txt in this dir, failed runserver .. in my test code controllers_tests.py `from wanttousing_lib import example_module` importError wanttousing_lib.......... but if I move my wanttousing_lib to ROOT dir, it works..... ROOT ├── lib │ ├── django │ ├── pytz │ │ └── ... ├── mysite │ ├── __init__.py │ ├── settings.py │ ├── controllers.py │ ├── models.py │ ├── views.py │ ├── templates │ │ └── like │ │ ├── index.html │ │ └── _likehelpers.html │ └── .... ├── test │ ├── like │ │ ├── models_tests.py │ │ └── … -
limiting number of rows for every distinct values
I have a table set with below data format: +-----+-----------------+------------+-------------+ | id | userid | city | sign_in | +-----+-----------------+------------+-------------+ | 371 | smepfx4c8b20400 | A | success | | 370 | smepfx6735f8742 | A | success | | 369 | smepfx5d8b58459 | P | failure | | 368 | smepfx48f038186 | C | failure | | 367 | smepfxf4b7c6336 | A | failure | | 366 | smepfx9c4e66230 | A | success | | 365 | smepfxd17db5687 | A | success | | 364 | smepfx355675462 | N | success | | 363 | smepfxcc78c5149 | N | success | | 362 | smepfxb0e844833 | N | success | | 361 | smepfx65ec54746 | N | success | | 360 | smepfx74e044621 | N | success | | 359 | smepfx4b3759839 | N | success | | 358 | smepfxbba779305 | N | success | | 357 | smepfxfbec98684 | B | failure | | 356 | smepfx0123e8146 | B | failure | | 355 | smepfx62b587897 | N | in_process | | 354 | smepfx0aba27775 | N | in_process | | 353 | smepfxad9986739 | N | in_process | | 352 | smepfx9a5f96601 | N | in_process | … -
Django auto redirecting to url folder of a different project
My current project url file redirects empty urls to a certain app folder new_project/url.py from django.conf.urls import url from django.contrib import admin from django.conf.urls import include from django.views.generic import RedirectView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^accounts/', include('django.contrib.auth.urls')), url(r'^new_app/', include('new_app.urls')), url(r'^$', RedirectView.as_view(url='/new_app/', permanent=True)), ] I have another older project which uses a similar urlpattern: old_project/urls.py urlpatterns = [ url(r'^$', RedirectView.as_view(url='/old_app/', permanent=True)), ] But when I try to open the new project site(www.new_project.com/), I get a 404 error. The error says the urlpatterns are being compared with a the old project string (old_app/) Error page: Using the URLconf defined in new_project.urls, Django tried these URL patterns, in this order: 1. ^admin/ 2. ^accounts/ 3. ^new_app/ 4. ^$ The current path, old_app/, didn't match any of these. All my projects are using the same redirect folder. I am guessing this has something to do with how I have used permanet=True. Why is this happening and how can this be solved? -
I don't understand how to fix this 'DatabaseOperations' error: object has no attribute 'select'
I'm trying to setup a GeoDjango site with PostGIS on Heroku. I've been trying to Google this AttributeError I get but I can't find information or solution. When trying to makemigrations or migrate the database with heroku run python manage.py migrate it returns this error. AttributeError: 'DatabaseOperations' object has no attribute 'select' I get no problems locally. I've followed the instructions on Heroku and created the database extension. https://devcenter.heroku.com/articles/heroku-postgres-extensions-postgis-full-text-search#postgis my-site::DATABASE=> SELECT postgis_version(); postgis_version --------------------------------------- 2.3 USE_GEOS=1 USE_PROJ=1 USE_STATS=1 (1 row) Can anyone shine some light on what could be the issue, help my troubleshoot. Haven't I not configured the database on Heroku correctly? Thank you $ heroku run python manage.py migrate Running python manage.py migrate on ⬢ my-site... up, run.8591 (Free) Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 294, in run_from_argv self.execute(*args, **cmd_options) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 342, in execute self.check() File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 374, in check include_deployment_checks=include_deployment_checks, File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 62, in _run_checks issues.extend(super(Command, self)._run_checks(**kwargs)) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 361, in _run_checks return checks.run_checks(**kwargs) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/checks/urls.py", line 14, in check_url_config … -
How can I show in django list of records from db
Can anybody help me? I have a list of 60 records from django database in my html file. I want to show that list in table of 6 columns and 10 rows. In html file I used command {% for %} but the list is in one column. -
ImproperlyConfigured: Django issue with local_settings and settings
I'm trying to run a simple test for a django project and separate them in two files because it's a good practice, however, this always gives me an error ImproperlyConfigured("settings.DATABASES is improperly configured. " and I don't why I have this in my settings.py in the end try: from local_settings import * except: pass and only have this in my local_settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } and yes there are in the same directory. I am using python3, windows 10