django-settings

Override test settings from a file

Override test settings from a file Question: For context, when one wants to change settings in a test (yes, it’s ok to change it there), we can use override_settings() or modify_settings() (as observed here). That works when running the tests in parallel too. Generally speaking, I do something like this from django.test import TestCase, override_settings …

Total answers: 1

Serving static files after deployment with django 2.2

Serving static files after deployment with django 2.2 Question: I deployed my site at the level of my host, but the imgaes are not displayed. I did python manage.py collectstatic and it copied the files to my STATIC_ROOT myprojet/settings.py STATICFILES_DIRS = [ os.path.join(BASE_DIR,’static’) ] STATIC_URL = ‘/static/’ STATIC_ROOT=’/home/www/mySite.com/static/’ index.html {% extends ‘layout/base.html’ %} {% load …

Total answers: 1

I'm doing the migration, but the table is not created in the database

I'm doing the migration, but the table is not created in the database Question: When I do the migration, I get the following message in the terminal: Migrations for ‘bookList’: bookList/migrations/0001_initial.py: Create model bookList And then I run the migrate command: Operations to perform: Apply all migrations: admin, auth, bookList, contenttypes, sessions When I look …

Total answers: 2

AttributeError: 'Settings' object has no attribute <class that I defined inside settings.py> when settings imported from conf

AttributeError: 'Settings' object has no attribute <class that I defined inside settings.py> when settings imported from conf Question: I’ve added enum in the settings.py file class Syncs(Enum): A = ‘a’ B = ‘b’ when I try to use them in an app by importing from django.conf import settings, it raises: AttributeError: ‘Settings’ object has no …

Total answers: 1

admin.site.register doesn't add my app in admin Django

admin.site.register doesn't add my app in admin Django Question: I’m trying to see the models in the admin. I’ve tried everything but nothing seems to work, could you help me? Note: I’ve also tried with admin.autodiscover() but it didn’t work. Also, I have installed the apps correctly and made the migrations without problems. Here’s what …

Total answers: 2

WSGI application 'mysite.wsgi.application' could not be loaded; Error importing module

WSGI application 'mysite.wsgi.application' could not be loaded; Error importing module Question: I use django 3.1.1 and Python 3.8.5. I want to create simple blog. I use some old code in which programmer used django 1.11 probably, so I change many things, but now I’m stuck I get error raise ImproperlyConfigured( django.core.exceptions.ImproperlyConfigured: WSGI application ‘mysite.wsgi.application’ could …

Total answers: 2

SMTPAuthenticationError at /password-reset/

SMTPAuthenticationError at /password-reset/ Question: I am new in Django. I am trying to add a feature in my project that enables user to reset his password through given email. These configurations are in development and not production. This is my configuration in settings.py EMAIL_BACKEND = ‘django.core.mail.backends.smtp.EmailBackend’ EMAIL_HOST = ‘smtp.gmail.com’ EMAIL_PORT = 587 EMAIL_USE_TLS = True …

Total answers: 3

Django TemplateDoesNotExist at / debug_toolbar/base.html after deployiing to EC2

Django TemplateDoesNotExist at / debug_toolbar/base.html after deployiing to EC2 Question: I am trying to deploy a Django app on EC2 Instance. I had put my EC2 instance in the Allowed_Host correctly. but it kept giving me a Disallowed_Host error. I have been trying to fix that but Now I get the. Django TemplateDoesNotExist at / …

Total answers: 3

ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured

ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured Question: I’m trying to make MongoDB and Django get on with each other the way I want them to. That’s the error I’m getting when trying to import viewsets from rest_framework_mongoengine. The whole error looks like this: ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. …

Total answers: 7