Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
DRF end-point posting error for nested serialization
Get method working in browse-able api end-point but when i try to post using my end-point through browser, it fires me this error: (My serializers are nested) This is my serializers.py and it is Nested serilizers from rest_framework import serializers from . models import Author, Article, Category, Organization class OrganizationSerializer(serializers.ModelSerializer): class Meta: model = Organization fields = '__all__' class AuthorSerializer(serializers.ModelSerializer): organization = OrganizationSerializer() class Meta: model = Author fields = '__all__' class CategorySerializer(serializers.ModelSerializer): class Meta: model = Category fields = '__all__' class ArticleSerializer(serializers.ModelSerializer): author = AuthorSerializer() category = CategorySerializer() class Meta: model = Article fields = '__all__' and this is my models.py from django.db import models import uuid class Organization(models.Model): organization_name = models.CharField(max_length=50) contact = models.CharField(max_length=12, unique=True) def __str__(self): return self.organization_name class Author(models.Model): name = models.CharField(max_length=40) detail = models.TextField() organization = models.ForeignKey(Organization, on_delete=models.DO_NOTHING) def __str__(self): return self.name class Category(models.Model): name = models.CharField(max_length=100) def __str__(self): return self.name class Article(models.Model): alias = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) author = models.ForeignKey(Author, on_delete=models.CASCADE, related_name='author') title = models.CharField(max_length=200) body = models.TextField() category = models.ForeignKey(Category, on_delete=models.CASCADE) and this is my views.py ( I am using APIView, not VIewset) class ArticleDeleteUpdate(DestroyAPIView, UpdateAPIView): queryset = Article.objects.all() serializer_class = ArticleSerializer lookup_field = 'alias' and this is my urls.py path('api/v1/article', views.ArticleListCreateGet.as_view(), name='article2'), … -
Django save() method not saving to DB
What am I doing wrong? I have two tables, User and Entrepreneur. Objects are not saving in the Entrepreneur table. I even used the shell! I've deleted the DB and migration files and the error stays the same. I know similar questions have been asked but I found none fitting my situation. MY MODELS: class EntrepreneurProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) mobile = models.CharField(max_length=100, blank=True, null=True) location = CountryField(blank=True, null=True) email_notif_on = models.BooleanField(default=False) photo = models.ImageField(upload_to='photo/%Y/%m/%d', blank=True, null=True) skills = TaggableManager(blank=True) date_joined = models.DateField(auto_now_add=True) accomplishnment = models.ForeignKey(Accomplishment, on_delete=models.CASCADE, null=True, blank=True) portfolio = models.ManyToManyField(Portfolio, blank=True) date_of_birth = models.DateField(blank=True, null=True) url = models.SlugField(unique=True) def __str__(self): return f'{self.user}' def save(self, *args, **kwargs): if self.url: self.url = slugify(f'{self.user.first_name} {self.user.last_name} {str(uuid.uuid4()[:7])}') MY VIEWS: def signup(request): if request.method == 'POST': user_form = UserCreateForm(request.POST) if user_form.is_valid(): user = user_form.save(commit=False) user.set_password(user.password) user.save() entrep = EntrepreneurProfile.objects.create(user=user) entrep.save() print(entrep.id) return redirect('users:login') else: user_form = UserCreateForm() data = {'user_form': user_form} return render(request, 'users/signup.html', data) -
How to encrypt and store data into a database using django and pycrpytodome?
I created a database using django and created a html form to store the data into the database. Now, I want to encrypt using pycryptodome and store the ciphertext into the database. And I want the decrypted plaintext when I display the data from the database. I have tries some basic encryption examples and algorithms from pycrytodome documentation. Now, I want to encrypt and store the ciphertext into the database. #This is the function where I want to encrypt the data in the get_password variable and store it def add(request): get_name = request.POST["add_name"] get_password = request.POST["add_password"] print(type(get_name),type(get_password)) s = Student(student_name=get_name,student_password=get_password) context = { "astudent":s } s.save() return render(request,"sms_2/add.html",context) #This is the example I have tried from pycryptodome documentation. from Crypto.Cipher import AES key=b"Sixteen byte key" cipher=AES.new(key,AES.MODE_EAX) data=b"This is a secret@@!!" nonce = cipher.nonce ciphertext, tag = cipher.encrypt_and_digest(data) print(nonce) print(key) print(cipher) print(ciphertext) print(tag) cipher1 = AES.new(key, AES.MODE_EAX, nonce=nonce) plaintext = cipher1.decrypt(ciphertext) try: cipher1.verify(tag) print("The message is authentic:", plaintext) except ValueError: print("Key incorrect or message corrupted") I want to encrypt the plaintext I enter into the database using the html form and I want to ciphertext to be stored into the database. I want help with that. -
django-storage file upload SuspiciousOperation and the joined path is located outside of the base path component error
I am using the latest version of django and django-storage. I am trying to save an uploaded image and a locally generated resized image. When I tried to save a image I got this errors: Traceback: File "/home/..proj/.env/lib/python3.6/site-packages/storages/backends/s3boto3.py" in _normalize_name 431. return safe_join(self.location, name) File "/home/prism/Desktop/code/viper/.env/lib/python3.6/site-packages/storages/utils.py" in safe_join 75. raise ValueError('the joined path is located outside of the base path' During handling of the above exception (the joined path is located outside of the base path component), another exception occurred: File "/home/..proj/.env/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner 34. response = get_response(request) File "/home/..proj/.env/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response 115. response = self.process_exception_by_middleware(e, request) File "/home/..proj/.env/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response 113. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/..proj/.env/lib/python3.6/site-packages/django/contrib/auth/decorators.py" in _wrapped_view 21. return view_func(request, *args, **kwargs) File "/home/..proj/admin/views.py" in product_update 578. image_model.image_thumbnail_index.save(a.name, File(a)) File "/home/..proj/.env/lib/python3.6/site-packages/django/db/models/fields/files.py" in save 87. self.name = self.storage.save(name, content, max_length=self.field.max_length) File "/home/..proj/.env/lib/python3.6/site-packages/django/core/files/storage.py" in save 51. name = self.get_available_name(name, max_length=max_length) File "/home/..proj/.env/lib/python3.6/site-packages/storages/backends/s3boto3.py" in get_available_name 633. return super(S3Boto3Storage, self).get_available_name(name, max_length) File "/home/..proj/.env/lib/python3.6/site-packages/django/core/files/storage.py" in get_available_name 75. while self.exists(name) or (max_length and len(name) > max_length): File "/home/..proj/.env/lib/python3.6/site-packages/storages/backends/s3boto3.py" in exists 528. name = self._normalize_name(self._clean_name(name)) File "/home/..proj/.env/lib/python3.6/site-packages/storages/backends/s3boto3.py" in _normalize_name 434. name) Exception Type: SuspiciousOperation at /admin/product/update/7/ Exception Value: Attempted access to '/home/..proj/convert/mqedpqL4tepvF4bT7wySMm/jo_308x412.webp' denied. Image model: class ProductImage(models.Model): image = models.ImageField(storage=ProductMediaStorage()) image_thumbnail_index = models.ImageField(storage=ProductMediaStorage()) … -
Anyone is able to delete or update other's post through url
Hy, I am developing a Django Blog application. In this application, I have a PostEdit view to edit the post, Delete post view to delete the post. These operations can only be performed by the user who has created that post. I used Delete view as a functional view and edit view as CBV. Now what is happening is that any user is able to delete or edit the others post through URL. In my delete post view since it is a functional based view, I have used if condition to prevent another user to prevent deleting someone else post. But since for post edit, I am using CBV, I am not able to find a way to prevent a user from editing someone else's post. So how can I prevent doing another user to edit someone else post? class PostUpdateView(LoginRequiredMixin ,UpdateView): model = Post template_name = 'blog/post_form.html' form_class = PostForm def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['title'] = 'Update' return context def form_valid(self, form): form.instance.author = self.request.user form.save() return super().form_valid(form) @login_required def post_delete(request, slug): post = get_object_or_404(Post, slug=slug) if (request.user == post.author): post.delete() return redirect('blog:post_list') else: return redirect('blog:post_detail', slug=slug) -
ValueError: server must be a Flask app or a boolean
I'm trying to work through the simplest dashboard example in the django-plotly-dash documentation, but I'm consistently getting the ValueError above. For the code below, assume the django project name is django_project and the django app name is dashboard. My ROOT_URLCONF at django_project/urls.py has the following relevant code: import dashboard.dash_app from dashboard.views import test_view urlpatterns = [ ... path('dashboard/', test_view, name='test_view'), path('django_plotly_dash/', include('django_plotly_dash.urls')), ] My dashboard app view, located at dashboard/views.py is as follows: from django.shortcuts import render def test_view(request): return render(request, 'dashboard/main.html') The main.html template is as follows: from django.shortcuts import render def test_view(request): return render(request, 'dashboard/main.html') {% load plotly_dash %} {% plotly_app name="SimpleExample" %} Finally, the DjangoDash app instance is created in a file called dashboard/dash_app.py. As shown earlier, this module is imported in django_project/urls.py, as above. Code is as follows: import dash import dash_core_components as dcc import dash_html_components as html from django_plotly_dash import DjangoDash app = DjangoDash('SimpleExample') app.layout = ... @app.callback(...) def callback_color(...): ... During the debugging process, the only other seemingly relevant information that I have is that the base_pathname is '/django_plotly_dash/app/SimpleExample/' Any other ideas? -
Display a fixed-length subset of a list in a Django template
I'd like to display a fixed-length subset of a set of related objects in a Django template. For example, imagine that I have a Car, which has related object Owner. I would like to display the four most recent owners, but also always display three entries even if there are fewer. So Ford Fiesta AA11 1AA 1. John Smith 2. Jane Smith 3. Jenny Smith Aston Martin DB9 1. Richard Rich 2. 3. even if the Fiesta has had 10 owners (and the DB9 has had only one). The naive way to do this would be <h1>{{car.name}}</h1> <ol> {% for owner in car.owner_set|slice:":3" %} <li>{{owner.name</li> {% endfor %} </ol> but this will only display one list item if there has only been one owner. I could also add lines like {% if car.owner_set|length < 2 %}<li></li>{% endif %} {% if car.owner_set|length < 3 %}<li></li>{% endif %} but that's terrible. Is there a nicer way to do this? -
When starting new django process during testing it uses the wrong database
If I start a new process in a django test case, it uses the normal database instead of the testing database. class ClientManagerTest(TestCase): def setUp(self): self.clientprocess = Process(target=run).start() Now If I do e.g. def run(): User.objects.all() it queries the standard database instead of the testing database. How to fix this? -
Django QuerySet with specific attributes from ManyToMany relationship
I need to obtain in a unique QuerySet all Jobs and every one with the name of a specific role user. For example: (all the Job attributes..., client='John', Teacher='Collins'...) Where client='John', Teacher='Collins' belongs to the ManyToMany relationships. Models: class UserProfile(models.Model): role = models.CharField(max_length=20, choices=role_choices, blank=True, null=True) ... class Job(models.Model): ... class Membership(models.Model): user = models.ForeignKey(UserProfile) job = models.ForeignKey(Job, related_name="memberships") ... -
Unable to add new model to Django Postgres DB via migration
I want to add a new model in my Django project after building my PostgresQL database. I add the model, run makemigations and migrate which both run fine. The model appears in the migrations files, but when I run python manage.py inspectdb it is not there. My initial import line works. This runs: from project import model1 When I try to load data into this model, I get the following error when I try to add this data from a CSV via get_or_create model. django.db.utils.ProgrammingError: relation "project_model1" does not exist Not sure how to fix this. Do I need to delete the database and start again. -
How to Use a DB function in a Subquery
I am trying to filter a Subquery through a function applied to a column on the parent query. How do I apply a function to an OuterRef? subquery = Subquery( Goal.objects.filter( year=ExtractYear(OuterRef("created")) ).values("target")[:1] ) stats_list = list(MyModel.objects.annotate(goal=subquery)) I expect each result in stats_list to have the appropriate goal target, but instead I get the error: AttributeError: 'ResolvedOuterRef' object has no attribute 'output_field' -
Django- Creating a log for any changes in any model data i.e creation, updation and deletion?
So i have been given a task to create a Activity Log page which shows the changes that have happened to any model data i.e either it is created or updated or deleted. My solution is to create a Activity model and store the changes following way- 1- override the save method and delete method and then save in Activity model or 2- use signals and then save it the Activity model. the Activity model right now contains only these fields- performed_on, performed_by, type_of_operation- Creation, Updation, Deletion Is there any other better way to achieve this?? -
type object 'Video' has no attribute 'video_file' django
I'm trying to display a mp4 on my site and i'm putting it in the context but for some reason when I visit the page I get this: 'type object 'Video' has no attribute 'video_file' Have tried a few things but none of them worked. Views.py def movie(request, movie_id): movie = get_object_or_404(Video, title=movie_id) # This only gets the movie name mp4 = Video.video_file.url context = {'video': movie, 'mp4':mp4} return render(request, template_name=f'uploadvideos/movie.html', context=context) models.py class Video(models.Model): title = models.CharField(max_length=40, blank=False) video_file = models.FileField(name="Upload a mp4 file", upload_to=f"uploadvideos/video", validators=[FileExtensionValidator(['mp4'])], blank=False) def __str__(self): return self.title movie.html <h1 class="movietitle">{{ video }}</h1> <div class="videoDetails"> <video width="700" height="430" controls> <source src="{{ mp4 }}" type="video/mp4"> </video> </div> I expected the video to be shown but instead I got this error: 'type object 'Video' has no attribute 'video_file' -
Send back list of errors in a template if is not empty
I create a view which add data from a file. fucntion will send back two dictionnary one with data to be saved and one with data on errors I would like to send back to template errors only if there is errors. thanks for helping My actual code send me back an error: Reverse for 'importXLS.views.import_choices' with arguments '(['miss..... -
Django testing - monkeypatching the same method on different objects
I have two objects which call the same method. However, I would like each of them to return different data. Assuming a view which could contain something like: def my_view(request): # Somehow fetching obj1 and obj2 using the ORM # ... data1 = obj1.get_data() data2 = obj2.get_data() return render(...) Here would be the outline of a test: @patch('model.get_data') def test_returns_some_data(self, mock_get_data): mock_get_data.return_value = {'foo': 'bar'} resp = self.client.get(...) In this example, both obj1 and obj2 would return the dictionary {'foo': 'bar'}. What can I do in my test to make one of them return something else? Thanks! -
Failing at sending mail from django
I'm trying to send an "email" from a website in django. I have completed the main code for doing so: -the view function -the URLs mapping to make the function reachable from code -the sending form at a template So my sending form would trigger the view function using the path specified in the URLS. On my server, I have a "postfix" instance installed and tried. I tried to edit changes in the settings.py and the views.py for about 2 days now but nothing worked. The errors range between these two 1) SMTPNotSupportedError at /website/email_send when settings are EMAIL_HOST = 'mydomain.com' EMAIL_PORT = 25 //same for port 587 EMAIL_HOST_USER = 'uname' EMAIL_HOST_PASSWORD = 'pwd!' EMAIL_USE_TLS = True 2) gaierror at /website/email_send [Errno -2] Name or service not known when settings are EMAIL_HOST = 'mail.mydomain.com' or 'smtp.mydomain.com' EMAIL_PORT = 25 //same for port 587 EMAIL_HOST_USER = 'uname' EMAIL_HOST_PASSWORD = 'pwd!' EMAIL_USE_TLS = True I expect the email to be sent using a form in my django site run on a server using postfix -
Cannot pass User to ProfileForm when testing
I'm testing a ProfileForm that depends on a SignUp form to capture User data ( I'm showing this 2 forms in a view and it works. But don't know how to test this profile form, especially because it has a user field that is a OneToOne field to the User model. And I'm using a @reciever decorator to detect what user is created and to pass this user to the profile model (please, see the view at the end). I've tried using: from django.contrib.auth import get_user_model to create a User, but when running coverage my test fails because form.is_valid() returns False when True is expected. test_forms.py from django.test import TestCase from django.utils import timezone from django.urls import reverse from shop.forms import SignUpForm, ProfileForm from django.contrib.auth import get_user_model import datetime #coverage run manage.py test shop/tests -v 2 class SignUpFormTest(TestCase): def setUp(self): self.user = get_user_model().objects.create_user( username='testuser', email='testemail@example.com', password='secret') def test_signup_form(self): form_data = {'first_name': 'oma', 'last_name': 'gonza', 'username': 'omagonza', 'email': 'oma.gonzales@gmail.com', 'password1': 'caballo123', 'password2': 'caballo123'} form = SignUpForm(data=form_data) self.assertTrue(form.is_valid()) def test_profile_form(self): district_list = 'Lima' province_list = 'Lima' department_list = 'Lima' form_data = {'user': self.test_signup_form().User, #also tried self.user from setUp method. 'dni': 454545, 'phone_number': 96959495, 'birthdate': datetime.datetime.now(), 'shipping_address1': 'Urb. Los Leones', 'shipping_address2': 'Colegio X', … -
unable to get kwargs from get_queryset of ListView
I want to get pk, or id of each post in 'views.py' so that I can use it for filtering and getting extra data in 'get_context_data'(Eventually, I want to check access of currently logged in user to each post). When website runs, it shows error message "KeyError at /post". What could be a problem in this? I was trying to apply example in django's official website(https://docs.djangoproject.com/en/2.1/topics/class-based-views/generic-display/). I couldn't see a significant difference between this example and mine. class PostList(ListView): model = Post template_name = 'post/post_list.html' def get_queryset(self): self.post = get_object_or_404(Post, pk=self.kwargs['pk']) return Post.objects.filter(pk=self.post) def get_context_data(self, **kwargs): context = super(PostList, self).get_context_data(**kwargs) context['post_info'] = self.post context['check_access'] = Access.objects.filter(sender return context I expected to see pk or id of each post but it shows below instead: self.post = get_object_or_404(Post, pk=self.kwargs['pk']) ... ▼ Local vars Variable Value args () kwargs {} self -
Transfer a url parameter to a class based view
Django==2.2.2 urlpatterns = [ re_path(r'^campaigns_detail/(?P<ids>\w+)/$', CampaignsDetailView.as_view(), name="campaigns_detail"), ] Could you help me understand why I get the error below when I try to transfer an url parameter to a class based view? Page not found (404) Request Method: GET Request URL: http://localhost:8000/campaigns_detail/?ids=1111 Using the URLconf defined in ads_manager.urls, Django tried these URL patterns, in this order: ^campaigns_detail/(?P<ids>\w+)/$ [name='campaigns_detail'] The current path, campaigns_detail/, didn't match any of these. You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page. -
Using "regular" Django with Wagtail. How to use the two together?
My problem is this: I want to build a SPA blog with React. For that, I need some Django features: Djoser (for auth with jwt), some endpoints for extra actions (for example, incrementing a view in a post), add comments, read list, and stuff. I may not have searched too much, but I did not think like: - Use regular DRF views with the wagtail API - Integrate auth with JWT (or some other example like auth token, or basic auth, but using DRF) - Or else, how to do everything with Django, but include the Wagtail only to generate Blog Posts. I have seen some examples but they are far from helping me with the problem, and my time is quite short, I need to learn some things as quickly as possible to get a job (learn redux-saga, nginx, supervisor, gunicorn and finalize a book of SQL), so I decided to ask questions here. Some of my "solutions" were: - Create a separate server for posts only (i.e., to use only the wagtail) - Create a server for everything else (i.e., using Django / DRF) So on the front end I can relate everything using the ids. -
Django registration form doesn't work with custom html
The django registration form no longer works when I included my own html template. It used to work with crispy forms, but I wanted to make it custom. The problem seems to be with the validation of the form, because it doesn't get into the "if form.is_valid():" condition anymore. My HTML code is simply input fields for username, email, password and password confirmation (I only gave the code for email as an example in the code below). template: <form method="POST"> {% csrf_token %} <fieldset class="form-group"> ... <div class="form-group"> <label for="email">Email*</label> <input required pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$" type="text" name="email" class="form-control input-email" id="email"> </div> ... </fieldset> </form> forms: class UserRegisterForm(UserCreationForm): email = forms.EmailField() class Meta: model = User fields = ['username', 'email', 'password1', 'password2'] views: def register(request): if request.method == 'POST': form = UserRegisterForm(request.POST) if form.is_valid(): post = form.save(commit=False) post.username = form.cleaned_data['username'] post.email = form.cleaned_data['email'] ... post.save() messages.success(request, 'Account created') return redirect('home') else: form = UserRegisterForm() return render(request, 'users/register.html', {'form' : form }) -
Throw Step Specific Server Error(s) Upon Saving
I am using django form wizard to save a long and complex form. Before moving to next step, I would process the step data - save the data to server using rest api. I would do the saving on each step instead of at the end during done. Is is there a way for me to throw the step specific server error to the page so that users can fix those errors first prior to moving to next step? Below is the psedo code of what I'm trying to achieve. def process_step(self, form): if self.steps.current == 'personal': first_name = self.get_form_step_data(form).get('first_name') last_name = self.get_form_step_data(form).get('last_name') try: json_data = {"first_name": first_name, "last_name": last_name} BASE_URL = 'http://xxxxxx:8080/api' response = requests.post( '%s/rest/create_user?access_token=%s' % (BASE_URL, get_access_token(requests)), data=json_data, headers=get_request_header()) status_code = response.status_code response_data = response.json() if status_code == 200: pass else: pass except: # Todo Throw Server Error Here! pass -
How to reference to parent field in django?
I'm new to Django and I have a problem: How can I show all the field from one model into another? In the HTML I need to display a table with all the field from Commesse plus the one from Prodotti and what I need is that when I change the field nostro_codice they also change the high linked fields (Descrizione, codice_cliente, etc. ..) class Commesse(models.Model): commessa = models.CharField(db_column='COMMESSA', primary_key=True, max_length=50) # Field name made lowercase. odl = models.CharField(db_column='ODL', unique=True, max_length=50) nostro_codice = models.ForeignKey(Prodotti, on_delete=models.CASCADE, to_field="nostro_codice", db_column='NOSTRO_CODICE', max_length=25, blank=True, null=True) class Prodotti(models.Model): nostro_codice = models.CharField(db_column='NOSTRO_CODICE', primary_key=True, unique=True, max_length=100) codice_cliente = models.CharField(db_column='CODICE_CLIENTE', max_length=200, blank=True, null=True) descrizione = models.CharField(db_column='DESCRIZIONE', max_length=200, blank=True, null=True) famiglia = models.CharField(db_column='FAMIGLIA', max_length=100, blank=True, null=True) unique_together = (('nostro_codice', 'codice_cliente', 'descrizione','famiglia'),) I want to display all the field from Prodotti in the Commessa with the same nostro_codice. -
Python Django strange DateTime
On the Django ModelAdmin site, my DateTime (readonly) looks strange: 23.06.19 12:Jun:rd I have in my model the following field: lastSync = models.DateTimeField(null=True, blank=True, default=None) In my settings.py I have those, which I tried different combinatinos of: #TIME_ZONE = 'Europe/Berlin' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = False USE_TZ = True I set the field via both, timezone and datetime.datetime but the result is the same: m.lastSync = timezone.now() #m.lastSync = datetime.datetime.now() What I done wrong? -
How to fix AttributeError: 'bytes' object has no attribute 'encode' if using mysql?
Django development server was running fine using mysql up to yesterday. But today I get the error AttributeError: 'bytes' object has no attribute 'encode'. I created a new blank django instance. It runs with 'ENGINE': 'django.db.backends.sqlite3'. But produces same error when I change it to 'ENGINE': 'django.db.backends.mysql' System specification: os: manjaro linux virtual environment python version: 3.6 Django version: 2.2 MariaDB version: 10.3.15-1 Have not updated any related package in last 3 days. The error: Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). Exception in thread django-main-thread: Traceback (most recent call last): File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/usr/lib64/python3.6/threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper fn(*args, **kwargs) File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run self.check_migrations() File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/core/management/base.py", line 453, in check_migrations executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__ self.loader = MigrationLoader(self.connection) File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__ self.build_graph() File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/migrations/loader.py", line 212, in build_graph self.applied_migrations = recorder.applied_migrations() File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 73, in applied_migrations if self.has_table(): File "/srv/http/python/env/env36/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 "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/backends/base/base.py", line 256, in cursor return self._cursor() File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/backends/base/base.py", line 233, in _cursor self.ensure_connection() File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/backends/base/base.py", line …