Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to use a FilterUserMixin to filter one field or the other in Django
I'm using FilterUserMixin for filtering data in a form. I have the model 'Game' which has attributes 'team1' and 'team2'. I want the filter to get all the games in the list where a certain team is either team1 or team2. My filter looks like this: class GamesFilter(FilterUserMixin): name = django_filters.CharFilter(method='filter_name', label='Team name') def filter_name(self,queryset,name,value): queryset = queryset.filter(team2=value) | queryset.filter(team1=value) return queryset class Meta: model = Game fields = ('team1','team2',) The filter does appear in the form, and it displays all teams registered (it's a ModelChoiceField, so a list, not a CharField to type in), and it correctly displays the games, but only those where the searched team is in the 'team1' field, not as 'team2'. Do you have any ideas?, I'm relatively new to this, and have tried a few unsuccesful things. -
how i retrieve a list of assets for each employee using django
i am trying to retrieve list of assets to each employee using django class Asset(models.Model): name = models.CharField(max_length=50) description = models.TextField() categories = models.ForeignKey(Category, on_delete=models.CASCADE, related_name='asset_categories') image = models.ImageField(upload_to='asset_images', null=True, blank=True) stock =models.IntegerField() employee= models.ForeignKey(Employee, on_delete=models.SET_NULL,null=True ,blank=True, related_name='assets') def __str__(self): return self.name here is view.py class EmployeeDataView(RetrieveAPIView): queryset = Employee.objects.all() serializer_class = EmployeeDataSerializer lookup_field = 'id' lookup_url_kwarg = 'employee_id' here is the Serializer.py class EmployeeDataSerializer(serializers.ModelSerializer): assets = serializers.SerializerMethodField() class Meta: model = Employee fields = ['id','user', 'assets',] def get_assets(self, obj): assets= Asset.objects.filter(employee=obj) # assets= obj.asset_set.all() return AssetsListSerializer(assets,many=True) here is url.py path('api/EmployeeData/<int:employee_id>/', EmployeeDataView.as_view(), name='Employee-data'), -
Is it possible to run an R script within Django in an AWS instance?
I'm writing a series of functions in R that will scrape data from the web, save it locally, analyze it, and produce some sort of output (text & graphs). Is it possible to spin up an AWS instance (for example EC2), with Django underneath, to create a website, then upload the R scripts to Django and have certain webpages automatically upload with the new R analysis daily? Is there a better option? I apologize, I'm not very familiar with Django or EC2, having only used them once in the past in a non-professional environment. -
Cannot import name 'urlresolvers' from 'django.core'
I am encountering this the error message cannot import name 'urlresolvers' from 'django.core' when trying to run python manage.py runserver. This is the full traceback I am getting Watching for file changes with StatReloader Exception in thread django-main-thread: Traceback (most recent call last): File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner self.run() File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", li ne 54, in wrapper fn(*args, **kwargs) File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands \runserver.py", line 109, in inner_run autoreload.raise_last_exception() File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", li ne 77, in raise_last_exception raise _exception[1] File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__ .py", line 337, in execute autoreload.check_errors(django.setup)() File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", li ne 54, in wrapper fn(*args, **kwargs) File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py", line 24, i n setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 114, in populate app_config.import_models() File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line 21 1, in import_models self.models_module = import_module(models_module_name) File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_m odule 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\AppData\Local\Programs\Python\Python37\lib\site-packages\allauth\account\models.py", lin e 17, in <module> from .utils import user_email File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\allauth\account\utils.py", line 30, in <module> from ..utils import (import_callable, … -
Send message to other users / groups with django channels
I'm trying to send notifications to all other connected users other than myself (or the connected user). I have three separate user accounts and I'm looking to send different messages to each user depending on the account type. 'Account type 1', 'Type 2' and none authorized user'. All users are on separate domains and connect to the web socket via a different route. I want to be able to let each user know when the other has joined the connection/page. However, it's currently displaying the message for the user in which has connected. e.g. When I access the page as 'Account 1', I get 'Account 1 has joined the group'. However, I don't want to see when the other connected users have joined. I could possibly be overlooking something simple here, so reaching out for some advice. If I try and create a group based on the user ID. I can then only see the messages being sent if the account type I'm accessing the page on. I have a 'booking' object which I'm using the ID to create the room. I'm then adding the users to the group once connected and sending a message to the group. Displaying the … -
How to validate objects from reverse side of foreign key
I have two objects that are connected together by a ForeignKey. class Question(models.Model): text = models.Charfield() class AnswerOption(models.Model): text = models.Charfield() question = models.ForeignKey(Question, on_delete=models.CASCADE, related_name="options") When Question is created in the admin interface I'd like to perform some validation on the Question and associated AnswerOptions. I've added a clean method to Question but the options property is empty. What is the correct way to validate Question? -
Regex path in Django
I want to create data/?Status=success&ExternalId= this kind of path. and status is dynamic. But i tried ``` I tried '^data/(?P<username>\w+)/$' and data/<str> ``` but these are wrong I know. any suggestion -
What's the best approach for this database models structure?
I'm developing a Property Management System with Django, right now I'm working on an app named by "Property Check", basically the purpose of it is to provide a form with a list of tasks like "Diswasher: clean & empty?", those tasks need to be checked at a property by a staff member. The main idea is to allow admin to create Tasks and their Categories on the admin side. Example: Task - Dishwater: clean & empty belongs to Category - Kitchen. Each Property Check belongs to a property, it has the list of tasks and those tasks have different status, like "Checked" or "Needs attention". So far this is what I've created: models.py class Task(models.Model): name = models.CharField(db_column='SafetyTaskName', max_length=100, blank=False, null=False) category = models.ForeignKey(Categories, db_column='category') task_check = models.ForeignKey(TaskCheck) class Categories(models.Model): name = models.CharField(db_column='Categories', max_length=40, null=False, blank=False) class TaskCheck(models.Model): status = models.CharField(db_column='Status', choices=STATUS_CHOICES, default='nd') image = models.ImageField(upload_to='property_check',null=True) notes = models.CharField(db_column='Notes', max_length=500, blank=True, null=True) # Field name made lowercase. class Propertycheck(models.Model): property = models.ForeignKey(Property, models.DO_NOTHING, db_column='ID_Property') # Field name made lowercase. task = models.CharField(TaskCheck) name = models.CharField(db_column='Name', max_length=150) date = models.DateField(db_column='Date', default=timezone.now) # Field name made lowercase. next_visit = models.DateField(db_column='Next Visit') staff = models.ForeignKey(User, db_column='Staff', max_length=25) notes = models.CharField(db_column='Notes', max_length=500, blank=True, null=True) … -
How do I paginate an API view in DRF
from django.shortcuts import render from .serializers import ApartmentSerializer,UserSerializer from .models import Apartment,User from rest_framework.views import APIView from rest_framework.response import Response from rest_framework import status, viewsets # Create your views here. class ApartmentList(APIView): def get(self,request): pagination_class = BasicPagination queryset = Apartment.objects.all() serializer = ApartmentSerializer(queryset,many=True) return Response(serializer.data) def post(self): pass class UserList(APIView): def get(self,request): queryset = User.objects.all() serializer = UserSerializer(queryset,many=True) return Response(serializer.data) def post(self): pass -
How can I gather all objects, from all models, within one class based view in django 2.2
A friend of mine is trying to gather all of the data from each of his models within one view, to display on one tamplate, with the 'slug' as the URL. He currently has a class based view that looks like this: from itertools import chain class ProductDetailView(DetailView): queryset1 = BooksProduct.objects.all() queryset2 = ClothingProduct.objects.all() queryset3 = FurnitureProduct.objects.all() queryset4 = DecoratingProduct.objects.all() queryset = chain(queryset1, queryset2, queryset3, queryset4) template_name = 'products/detail.html' The URL looks like this: urlpatterns =[ path('product-detail/<slug>/', ProductDetailView.as_view(), name='product-detail'), ] The four different models all look very similar to this: class BookProduct(models.Model): slug = models.SlugField(max_length=40) image = models.ImageField(upload_to='media') title = models.CharField(max_length=150) description = models.TextField() short_description = models.CharField(max_length=300) price = models.DecimalField(max_digits=5, decimal_places=2) stock_quantity = models.PositiveIntegerField() in_stock = models.BooleanField(default=True) main_category = models.CharField(choices=PRODUCT_CATEGORY_CHOICES, max_length=2, default='FW') brand = models.CharField(choices=TOY_BRAND_CHOICES, max_length=2, default='NB') on_sale = models.BooleanField(default=False) date_added = models.DateTimeField(auto_now_add=True, blank=True) def __str__(self): return self.title class Meta: ordering = ['-date_added'] def get_absolute_url(self): return reverse("products:product-detail", kwargs={ 'slug': self.slug }) At the moment, clicking on an individual product to get the product-detail.html view results in this error: 'itertools.chain' object has no attribute 'all' How is he able to accumulate all of the products from each model into one view? Kind regards -
Django: null value in column "email" violates not-null constraint
models.py class Employee(models.Model): name = models.Charfield(max_length=50) contact = models.BigIntegerField() email = models.EmailField(max_length=40, null=False) password = models.TextField(max_length=30) Form.py class CreateEmployee(forms.Form): name = forms.CharField(label="Enter Your Name", max_length=30, required=True) contact = forms.IntegerField(required=True) Email = forms.EmailField(max_length=40, widget=forms.EmailInput(), required=True) password = forms.CharField(required=True, widget=forms.PasswordInput()) View class Create_Employee(TemplateView): template_name = 'employee.html' def get(self, request, *args, **kwargs): form = CreateEmployee() return render(request, self.template_name, {'form': form}) def post(self, request): try: data = request.POST.get Employee(name=data('name'), contact=data('contact'), email=data('email'), password=data('password') ).save() return HttpResponse("Employee has been added successfully", 200) except Exception as e: return HttpResponse("Failed: {}".format(e), 500) After submit the i got this issue Failed: null value in column "email" violates not-null constraint DETAIL: Failing row contains (20, usman, 31902355, null, 123456s). -
Why is my clean() in a datetime field throwing a TypeError? [duplicate]
This question already has an answer here: Can't compare naive and aware datetime.now() <= challenge.datetime_end 6 answers I have a form that takes in modified timestamps, however these should never be in the future. I created the function below to raise an error if someone tries to submit a time in the future, however, I keep getting this error TypeError at /operations/enter-exit-area/ can't compare offset-naive and offset-aware datetimes Request Method: POST Request URL: http://localhost:8000/operations/enter-exit-area/ Django Version: 2.1.5 Exception Type: TypeError Exception Value: can't compare offset-naive and offset-aware datetimes Exception Location: C:\Users\mkusneco\apps.rsrgroup.com\apps\operations\forms.py in clean_modified_in, line 48 def clean_modified_in(self): mod_in = self.cleaned_data.get('modified_in') if mod_in > datetime.datetime.now(): raise forms.ValidationError("The modified time cannot be in the future") return mod_in -
How can I achieve database sharding for my MYSQL database with Django
I am trying to understand the concept of system design and trying to practically implement it. One thing that struck my mind is how exactly do I achieve sharding of my databases in Django. Here is what I mean : Suppose I have multiple machines in my distributed system, all of which were previously using a centralised database to read/write data which was fine. I only had to specify it in my setting.py file in django. Now lets say, I want to implement database sharding for my MYSQL database and shard the servers based on the username keys. Now suppose when a request comes in how exactly will Django search I mean how do I specify it where my data is stored. Is there any way to tell django that my database is sharded. And moreover suppose a request want to view the contents which is available in multiple databases how exactly will it gather the data from all the database servers . Since all my database servers now will be having different address so how do I specify in django that how it has to configure these things. Or is there already a package in dango-python that lets me … -
Error: unsupported operand type(s) for +: 'int' and 'str'
Am new to django and am trying to get all the sum of all Gross_amount, Withholding_tax,Net_amount for each month a yr and i keep getting this error "TypeError: unsupported operand type(s) for +: 'int' and 'str'" below is my code: class Dashboard(ListView): class Dashboard(ListView): template_name = 'pv/dashboard.html' table =Pv.objects.annotate(month = TruncMonth('Date_recieved')) def get_context_data(self, **kwargs): today = datetime.now() context = super(Dashboard, self).get_context_data(**kwargs) context['table_pv'] = self.table.values('month').annotate(G=sum('Gross_amount'), T=sum(int('Withholding_tax')), N=sum(int('Net_amount'))).values('month','G','T').filter(Date_recieved__year=today.year).order_by() -
How to create a CustomUser for authentication from external Database in Django?
I created a django CustomUser model with a UserManager, it is working just fine but i didn't find a way to use this model with a MyQSL secondary database (not default one) which already contains some data. Setting file : DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'default', 'HOST': '', 'USER': '', 'PASSWORD': '', 'PORT': '', }, 'secondary': { 'NAME': 'secondary', 'ENGINE': 'django.db.backends.mysql', 'HOST': '', 'USER': '', 'PASSWORD': '', }, models : class CustomUserManager(BaseUserManager): def create_user(self, username, password=None): user_obj = self.model( username=username ) user_obj.set_password(password) user_obj.save(using=self._db) return user_obj def create_superuser(self, username, password): user_obj = self.create_user( username=username, password=password, ) user_obj.save(using=self._db) return user_obj class CustomUser(AbstractBaseUser): username = models.CharField(max_length=50, blank=False, unique=True) email = models.CharField(null=True, max_length=200, blank=False) first_name = models.CharField(null=True, max_length=200, blank=False, db_column='firstName') last_name = models.CharField(null=True, max_length=200, blank=False, db_column='lastName') last_login = timezone.now() USERNAME_FIELD = 'username' objects = CustomUserManager() class Meta: db_table = 'secondary' I can get the data from views just like this queryset = CustomUser.objects.using('secondary_database') But this doesn't help in authentication. How can i do please ? or at least a track. Thank you -
Django requests sometimes doesn't contain sessions over SSL
I'm facing something weird over my Django web app, I'm using sessions over the database to keep track of users sessions, but seems like over SSL these sessions doesn't stick around, I don't have pretty much clues why, but I have evidence on how it happens. My main problem is, that I have a view that if you are logged in it redirects you to the index, and in the index, if you are not logged in, then in redirects you to the login screen, so what happens here is that after login, the server will redirect me to the index page, but the index will get "None" checking over the session for the logged in parameter, and then, on the login form it check again the session and it actually gets that the user in logged in, so I enter in a infinite redirect loop, and after a while chrome says that the page redirect too much times. This is my settings.py """ Django settings for rienpaAdmin project. Generated by 'django-admin startproject' using Django 2.2.6. For more information on this file, see https://docs.djangoproject.com/en/2.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.2/ref/settings/ """ import os # Build … -
How can I get tox and poetry to work together to support testing multiple versions of a Python dependency?
I am switching a project that currently uses pipenv to poetry as a test to see what the differences are. The project is a simple, redistributable, Django app. It supports Python 3.6-8, and Django 2.2 and 3.0. I have a tox.ini file that covers all combinations of Python and Django thus: [tox] envlist = py{36,37,38}-django{22,30} [testenv] whitelist_externals = poetry skip_install = true deps = django22: Django==2.2 django30: Django==3.0 commands = poetry install -vvv poetry run pytest --cov=poetry_template tests/ poetry run coverage report -m The problem that I am having (which does not exist in the pipenv world) is that the poetry install statement will always overwrite whatever is in the deps section with whatever is in the poetry.lock file (which will be auto-generated if it does not exist). This means that the test matrix will never test against Django 2.2 - as each tox virtualenv gets Django 3.0 installed by default. I don't understand how this is supposed to work - should installing dependencies using poetry respect the existing environment into which it is being installed, or not? So - my question is - how do I set up a multi-version tox (or travis) test matrix, with poetry as the … -
Application labels aren't unique, duplicates: account
I created a 'account' app in my project and i add to installed app and this code; INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sites', 'account', 'allauth', 'allauth.account', 'allauth.socialaccount', ] And, i run this project (python manage.py runserver), i have one problem; django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: account I not have seen before this problem and i dont have any idea. -
Is there a generic way to get all existing values of fields from django endpoint?
I am trying to find a generic way to create a new endpoint from an original one. The new one should have all fields of model from the original one with lists of all possible values that exists in the original one's fields. for example- an original endpoint can be: "results": [ { "id": 3419, "scan_res": 'a', }, { "id": 3422, "scan_res": 'b', }, ] and the new one should be: "id": [ 3419, 3422 ], "scan_res": [ 'a', 'b' ] -
How to I disable all Django logging?
I want to run a Django shell (python manage.py shell) and not log any messages from it, particularly any typos I may eventually do. I have handlers setup to file output, bug trackers, etc. I want to suppress all loggers. How do I disable all logging from within a Django context? -
Django Rest Framework mock serializer create
I'm trying to test the atomicity of my viewset, by mocking a nested serializer so it fails on create. However, my current approach is causing the test to pass (and everything to be created normally): test.py: def test_atomicity(admin_user, payload, mocker): mocked_method = mocker.patch.object(serializers.ChildSerializer, 'create') mocked_method.raiseError.side_effect = Mock(side_effect=Exception('Test')) view = views.ParentViewSet.as_view({'post': 'create'}) request = factory.post('/', payload, format='json') force_authenticate(request, user=admin_user) response = view(request) assert response.status_code == status.HTTP_201_CREATED viewsets.py: class ParentViewSet(viewsets.ModelViewSet, AtomicMixin): queryset = models.Parent.objects.all().prefetch_related( 'child', ) serializer_class = serializers.ParentSerializer class ChildViewSet(viewsets.ModelViewSet, AtomicMixin): queryset = models.Child.objects.all() serializer_class = serializers.ChildSerializer serializers.py: class ChildSerializer(WritableNestedModelSerializer): class Meta: model = models.Child fields = ['id', 'claimed'] class ParentSerializer(WritableNestedModelSerializer): multipliers = ChildSerializer(many=True) class Meta: model = models.Parent fields = [ 'id', 'name', 'children', ] Does anyone have any experience with mocking the serializers? -
If i don't use SessionAuthentication in restframe-work, how to add CSRF authentication to all view methods of restframe?
The csrftoken is not automatically added to the APIView of the restframe work. It is used in SessionAuthentication by default. But ssionAuthentication is not safe, so I use the TokenAuthentication that I should write. Then how should I add csrf authentication to the APIView's POST method of the restframe work I add {% csrf_token%} in html or {"X-CSRFToken": '{{csrf_token}}'} But I found no trace of csrftoken in the request cookie and POST data, and the header. Does the default django csrf middleware not work? Should I write the middleware myself. f I use View,The following are the received request.COOKIES, request.POST, request.META.get ("HTTP_X_CSRFTOKEN") {} <QueryDict: {'username': ['xx'], 'password': ['123'], 'remember': ['false']}> None f I use APIView, {'csrftoken': 'syyAdWYJMk1xVJ7OS02jJU0S4J345YxlvbBnxPPXGz3Iw7wU2laqd7xgDla0xl8e'} <QueryDict: {'username': ['xx'], 'password': ['123'], 'remember': ['false']}> GmwhLBtnLbKjzUwSUtaGHpMfe9U0LWoEJZz45ukBFqMuaiVY4OiNbCjDNL1WdjZx why? -
How to display the logs of the appspec file on jenkins console log?
I have a containerized(Docker) Django-python application deployed on AWS server to which I have configured cloudwatch. As we know the project kick-off starts from the appspec file. The appspec contains of the docker build, docker run commands The appspec file logs can be monitored from the codedeploy agent by ssh in /opt/code-deploy/.. and also cloudwatch. I need: 1) To display that deployment ID specific logs in jenkins console log. 2) If the deployment doesn't show up any error the build should pass. 3) If the deployment shows any error in the ssh logs while creating the image through the dockerfile the build should fail Pasting my appspec file: version: 0.0 os: linux files: - source: . destination: /tmp hooks: BeforeInstall: - location: install/aws/instance_clean_up timeout: 60 runas: root ApplicationStart: - location: install/aws/docker_cleanup timeout: 60 runas: root - location: install/aws/docker_build timeout: 600 runas: root -
how to retrieve list of model from another model has ForeignKey relationship
I am A junior dev tring to build an app that save an asset to each employee employee can has many assets employ can see list of his asset only i am using django python """ class Category(models.Model): name = models.CharField(max_length=50) def __str__(self): return self.name class Asset(models.Model): name = models.CharField(max_length=50) # added_by = models.ForeignKey(User, on_delete=models.CASCADE, related_name='asset_added_by') description = models.TextField() categories = models.ForeignKey(Category, on_delete=models.CASCADE, related_name='asset_categories') image = models.ImageField(upload_to='asset_images', null=True, blank=True) stock =models.IntegerField() def __str__(self): return self.name class Department(models.Model): name = models.CharField(max_length=50) number_of_employees = models.IntegerField() def __str__(self): return self.name class Employee(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE,) department = models.ForeignKey(Department, on_delete=models.CASCADE,) image = models.ImageField(upload_to='employee_image', null=True, blank=True) def __str__(self): return self.user.username class Registration(models.Model): employees = models.ForeignKey(Employee, on_delete=models.CASCADE,) assets = models.ForeignKey(Asset, on_delete=models.CASCADE,) date_from = models.DateField() date_to = models.DateField() """ i am confusing with relationships is it correct ? and how can i get list of asset for each employee -
Can't connect to postgres to django using docker-compose
I use docker-compose to run postgres server and cant connect to it with Django but i can connect using adminer launched in same docker-compose stack error Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/home/puretilt/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/home/puretilt/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/puretilt/.local/lib/python3.6/site-packages/django/core/management/base.py", line 328, in run_from_argv self.execute(*args, **cmd_options) File "/home/puretilt/.local/lib/python3.6/site-packages/django/core/management/base.py", line 369, in execute output = self.handle(*args, **options) File "/home/puretilt/.local/lib/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped res = handle_func(*args, **kwargs) File "/home/puretilt/.local/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 86, in handle executor = MigrationExecutor(connection, self.migration_progress_callback) File "/home/puretilt/.local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__ self.loader = MigrationLoader(self.connection) File "/home/puretilt/.local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__ self.build_graph() File "/home/puretilt/.local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 212, in build_graph self.applied_migrations = recorder.applied_migrations() File "/home/puretilt/.local/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 76, in applied_migrations if self.has_table(): File "/home/puretilt/.local/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 56, in has_table return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()) File "/home/puretilt/.local/lib/python3.6/site-packages/django/utils/asyncio.py", line 24, in inner return func(*args, **kwargs) File "/home/puretilt/.local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 260, in cursor return self._cursor() File "/home/puretilt/.local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 236, in _cursor self.ensure_connection() File "/home/puretilt/.local/lib/python3.6/site-packages/django/utils/asyncio.py", line 24, in inner return func(*args, **kwargs) File "/home/puretilt/.local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection self.connect() File "/home/puretilt/.local/lib/python3.6/site-packages/django/db/utils.py", line 90, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/home/puretilt/.local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection self.connect() File "/home/puretilt/.local/lib/python3.6/site-packages/django/utils/asyncio.py", line 24, in inner return func(*args, **kwargs) File …