Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to keep django rest API server running automatically on AWS?
So I uploaded my Django API with Rest framework on AWS EC2 instance. However, I have to manually go to Putty and connect to my EC2 instance and turn API on whenever I want to use it. When I turn off my PC, putty closes and API cannot be accessed anymore on the ip address. How do I keep my API on forever? Does turning it into https help? Or what can be done? -
Why this python returned value is changing type after assignment
I'm puzzled by this piece of code. The code below is a copy of renderer.py module from django rest framework. Than led me to study a lot of Python inner workings but I still can't understand what is going on with the return / assignment behavior of self.get_template_context function. def render(self, data, accepted_media_type=None, renderer_context=None): (...) print('1', id(data), data) context = self.get_template_context(data, renderer_context) print('4', id(context), context) (...) def get_template_context(self, data, renderer_context): print('2', id(data), data) response = renderer_context['response'] if response.exception: data['status_code'] = response.status_code print('3', id(data), data) return data So the render function calls get_template_context passing two variables, data and renderer_context. The function then includes the status_code on data dictionary before returning it (if exception). I put some print statements to see what is going on with this small piece of code: 1 1730745664704 <class 'rest_framework.utils.serializer_helpers.ReturnDict'> {'date': '', 'memo': ''} 2 1730745664704 <class 'rest_framework.utils.serializer_helpers.ReturnDict'> {'date': '', 'memo': ''} 3 1730745664704 <class 'rest_framework.utils.serializer_helpers.ReturnDict'> {'date': '', 'memo': ''} 4 1730745396352 <class 'dict'> {'data': {'date': '', 'memo': ''}, 'serializer': TransactionSerializer(context={'request': <rest_framework.request.Request: POST '/ledger/ledgers/1/transactions/'>, 'format': None, 'view': <ledger.views.TransactionViewSet object>}): url = NestedHyperlinkedIdentityField(parent_lookup_kwargs={'ledger_pk': 'ledger__pk'}, view_name='transaction-detail') date = DateTimeField() memo = CharField(allow_blank=True, required=False, style={'base_template': 'textarea.html'}) entries = EntrySerializer(many=True, required=True): url = NestedHyperlinkedIdentityField(parent_lookup_kwargs={'transaction_pk': 'transaction__pk', 'ledger_pk': 'transaction__ledger__pk'}, view_name='entry-detail') value = DecimalField(decimal_places=5, … -
Django Model - special characters in field name
I'm creating model for my app. Unfortunately I'm working with measurements units like km/h, kg CO2/ton, heat content (HHV) - 30 different units at all. I don't know how to save it properly in django model or maybe in serializer to make it display proper unit name, including "/", " ", "(" in REST Responses. Also I will be importing data through django-import-export module so it should recognize excel columns which will be named like actual unit name. For example: class Units(models.Model): km_h = models.FloatField(default=-1, null=True) kg_co2ton = models.FloatField(default=-1, null=True) and I would like to have this data available in the following form: class Units(models.Model): km/h = models.FloatField(default=-1, null=True) kg co2/ton = models.FloatField(default=-1, null=True) How to write model and/or serializer to make it work and look good? -
How to deploy a Django and React project on the same Ubuntu 18.04 server using gunicorn and nginx?
I have a Django project that I have already successfully deployed on my Ubuntu 18.04 server via gunicorn and nginx using this tutorial. https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04 The project uses Django Rest Framework and I'm able to access it's endpoints via a web browser. However, I would also like to deploy a separate react project on the same server, so that it can send http requests to the Django app and display data received from the REST API. How can I go about doing this? Here is my current gunicorn.service [Unit] Description=gunicorn daemon Requires=gunicorn.socket After=network.target [Service] User=ubuntu Group=www-data WorkingDirectory=/home/ubuntu/my_project/coffeebrewer ExecStart=/home/ubuntu/my_project/venv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/ubuntu/my_project/coffeebrewer/coffeebrewer.sock coffeebrewer.wsgi:application [Install] WantedBy=multi-user.target And here are my current nginx configurations server { listen 80; listen [::]:80; server_name my_ipv6_address; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root root /home/ubuntu/my_project/coffeebrewer; } location / { include proxy_params; proxy_pass http://unix:/run/gunicorn.sock; } } -
Maintaining current URL after incorrect password entry -- Django
def login_view(request): if request.method == "POST": form = AuthenticationForm(data=request.POST) if form.is_valid(): user= form.get_user() login(request, user) if "next" in request.POST: return redirect(request.POST.get('next')) else: print('failed to redirect after login') return redirect('articles:list') <form class="site-form" action='.' method="post"> {% csrf_token %} {{ form }} {% if request.GET.next %} <input type="hidden" name="next" value="{{ request.GET.next }}"> {% endif %} <input type="submit" value="Login"> </form> So the issue I am having is that when I use the @login_required parameter on a specific view function in Django. Things work fine initially. The URL contains ?next=/original/url and the form is correctly able to collect the request.POST.next value of the dictionary it returns and send it back to the login function. Then if you put the password in correctly, it redirects you back to the page you were originally trying to get to via the value of the request.POST.next value THE ISSUE: This only works if you get the password right on the first try. If you enter the password incorrectly, it loses the ?next= part of the url tag and just goes to the default log in page. Thus, when you get the password right the second time, it does not redirect you back to the page you were trying to … -
Unable to login if I register the user using post man or with API in django
unable to login the user if the register the user with postman or with API, but if the register the same user in django admin i can able to login and generating the token. Please help me on this. my serializer code: class UserSerializerWithToken(UserSerializer): token = serializers.SerializerMethodField(read_only=True) class Meta: model = NewUser fields = ['_id','token'] def get_token(self,obj): token = RefreshToken.for_user(obj) return str(token.access_token) my token generation code: class MyTokenObtainPairSerializer(TokenObtainPairSerializer): def validate(self, attrs): data = super().validate(attrs) # data['username'] = self.user.username serializer = UserSerializerWithToken(self.user).data for k, v in serializer.items(): data[k] = v return data class MyTokenObtainPairView(TokenObtainPairView): serializer_class = MyTokenObtainPairSerializer I have created the custom model I think i have problem with the register one but once I register the token is generating but if i am logging in its is saying in valid credentials @api_view(['POST']) def registerUser(request): data = request.data try: user = NewUser.objects.create_user( email=data['email'], first_name=data['first_name'], last_name=data['last_name'], password=make_password(data['password']), ) serializer = UserSerializerWithToken(user, many=False) return Response(serializer.data) except: message = {'detail': f'User with email: {data["email"]} already exists'} return Response(message, status=status.HTTP_400_BAD_REQUEST) -
wagtail django.core.exceptions.FieldError: Unknown field(s); Fields doesn't exist anywhere
my python manage.py makemigrations return error with message File "/usr/local/lib/python3.6/site-packages/django/forms/models.py", line 268, in __new__ raise FieldError(message) django.core.exceptions.FieldError: Unknown field(s) (seo_title_fr, title_fr, search_description_en, slug_en, seo_title_en, slug_fr, search_description_fr, title_en) specified for PostPage I did serch everywhere in the code where are this fields I didn't find theme at all I did search in database wagtailcore_page I didn't find that fields id | path | depth | numchild | title | slug | live | has_unpublished_changes | url_path | seo_title | show_in_menus | search_description | go_live_at | expire_at | expired | content_type_id | owner_id | locked | latest_revision_created_at | first_published_at | live_revision_id | last_published_at | draft_title | locked_at | locked_by_id | translation_key | locale_id | alias_of_id | url_path_en | url_path_fr I did search in all the code including migrations but not found anything I did try : python manage.py update_translation_fields but no luck my model is : import json from django.db import models from django import forms from django.conf import settings from django.utils.translation import ugettext_lazy as _ from django.template.defaultfilters import slugify from django.utils.timezone import now from django.shortcuts import render from django.http import HttpResponse, JsonResponse,HttpResponseRedirect, Http404 from django.template.response import TemplateResponse from django.forms import FileField from django.core.serializers.json import DjangoJSONEncoder from wagtail.core.models import Page from wagtail.core.fields … -
How to know when heroku rotate my heroku postgres credentials?
Heroku rotate the credentials on heroku postgres, how can i prevent this issue in production apps? -
how to request and post an object to a foreignkey field
When I do this exactly as provided below, a shipping address object is created without the customer assigned in the shipping address foreignkey field, I can add it from the admin panel manually but I'm not able to make it work through code, idk what I'm doing wrong, please help! **models.py** class Customer(models.Model): user = models.OneToOneField(CustomUser, on_delete=models.CASCADE, blank=True, null=True) first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) email = models.EmailField(max_length=150) class ShippingAddress(models.Model): customer = models.ForeignKey(Customer, on_delete=models.SET_NULL, blank=True, null=True) order = models.ForeignKey(Order, on_delete=models.SET_NULL, blank=True, null=True) address_one = models.CharField(max_length=200) address_two = models.CharField(max_length=200) ... **views.py** def checkout(request): if request.user.is_authenticated: customer = request.user.customer order, created = Order.objects.get_or_create(customer=customer, complete=False) items = order.orderitem_set.all() else: items = [] order = {'get_cart_total': 0, 'get_cart_items': 0} if request.method == 'POST': form = ShippingForm(request.POST) if form.is_valid(): #how do I get the customer to get added in the foreignkey field for the shipping address model form.save() return redirect('store:checkout_shipping') else: form = ShippingForm() else: form = ShippingForm() context = {"items": items, "order": order, "form": form} return render(request, 'store/checkout.html', context) -
Error in Postgresql: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: password authentication failed for user "TheGecko"
Im trying to use PostgreSQL with django and I get that error when running python3 manage.py migrate: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: password authentication failed for user "TheGecko" I was following this guide:https://djangocentral.com/using-postgresql-with-django/ Here is my settings.py: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'websitedb', 'USER':'TheGecko', 'PASSWORD':'xx', 'HOST':'localhost', 'PORT':5432, } } Also, even though I entered that line: GRANT ALL PRIVILEGES ON DATABASE websitedb TO TheGecko;, when I do \l, I get this output. Shouldn't the owner be TheGecko? I've looked over the web and nothing I could read worked for me. Please help. -
Python Django Rest framework
What are the contents of args and kwargs in this create method? def create(self, request, *args, **kwargs) -
Django's Image Field and Google app engine
I have a django app deployed on google cloud platform. I also have the same app deployed on heroku(It works fine). I have a model in my code that looks like this : class Notification(models.Model): ## other fields qrcode = models.ImageField(null=True, blank=True, default=None) When I pass this model to the serializer, I got a status code 500. I googled it and find some answers reffering to PIL library or some needed configuration in the Google Cloud App Engine in order to support ImageField. Does anyone know what to do in this case? Thnx in advance -
What other softares/libraries should I look to import to base Django if I'm looking to make a banking application?
I'm a relatively new full stack developer that recently picked up a project to create a banking application that handles users' banking information and allows them to purchase bonds. I'm familiar with Django, templating, and APIs, but I was wondering if someone could recommend some of the best software to combine with Django to make this app possible. -
Specifying Django widget attribute in ModelForm rather than as HTML <style>
I have a Django input slider defined as follows: #widgets.py from django.forms.widgets import NumberInput class RangeInput(NumberInput): input_type = 'range' #forms.py from polls.widgets import RangeInput class VoteForm(forms.ModelForm): class Meta: #model = CC_Responses model = CC_Resp_NoFK fields = ['Person_ID', 'Test_date', 'Response_value'] # following added from SliderModelForm widgets ={ 'Response_value':RangeInput } which is “processed” by the view def p2vote(request,q_id): CC_question = get_object_or_404(CC_Questions, pk=q_id) # if request.method == 'POST': form = VoteForm(request.POST) if form.is_valid(): item = form.save(commit=False) item.Q_ID = q_id item.save() return redirect('/polls/p2') else: formV = VoteForm() return render(request, 'pollapp2/vote.html', {'var_name':CC_question,'form' : VoteForm()}) and in the template I have the inline CSS <style> /* Following CSS is used by the input slider (range) since Django assigns id value of id_Response_value */ /*See: https://stackoverflow.com/questions/110378/change-the-width-of-form-elements-created-with-modelform-in-django */ #id_Response_value{width:300px;} </style> which is associated with the slider/range <label for="Response_value">Response value</label> {% render_field form.Response_value rows="1" class="form-control" %} I obtained id_Response_value by looking at the source of the rendered HTML in the browser – I guess I could explicitly set an ID. All the above works exactly as I want. I can control the width of the range slider using CSS. Now, I believe, inline CSS is a “bad thing”, so as a step to improve my code I’m trying to … -
I want to display the images and user can select one of them
I am new at Django I want some helps. Basically,I want from users that they can select multiple images and save it, but I got like this and I don't know how to do it. I want to display the images and user can select one of them. please help. models.py class Images(models.Model): product_image=models.ImageField(upload_to='media',null=True, blank=True) def __str__(self): return "{}".format (self.product_image) class user_select(models.Model): name = models.CharField(max_length=200, null=True, blank=True) product_image=models.ForeignKey(Images, on_delete=models.CASCADE) def __str__(self): return "{}".format (self.name) forms.py class UserForm(forms.ModelForm): class Meta: model = user_select fields = '__all__' views.py def home(request): form = UserForm() if request.method == 'POST': form = UserForm(request.POST) if form.is_valid(): form.save() context = {'form':form} return render(request, 'home.html', {'form':form}) home.html {% extends 'base.html' %} {% load crispy_forms_tags %} {% block content %} <div class="container mt-5"> <div class="row mt-5 mr-5"> <div class="col-md-8 mt-5"> <div class="card border border-secondary mt-5"> <div class="col-md-8 mt-5" align='center'> <form method="POST" action="" > {% csrf_token %} <div class="col-md-8"> {{ form|crispy }} </div> </form> <button type="submit" class="btn btn-success mt-5 mb-5">Place Order</button> </div> </div> </div> </div> </div> {% endblock %} enter image description here -
Dehydrate the same field django
I have a model Student: class Student(models.Model): id = models.AutoField(primary_key=True) name = models.CharField(max_length=30, verbose_name='Name') lastname = models.CharField(max_length=100, verbose_name='Lastname') history = HistoricalRecords() Also I have a model: class Class(models.Model): id = models.AutoField(primary_key=True) student = models.models.ForeignKey(Student,on_delete = models.CASCADE, related_name='+') my admin.py class ClassResource(resources.ModelResource): class Meta: model = Class fields = ('student',) def dehydrate_student(self, Class): student= getattr(Class.student, "name") return '%s' % (student) class ClassExportAdmin(ImportExportModelAdmin, ClassAdmin): resource_class = ClassResource admin.site.register(Class, ClassExportAdmin) Now I am executing only name, is that possible to dehydrate the same field student one more time. I need past into my 2 column the surname of the student. -
Django : Rename a file with the username and the the timestamp before uploading
I am newbee in Django. I have an app where I can upload multiple files. I would like to rename the file by including the username that is authenticated and the timestamp : "bild.png" should become "bild_John_Bown_202204055.png" I use the Microsoft Graph tutorial on Django to the authentication process (https://docs.microsoft.com/en-us/graph/tutorials/python). Anyone can help me to include that in my code. Thank you models.py from django.db import models class UploadFiles(models.Model): documents = models.FileField(upload_to='document/', blank=True, null=True) uploaded_at = models.DateTimeField(auto_now_add=True) forms.py from django import forms from django.forms import ClearableFileInput from .models import UploadFiles class FilesForm(forms.ModelForm): class Meta: model = UploadFiles fields = ['documents'] widgets = {'documents': ClearableFileInput(attrs={'multiple': True}),} views.py from django.shortcuts import render from django.http import HttpResponse, HttpResponseRedirect from django.urls import reverse from base.auth_helper import get_sign_in_flow, get_token_from_code, store_user, remove_user_and_token, get_token from base.login_helper import * from django.core.files.storage import FileSystemStorage from os import listdir from os.path import isfile, join, getmtime from django.conf import settings from base.forms import FilesForm from base.models import UploadFiles def home(request): context = initialize_context(request) return render(request, 'home.html', context) def initialize_context(request): context = {} # Check for any errors in the session error = request.session.pop('flash_error', None) if error != None: context['errors'] = [] context['errors'].append(error) # Check for user in the session context['user'] = … -
how to delete an specific item from a foreign key within .views? Django
Im working on a Django app where you can join events only under the approval of the owner of the event. By now, I have the function that adds the current user to the event for approval. .views @login_required def request_event(request, pk): previous = request.META.get('HTTP_REFERER') try: post = Post.objects.get(pk=pk) Attending.objects.create(post=post, attendant=request.user) messages.success(request, f'Request sent!') return redirect(previous) except post.DoesNotExist: return redirect('/') and here is the function that deletes de user request (By now is deleting the request of the current logged user) @login_required def remove_attendant(request, pk): previous = request.META.get('HTTP_REFERER') try: post = Post.objects.get(pk=pk) #attendant = #post.attending_set.all Attending.objects.filter(post=post, attendant=request.user).delete() messages.success(request, f'User removed!') return redirect(previous) except post.DoesNotExist: return redirect('/') My situation here is that I'm a having problem to get the attendants of the event (all the users who where added as atendant), so that the owner can reject which ever request he want. How can I change this so that the function is going to delete a specific user of the event? Thanks!! Additional: models.py class Attending(models.Model): is_approved = models.BooleanField(default=False) attendant = models.ForeignKey(User, related_name='events_attending', on_delete=models.CASCADE, null=True) post = models.ForeignKey('Post', on_delete=models.CASCADE, null=True) class Post(models.Model): author = models.ForeignKey(User, on_delete=models.CASCADE) urls.py path('post/<int:pk>/remove_attendant/', views.remove_attendant, name='remove-attendant'), -
Django - how to create a form field containing checkboxes WITH an 'Other' text input field
I'm creating a form in Django, and would like to give users a list of checkboxes with the option of having an Other _____ text input as one of the choices. Here's my code using MultipleChoiceField and CheckboxSelectMultiple: class IntakeFormSimple(Form): def __init__(self, *args, **kwargs): super(IntakeFormSimple, self).__init__(*args, **kwargs) preferred_pronouns = forms.MultipleChoiceField( choices=(("she/her", "she/her"), ("he/him", "he/him"), ("they/them", "they/them")), # <--- add "Other" here label="What are your preferred pronoun(s)?", widget=forms.CheckboxSelectMultiple, ) -
How to implement a low cost (semi) chat in django/mobile app
I want to implement a semi (realtime) web chat. The project has 2 user groups, Managers and Users. The manager is in a group chat with his users. There are a couple of demands/problems: Now the thing is django is hosted on pythonanywhere, they dont support websocket. The cost of the project has to be low so streamer is not an option for now. I can do it over rest api but there will be a lot of requests on the server side, i dont know if this is a problem over time. Anyone done a project like this ? please advise. -
How to use Django's hidden `through` models in a `Q` expression
I learned yesterday that you can use a through expression in a key path that's in a Q expression. And I learned that when filtering using fields in M:M related tables, the resulting queryset is more like a true join (where the root table record is duplicated and combined with multiple related table records). I learned that I could accomplish this using ModelA.mmrelatedModelB.through.filter() in the shell. For example, I have 106 PeakGroup records, and every PeakGroup for compound "citrate" also links to compound "isocitrate", so if I query for 1, I get back 106 records. And if I query for either, I get back 212: In [16]: PeakGroup.compounds.through.objects.filter(Q(compound__name__exact="citrate")).count() Out[16]: 106 In [17]: PeakGroup.compounds.through.objects.filter(Q(compound__name__exact="citrate") | Q(compound__name__exact="isocitrate")).count() Out[17]: 212 However, I learned in the comments under this stack answer, that I should be able to accomplish the same thing in the Q expression only, without referencing PeakGroup.compounds.through. I imagined the expression might look something like this: PeakGroup.objects.filter(Q(through_peakgroup_compound__compound__name__exact="citrate") | Q(through_peakgroup_compound__compound__name__exact="isocitrate")).count() but I have been unable to figure out how to construct the "path" that includes the through model... Every attempt results in an error something like: FieldError: Cannot resolve keyword 'through_peakgroup_compound' into field. Perhaps in the comments of that linked stack answer, there … -
what's gettext_lazy on django is for?
maybe is a dummy question but i have read on the documentation of Django about the "gettext_lazy", but there is no clear definition for me about this exact function and i want to remove it and i found this implementation from django.utils.translation import gettext_lazy as _ and is used on a django model field in this way email = models.EmailField(_('email address'), unique=True) what's is for? what's happen if i remove it? -
how do I request a user and save the user in a Foreignkey field of a model
I've been at it for some time but can't find a way to set the 'customer' to the 'ShippingAddress' model's customer foreignkey field, how do I query the customer field so that along with the shipping data through the form, the customer gets saved in the foreignkey field as well. thx in advance! **models.py** class Customer(models.Model): user = models.OneToOneField(CustomUser, on_delete=models.CASCADE, blank=True, null=True) first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) email = models.EmailField(max_length=150) class ShippingAddress(models.Model): customer = models.ForeignKey(Customer, on_delete=models.SET_NULL, blank=True, null=True) address_one = models.CharField(max_length=200) address_two = models.CharField(max_length=200) ... **views.py** def checkout(request): if request.method == 'POST': form = ShippingForm(request.POST) customer = request.user.customer if form.is_valid(): # how to get the customer and send it back to the shippingmodel form user = ShippingAddress.objects.get(customer=customer) form.save() return redirect('store:checkout_shipping') else: form = ShippingForm() else: form = ShippingForm() context = {"form": form} return render(request, 'store/checkout.html', context) -
Configuring multiple databases in Django
Introduction I have read Django docs: Multiple databases, but it doesn't seem to work for me after upgrading from 3.2 to 4.0. Other changes have been made, but since I'm working in a development environment, I chose to remove all previous migrations and run ./manage.py makemigrations again, but it did not help to solve the issue. Router Definition First, here's how I define the router. You'll notice it's nearly identical to the example, but I include mostly everything in the admin_db database (with two exceptions: custom apps api.dictionary and api.pdf). /api/authentication/routers.py class AdminDBRouter: """ A router to control all database operations on models in the authentication application, all and any dependent applications, and Django administrative applications. """ route_app_labels = { 'admin', 'auth', 'authentication', 'contenttypes', 'sessions', 'sites', 'token_blacklist', } def db_for_read(self, model, **hints): """ Attempts to read models defined in any app in 'self.route_app_labels' go to 'admin_db'. """ if model._meta.app_label in self.route_app_labels: return 'admin_db' return None def db_for_write(self, model, **hints): """ Attempts to write models defined in any app in 'self.route_app_labels' go to 'admin_db'. """ if model._meta.app_label in self.route_app_labels: return 'admin_db' return None def allow_relation(self, obj1, obj2, **hints): """ Allow relations if a model in any app defined in 'self.route_app_labels' is … -
Migrating my Django project on Heroku is showing django.db.utils.ProgrammingError: relation "users_customuser" does not exist
Migrating my Django project on Heroku is showing django.db.utils.ProgrammingError: relation "users_customuser" does not exist. But this is working completely fine on my local. Running migrations: Applying account.0001_initial...Traceback (most recent call last): File "/app/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) psycopg2.errors.UndefinedTable: relation "users_customuser" does not exist The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/manage.py", line 22, in <module> main() File "/app/manage.py", line 18, in main execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv self.execute(*args, **cmd_options) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute output = self.handle(*args, **options) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 89, in wrapped res = handle_func(*args, **kwargs) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 244, in handle post_migrate_state = executor.migrate( File "/app/.heroku/python/lib/python3.9/site-packages/django/db/migrations/executor.py", line 117, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "/app/.heroku/python/lib/python3.9/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/app/.heroku/python/lib/python3.9/site-packages/django/db/migrations/executor.py", line 230, in apply_migration migration_recorded = True File "/app/.heroku/python/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 118, in __exit__ self.execute(sql) File "/app/.heroku/python/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 145, in execute cursor.execute(sql, params) File "/app/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py", line 98, in execute return super().execute(sql, params) File "/app/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py", line 66, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/app/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py", line 75, …