Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django.urls.exceptions.NoReverseMatch on deleteview
I am deleting a post using generic DeleteView. On clicking the link for delete it returns django.urls.exceptions.NoReverseMatch: Reverse for 'postdelete' with no arguments not found. 1 pattern(s) tried: ['posts/(?P[0-9]+)/delete/$'] I tried placing the before and after /delete/ #urls.py path('posts/<int:id>/delete/',blogpostDelete.as_view(),name='postdelete'), #DeleteView class blogpostDelete(DeleteView): success_url='/posts/' template_name="blog/delete.html" def get(self,request,id) : Blogpost = get_object_or_404(blogpost,id=id) return self.render_to_response({'id':id}) #link in template <a href={% url "postdelete" id=id %}>Delete</a> #delete.html {% block content %} <form action={% url "postdelete" %} method="post"> {% csrf_token %} <p>Are you sure you want to delete "{{ id }}"?</p> <input type="submit" value="Confirm"> </form> {% endblock %} -
How to trigger session deletion automatically after it expires?
I need to delete expired sessions from database. Similar Stack Overflow threads seem to suggest introducing a scheduled task (cron, Celery etc.) to run a check on expired sessions and delete them. However, I want to avoid introducing heavy stack for such simple task and am looking for a "native" way to delete a session from a database AS SOON AS it expires. So I have a pre_delete signal set on Session model that triggers the deletion if model's instance is expired. But there is one step remaining: I need Django to run delete on the instance as soon as it expires. Ideally, I would need a method like request.session.on_expiry(some_function_that_deletes_a_session_from_db). Is there a way to do this? -
how to add custom user field in User of admin page of django?
Will anybody help me? I have tried so much. I have read documentation but not understanding how to add custom user field in User of admin page? Whenever I makemigrations, it gives me following error. Different pages #admin.py from django.contrib.auth.admin import UserAdmin admin.site.register(UserProfile, UserAdmin) #models.py from django.contrib.auth.models import AbstractUser class UserProfile(AbstractUser): Id_card_number = models.CharField(max_length=15) #forms.py class UserRegisterForm(UserCreationForm): email = forms.EmailField(required=True)._unique = True Id_card_number = forms.CharField(max_length=15, required=True)._unique = True class Meta: model = UserProfile fields = ['username','email','password1','password2','Id_card_number'] Error whenever I use AUTH_USER_MODEL = 'users.UserProfile' in settings.py ERRORS: auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'UserProfile.groups'. HINT: Add or change a related_name argument to the definition for 'User.groups' or 'UserProfile.groups'. auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'UserProfile.user_permissions'. HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'UserProfile.user_permissions'. users.UserProfile.groups: (fields.E304) Reverse accessor for 'UserProfile.groups' clashes with reverse accessor for 'User.groups'. HINT: Add or change a related_name argument to the definition for 'UserProfile.groups' or 'User.groups'. users.UserProfile.user_permissions: (fields.E304) Reverse accessor for 'UserProfile.user_permissions' clashes with reverse accessor for 'User.user_permissions'. HINT: Add or change a related_name argument to the definition for 'UserProfile.user_permissions' or 'User.user_permissions'. Error whenever I don't use AUTH_USER_MODEL = 'users.UserProfile' in settings.py … -
Is it safe to store OAuth credentials in request.session?
I need to store OAuth access token in between requests. I am currently doing something similar to this: def store_token(request): access_token = some_obtained_access token request.session['access_token'] = access token return HttpResponse('Token stored') Is it safe? If not, what other approach could I use to store the token in between requests? -
How to fix " 'user' is not a valid UUID."
I have created my own user model and there I have created a field named Unique_id and this is a uuid field and the primary_key=Trueand after creating a user I am getting this error ["'1' is not a valid UUID."] This is my custom user model class User(AbstractBaseUser): username = models.CharField(max_length=200, unique=True,) firstname = models.CharField(max_length=100) lastname = models.CharField(max_length=100) email = models.EmailField(unique=True) mobile_phone_number = models.CharField(max_length=20, unique=True) profile_photo = models.ImageField(default='media/default.png', upload_to = user_directory_path) unique_id = models.UUIDField(default=uuid.uuid4, editable=False, unique=True, primary_key = True) active = models.BooleanField(default=True) staff = models.BooleanField(default=False) admin = models.BooleanField(default=False) moderator = models.BooleanField(default=False) date_joined = models.DateTimeField(_('date joined'), default=timezone.now) USERNAME_FIELD = 'username' REQUIRED_FIELDS = ['firstname','lastname','email','mobile_phone_number'] objects = UserManager() def __str__(self): return self.username def has_perm(self, perm, obj=None): return True def has_module_perms(self, app_label): return True @property def is_staff(self): return self.staff @property def is_active(self): return self.active @property def is_admin(self): return self.admin @property def is_moderator(self): return self.moderator After creating a user I am getting this error. Exception Type: ValidationError Exception Value: ["'1' is not a valid UUID."] -
Apache + Django can not read css (403 error)
I want to publish a web app with Django + Apache + mod_wsgi. The app has been published but can not read static files. The version used is as follows. Windows10 Python==3.7.1 Django==2.2.3 Apache==2.4 We have confirmed that it works with Django's development server. I collected the files in one place using collectstatic. [httpd.conf] Alias /static/ C:/users/10001205180/Programs/katakan/deploy/ <Directory "C:/users/10001205180/Programs/katakan/deploy"> Require all granted </Directory> WSGIPythonPath C:/users/10001205180/programs/katakan SetHandler wsgi-script WSGIPythonPath C:/users/10001205180/Programs/katakan/myvenv/Lib/site-packages WSGIScriptAlias / C:/users/10001205180/programs/katakan/mysite/wsgi.py <Directory "C:/users/10001205180/programs/katakan"> <Files wsgi.py> Require all granted </Files> </Directory> [error.log] (Apache) [Mon Aug 05 18:31:05.015949 2019] [wsgi:error] [pid 3396:tid 1184] [client 10.5.150.3:58977] Options ExecCGI is off in this directory: C:/Users/10001205180/Programs/katakan/deploy/mainteboard/css/base.css, referer: http://10.5.150.3:8000/mainteboard/ [Mon Aug 05 18:31:05.028951 2019] [wsgi:error] [pid 3396:tid 1180] [client 10.5.150.3:58991] Options ExecCGI is off in this directory: C:/Users/10001205180/Programs/katakan/deploy/mainteboard/css/calendar.css, referer: http://10.5.150.3:8000/mainteboard/ [Mon Aug 05 18:31:05.028951 2019] [wsgi:error] [pid 3396:tid 1176] [client 10.5.150.3:58993] Options ExecCGI is off in this directory: C:/Users/10001205180/Programs/katakan/deploy/bootstrap_datepicker_plus/css/datepicker-widget.css, referer: http://10.5.150.3:8000/mainteboard/ [Mon Aug 05 18:31:05.038948 2019] [wsgi:error] [pid 3396:tid 1172] [client 10.5.150.3:58994] Options ExecCGI is off in this directory: C:/Users/10001205180/Programs/katakan/deploy/bootstrap_datepicker_plus/js/datepicker-widget.js, referer: http://10.5.150.3:8000/mainteboard/ [wsgi.py] import os from django.core.wsgi import get_wsgi_application import sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..' ) os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') application = get_wsgi_application() When opened in a browser, a 403 error occurs. I thought that there was … -
i want know how applicat css in my login.html
hello my friend i install bootstrap in my poject adn he works fine just i want to know how i can apllicate this bootstrap style with css and adapt it to my login.html thank you {% extends 'base.html' %} {% block content %} <div class="container"> <div class ="row text-center"> <div class="col-md-6 offset-md3"> <form action="" method="Post"> {% csrf_token %} <div class="form-group"> <label for="username">Nom d'Utilisateur</label> <input type="text" class="form-control" name="username" placeholder="Tapez le Nom d'Utilisateur"> </div> <div class="form-group"> <label for="password">Mot de Passe</label> <input type="password" class="form-control" name="password" placeholder="Mot de Passe"> </div> <button type="submit" class="btn btn-primary">Entrer</button> </form> </div> </div> </div> {% endblock %} -
Testing views with 'logged in user' without accessing database
I have written som arbitrary code to test a view-class with and without a logged in user. However, while doing that I have to create a user, which accessed the database. To follow good practice for TDD unittests I would try to avoid accessing the database, but I don't know how I've briefly tried to patch different modules, but I haven't figured out exactly how or what to patch This is the solution I'm using today: @pytest.mark.django_db class TestTreaterProfile: """ get with anonymous get with logged-in user """ [...] def test_get_with_logged_in_user(self): status_code = [200] view_class = ClientProfile client = Client() user = User.objects.create_user("user", "my@email.com", "password") client.force_login(user) # create request and retrieve response request = RequestFactory().get("/") request.user = user response = view_class.as_view()(request, *[], **{}) assert response.status_code in status_code, "Should have status_code 200 - OK" The code works, I would just like to modify it so that it don't have to access the database. Thanks in advance for your help! -
enabled download button if file is available with JavaScript
I'm trying to implement some logic for my UI. First the download button is in disabled state after an image uploaded. Once the Image is processed and it will generate an text file in a particular directory which will updated in database. Once the converted file available the download button automatically need to be enabled. The refresh should need to be done only for the button not the whole page. I have already tried setTimeout but the issue is entire page getting refreshed. Thanks in advance. My project is under development with Django framework. -
Is it possible to access Django application running on my local host to be accessible by another computer on other networks?
I am developing a web application on my local computer in Django. Now I want my webapp to be accessible to other computers on other networks. -
Django: dropdown selecting a model in a generic view
I have a generic Django generic DetailView and I'd like to be able to render a dropdown via a django.form. The options are a list of objects that belong to the user. I can do this for ALL objects with something like Model.objects.all() in the form, but how can I filter out the options that belong to the user without being able to access the request.user from the form? I've seen an example where the queryset can be injected into the form: form = MyForm() form['field'].queryset = Model.objects.filter(user=user) But there is no place to really do this in a django generic view (is there?) -
How to complete user (set password) registration with email in django-allauth?
I would like to register the user with some basic info (Name, Company...) and email. After the user submits the form i would like to send an email with a link that takes the user to a page to set his password. I have tried with a solution from this question: Django AllAuth - How to manually send a reset-password email?. The email was send and the link inside the email is working, but i get an AssertionError on my site. The error is in /allauth/account/utils.py inside the setup_user_email(request, user, addresses) function. The line: assert not EmailAddress.objects.filter(user=user).exists() What am i doing wrong here? My models.py: from django.contrib.auth.models import AbstractUser from django.db import models from allauth.account.views import PasswordResetView from django.conf import settings from django.dispatch import receiver from django.http import HttpRequest from django.middleware.csrf import get_token class Kompanija(models.Model): naziv = models.CharField(max_length=50) adresa = models.CharField(max_length=50, blank=True) def __str__(self): return self.naziv class Meta: verbose_name = "Kompanija" verbose_name_plural = "Kompanije" class CustomUser(AbstractUser): ime = models.CharField(max_length=30, default='') prezime = models.CharField(max_length=30, default='') kompanija = models.ForeignKey(Kompanija, on_delete=models.CASCADE, null=True, blank=True) is_premium = models.BooleanField('premium status', default=False) def __str__(self): return self.ime + " " + self.prezime @receiver(models.signals.post_save, sender=settings.AUTH_USER_MODEL) def send_reset_password_email(sender, instance, created, **kwargs): if created: request = HttpRequest() request.method = 'POST' if … -
NoReverseMatch at /^users/login/ (Reverse for 'index' not found. 'index' is not a valid view function or pattern name.)
I set up a user registtation and authorization system to allow people to register an account and log in and out. the first error is about TypeError: login() got an unexpected keyword argument 'template_name', I fixed it ,but the second problem arises.like this: NoReverseMatch at /^users/login/ Reverse for 'index' not found. 'index' is not a valid view function or pattern name. Request Method: GET Request URL: http://localhost:8000/%5Eusers/login/ Django Version: 2.2.3 Exception Type: NoReverseMatch Exception Value: Reverse for 'index' not found. 'index' is not a valid view function or pattern name. Exception Location: D:\learning-note\ll_env\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 668 Python Executable: D:\learning-note\ll_env\Scripts\python.exe Python Version: 3.7.3 Python Path: ['D:\\learning-note', Error during template rendering In template D:\learning-note\learning_logs\templates\learning_logs\base.html, error at line 2 Reverse for 'index' not found. 'index' is not a valid view function or pattern name. 1 <p> 2 <a href="{% url 'learning_logs:index' %}">Learning Log</a> - 3 <a href="{% url 'learning_logs:topics' %}">Topics</a> - 4 {% if user.is_authenticated %} 5 Hello, {{ user.username }}. 6 {% else %} 7 <a href="{% url 'users:login' %}">log in</a> 8 {% endif %} 9 </p> 10 11 12 learning_log/urls.py from django.contrib import admin from django.urls import path, include urlpatterns =[ path('admin/',admin.site.urls), path(r'^users/', include('users.urls', namespace='users')), path('', include('learning_logs.urls',namespace = 'learning_logs')), ] … -
Django Custom User authentication, lookup error User not registered
After running a migration I get the following error: LookupError: Model 'users.UserProfile' not registered. I am trying to create a customer User for Django-cms. It just does not want to do it. Full Traceback: Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "C:\Users\user\Envs\p37\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line utility.execute() File "C:\Users\user\Envs\p37\lib\site-packages\django\core\management\__init__.py", line 357, in execute django.setup() File "C:\Users\user\Envs\p37\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\user\Envs\p37\lib\site-packages\django\apps\registry.py", line 112, in populate app_config.import_models() File "C:\Users\user\Envs\p37\lib\site-packages\django\apps\config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "C:\Users\user\Envs\p37\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "C:\Users\user\Envs\p37\lib\site-packages\djangocms_text_ckeditor\models.py", line 10, in <module> from cms.models import CMSPlugin File "C:\Users\user\Envs\p37\lib\site-packages\cms\models\__init__.py", line 4, in <module> from .permissionmodels import * # nopyflakes File "C:\Users\user\Envs\p37\lib\site-packages\cms\models\permissionmodels.py", line 21, in <module> User = apps.get_registered_model(user_app_name, user_model_name) File "C:\Users\user\Envs\p37\lib\site-packages\django\apps\registry.py", line 270, in get_registered_model "Model '%s.%s' not registered." % (app_label, model_name)) LookupError: Model 'users.UserProfile' not registered. Models.py file: from django.db import models from django.contrib.auth.models import AbstractBaseUser from django.contrib.auth.models import PermissionsMixin from … -
Postgresql: could not connect to server
I'm use postgresql 9.6, Django 2.0, psycopg2==2.8.3 psycopg2.OperationalError: could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432? pg_hba.conf local all postgres peer # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all peer # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5 # Allow replication connections from localhost, by a user with the # replication privilege. #local replication postgres peer #host replication postgres 127.0.0.1/32 md5 #host replication postgres ::1/128 md5 host all all 0.0.0.0/0 md5 host all all ::/0 md5 status ● postgresql.service - PostgreSQL RDBMS Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled) Active: active (exited) since Mon 2019-08-05 11:52:49 EEST; 19min ago Process: 26617 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Main PID: 26617 (code=exited, status=0/SUCCESS) сер 05 11:52:49 lexvel-MS-7A72 systemd[1]: Starting PostgreSQL RDBMS... сер 05 11:52:49 lexvel-MS-7A72 systemd[1]: Started PostgreSQL RDBMS. settings DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'keyua_dev', 'USER': 'postgres', 'PASSWORD': '***', 'HOST': '127.0.0.1', 'PORT': '', } } -
Django Selected Radio button choice and dropdown
I have created radio button and dropdown menu populated from the static tuple from the Form. I would like to fetch the item what user selected on the same page below the submitting. FORM.py ## VIEW: Populate dropdown to select Data center def get_role_dc_data(request, *args, **kwargs): if request.method == 'POST': form = SelectionForm(request.POST or None) if form.is_valid(): form.save() return render(request, 'selectsite.html', {'form': form }) else: form = SelectionForm() return render(request, 'selectsite.html', {'form': form }) ## POPULATE: Data def gather_data(request, *args, **kwargs): selectedsite = '' roletype = '' if request.method == 'POST': form = SelectionForm(request.POST or None) if form.is_valid(): selectedsite = form.cleaned_data.get('location') roletype = form.cleaned_data.get('roletype') print (selectedsite) print (region) context_dict = { "selectedsite": selectedsite, "roletype": roletype } else: context_dict = {} return render(request, 'configure.html', context_dict) HTML: <form method="post" action=/configure/> {% csrf_token %} <table class="table"><tr><th> <label name="roletype" for="region" class="form-check-label"> Type: {% for choice in form.roletype %} <name="roletype"> {{ choice }} {% endfor %} </label></th><th> <select name="location"> <datalist id="location">Select an the site</option> {% for dc in form.location %} <option selected="selected" value="{{ dc }}"></option> {% endfor %}</datalist></select></th><th> <button align="right" class="button execute" name="submit" value="submit">GO TO</button> </th></tr></table></form> -
Add a virtual field to a django query
I want to add an extra field to a query set in Django. The field does not exist in the model but I want to add it to the query set. Basically I want to add an extra field called "upcoming" which should return "True" I already tried adding a @property method to my model class. This does not work because apparently django queries access the DB directly. models.py class upcomingActivity(models.Model): title = models.CharField (max_length=150) address = models.CharField (max_length=150) Views.py def get(self, request): query = upcomingActivity.objects.all() feature_collection = serialize('geojson', query , geometry_field='location', fields= ( 'upcoming','title','address','pk' ) ) -
Primary key validation after Django's sqlsequencereset [duplicate]
This question already has an answer here: IntegrityError duplicate key value violates unique constraint - django/postgres 9 answers I've migrated a DB from a Django App from SQLite to Postgres. When I enter new data on the admin view I get an error message that the primary key already exists. duplicate key value violates unique constraint I tried to resync the sequences in postgres using the following command, which generates the required SQL script. python manage.py sqlsequencereset app | python manage.py dbshell I still get the same error as before. How can I check whether the sequence was resynced correctly and the next id is set to MAX(id)+1 or so? -
While creating python file on IIS with django Error 500
When i try to create a python file (.py) in my django application i get an error 500. The File is created and the code isn't the problem. I can create a text file or any other format. It would need to be a python file cause i need it for further steps. I am using Windows 10 and run the django Application on IIS. Windows, IIS and Django are all uptodate. I already tried to add permission to the folder I will edit. I tested around with some other settings but havent figuerd out the problem yet. I think it should be something with permission of the iss or django. This is my error message: d:\django\virtualenv0\scripts\python.exe - The FastCGI process exited unexpectedly Most likely causes: IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred. IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly. IIS was not able to process configuration for the … -
How to get data by one query
I have two models question and option class Question(AbstractStatusModel): pass class Option(models.Model): option = models.TextField() is_correct = models.BooleanField(default=False) question = models.ForeignKey(Question, on_delete=models.CASCADE) How can I get a question with at least one correct option? -
Is there any support for constraint ON UPDATE in django
In the Django model on the foreign key attribute, I can add on_delete= models.CASCADE constraint but similarly I also need on_update RESTRICT. Is it possible? and is there any source of documentation if available -
How can i set a default value to an OneToOneField relationship which it's automatically generated?
I have two model classes they like below: from django.db import models from django.urls import reverse class Place(models.Model): address = models.CharField(max_length=80) class Author(Place): name = models.CharField(max_length=50) But when i want to execute makemigartions django shows me error below: You are trying to add a non-nullable field 'place_ptr' to author without a default; we can't do that (the database needs something to populate existing rows). Please select a fix: 1) Provide a one-off default now (will be set on all existing rows with a null value for this column) 2) Quit, and let me add a default in models.py Select an option: I have some data in Author table but i dont want to remove that data. how can i fix this issue? -
Django Messages are loading only after refresh after ajax call to delete a product from wishlist
In my django oscar project i have a wishlist templte which contains button to delete product from wishlist. The product is getting deleted after ajax call but the success message which is created in deleteview is loading after refreshing page. -
How to substitute a custom user in django?
Could anyone help me? I have been trying for so many days. I have read documentation but not understanding how to add custom user field in User of admin page? Whenever I makemigrations, it gives me following error. Different pages #admin.py from django.contrib.auth.admin import UserAdmin admin.site.register(UserProfile, UserAdmin) #models.py from django.contrib.auth.models import AbstractUser class UserProfile(AbstractUser): Id_card_number = models.CharField(max_length=15) #forms.py class UserRegisterForm(UserCreationForm): email = forms.EmailField(required=True)._unique = True Id_card_number = forms.CharField(max_length=15, required=True)._unique = True class Meta: model = UserProfile fields = ['username','email','password1','password2','Id_card_number'] Error whenever I use AUTH_USER_MODEL = 'users.UserProfile' in settings.py ERRORS: auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'UserProfile.groups'. HINT: Add or change a related_name argument to the definition for 'User.groups' or 'UserProfile.groups'. auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'UserProfile.user_permissions'. HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'UserProfile.user_permissions'. users.UserProfile.groups: (fields.E304) Reverse accessor for 'UserProfile.groups' clashes with reverse accessor for 'User.groups'. HINT: Add or change a related_name argument to the definition for 'UserProfile.groups' or 'User.groups'. users.UserProfile.user_permissions: (fields.E304) Reverse accessor for 'UserProfile.user_permissions' clashes with reverse accessor for 'User.user_permissions'. HINT: Add or change a related_name argument to the definition for 'UserProfile.user_permissions' or 'User.user_permissions'. Error whenever I don't use AUTH_USER_MODEL = … -
Django test chooses database randomly
I have multiple database settings (master/slave) as follow: DATABASES = { 'default': dj_database_url.parse('postgres://localhost:5432/master_db'), 'slave': dj_database_url.parse('postgres://localhost:5432/slave_db'), } Slave database is only used explicitly for some offline expensive query (with objects.using and is not used any of testcases. As noted in django docs 'default' database is used when there is no database specified explicitly. The problem is when I run python manage.py test --keepdb it sometimes run tests with slave database which raises error (because there is no table created in slave databse). The output of python manage.py test --keepdb when it uses slave: Using existing test database for alias 'slave'... Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) psycopg2.ProgrammingError: relation "categorization_category" does not exist LINE 1: ...rization_category"."last_modified_date" FROM "categoriz... The output of when it uses default: # some ..... and warnings showing tests are running Creating test database for alias 'default'... # some debug info in tests Destroying test database for alias 'default'... Ran 119 tests in 91.456s OK How can I force test to use only 'default' database as test database?