Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Error ModelForm has no model class specified
Can't get past this error for a while now, checked all the related topics and everyone had a typo/syntax problem. I have checked everything and the code looks fine and I really can't tell what could be the problem, if anyone sees the issue pls help. Below I'll place my code and the error. I created a form so I can add a new subject via a button which I call inside my view and render in a template, very simple. TRACEBACK Environment: Request Method: GET Request URL: http://127.0.0.1:8000/addsubj/ Django Version: 3.1.5 Python Version: 3.7.0 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'App', 'crispy_forms'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback (most recent call last): File "C:\Users\D\Documents\django\project\env\lib\site-packages\django\core\handlers\exception.py", line 47, in inner response = get_response(request) File "C:\Users\D\Documents\django\project\env\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\D\Documents\django\project\project\App\decorations.py", line 7, in wrap return function(request, *args, **kwargs) File "C:\Users\D\Documents\django\project\project\App\views.py", line 40, in add_subject_view newsubj = AddSubjectForm() File "C:\Users\D\Documents\django\project\env\lib\site-packages\django\forms\models.py", line 287, in __init__ raise ValueError('ModelForm has no model class specified.') Exception Type: ValueError at /addsubj/ Exception Value: ModelForm has no model class specified. MY FORMS.PY from django.forms import ModelForm from django import forms from django.contrib.auth.forms import UserCreationForm from .models … -
Submitting data from 1 table to another table
I am trying to submit data from a checklist using forms. The checklist is generated from a database table and after submission the checked items are inserted into another database table. I am getting the error as form is invalid. This is my models.py CustomStudent is the database from where I am taking value and Reports is the database where I am submitting values class CustomStudent(models.Model): _id = models.AutoField sname = models.CharField(max_length = 50) slname = models.CharField(max_length = 50) password = models.CharField(max_length = 255, default = '') def __str__(self): return str(self.slname) return str(self.sname) class Report(models.Model): # _id = models.AutoField() tname = models.CharField(max_length = 100) sname = models.CharField(max_length = 100) fdate = models.DateField() tdate = models.DateField() dailydate = models.DateField() objective = models.CharField(max_length = 512) tplan = models.CharField(max_length = 512) how = models.CharField(max_length = 512) material = models.CharField(max_length = 512) extra = models.CharField(max_length = 512) topic = models.CharField(max_length = 512) pftd = models.CharField(max_length = 512) activity = models.CharField(max_length = 512) comment = models.CharField(max_length = 512) thought = models.CharField(max_length = 512) admin_comment = models.CharField(max_length = 255) def __str__(self): return str(self.tname) return str(self.sname) This is code from my forms.py to use the database. sname = forms.ModelMultipleChoiceField(queryset=CustomStudent.objects.all().values_list('sname', flat=True), required = False, widget =forms.CheckboxSelectMultiple( attrs ={'class':' … -
How do I keep select option after form validation has failed in Django?
After validation fails, I want to keep values entered by user, but have issues with dropdowns. In models.py GENDER = [ ('M', 'Male'), ('F', 'Female'), ('O', 'Other'), ] gender = models.CharField(max_length=1, choices=choices.GENDER, default='') In template <div class="col-md-4"> <label for="gender">Gender</label> <select class="form-control form-control-lg" id="gender" name="gender" required> <option selected></option> {% for choice in form.gender.field.choices %} <option value="{{ choice.0 }}" >{{ choice.1 }}</option> {% endfor %} </select> </div> In views.py if form.is_valid(): return render(self.request, 'success.html') else: form_content = {'form': form} return render(self.request, 'template.html', form_content) -
Want to run test on postgresql and not sqlite: sqlite3.OperationalError: no such function: Now
I have a Django app set with Docker and different developpement environment: dev, preprod, prod. I use a postgresql database / pgaadmin 4 in my local Windows environment I want to write and run tests 'outside' Docker in a VSCode terminal (because if I use web container to run tests, changes in my tests.py are not updated so I need to down, build and re-run my containers) so I run the command py manage.py test cafe.tests.CafeTestCase --settings=core.settings.preprod where I speficy the settings to consider But I got an error sqlite3.OperationalError: no such function: Now because some data migrations use timezone.now() that i not available in sqlite but I have specify test_database in my settings and given access to user so test should consider postgresql no? base.py DATABASES = { 'default': { "ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.sqlite3"), "NAME": os.environ.get("SQL_DATABASE", os.path.join(BASE_DIR, 'db.sqlite3')), "USER": os.environ.get("SQL_USER", "user"), "PASSWORD": os.environ.get("SQL_PASSWORD", "password"), "HOST": os.environ.get("SQL_HOST", "localhost"), "PORT": os.environ.get("SQL_PORT", "5432"), 'TEST' : { 'NAME': 'test_cafetropical', } } } environment variables are set in a .env.preprod file -
Error while executing raw sql query in django
I am trying to use raw query in django view : but it is showing error: database table named auth_user: my point is: 'where' clause should check for column named "username" why it checking for column "chaitanya360" which is obviously not present in table. -
Follow/unfollow button without reload page [Django, AJAX]
I made 'Follow user' functionality. It works fine. You can follow and later unfollow somebody. But it's not enough... Now when you click follow or unfollow button the page have been reload. I need 'Follow user' functionality without reload the page. I don't know how implement AJAX here. Can you help me with this? In my template.html i have: {% with total_followers=profile.followers.count %} ({{ total_followers }} Follower) <br> {% endwith %} <form action="{% url 'users:follow_user' %}" method="POST" class="follow-form" id="{{ profile.id }}"> {% csrf_token %} <input type="hidden" name="user_id" value="{{ profile.id }}"> <button type="submit" class="follow-btn{{ profile.id }}"> {% if request.user not in profile.followers.all %} Follow {% else %} Unfollow {% endif %} </button> </form> In my view.py i have function to follow or unfollow: def follow_user(request): user = request.user if request.method == 'POST': user_id = request.POST.get('user_id') user_obj = Profile.objects.get(id=user_id) if user not in user_obj.followers.all(): UserFollowing.objects.get_or_create(following_from=user, follow_to=user_obj) else: UserFollowing.objects.filter(following_from=user, follow_to=user_obj).delete() return redirect('profile', slug=user_obj.slug) In my models.py i have: class UserFollowing(models.Model): following_from = models.ForeignKey("Profile", related_name="following_from", on_delete=models.CASCADE) follow_to = models.ForeignKey("Profile", related_name="follow_to", on_delete=models.CASCADE) created = models.DateTimeField(auto_now_add=True, db_index=True) class Meta: db_table = 'users_userfollowing' constraints = [models.UniqueConstraint(fields=["following_from", "follow_to"], name="unique_followers")] ordering = ("-created",) def __str__(self): return f"FROM:{self.following_from} TO:{self.follow_to}" class Profile(AbstractUser, HitCountMixin): following = models.ManyToManyField("self", through=UserFollowing, related_name="followers", symmetrical=False) def save(self, … -
more than one primary key error in django
I have a problem with two of my models. When tying to migrate it always ends up with the error that I have more than one primary key. I have googled and tried lots of different solutions but nothing works. models: class Adress(Model): street=CharField(default='',max_length=100) snumb=CharField(default='',max_length=15) town=CharField(default='',max_length=100) postn=CharField(default='',max_length=5,validators=[postnvali]) def __str__(self): return 'city: ' + self.town class Meta: ordering=('street','town') class Person(Model): fname=CharField(default="",max_length=100) lname=CharField(default="",max_length=100) mobil=PhoneField(default='9999999999') mail=EmailField(default='contact@gmail.com') padress=OneToOneField(Adress,on_delete=CASCADE) def __str__(self): return 'person: ' + self.fname class Meta: ordering=('fname','lname') migration file: # Generated by Django 3.1.4 on 2021-01-20 13:32 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('kammem', '0029_auto_20210120_1354'), ] operations = [ migrations.AddField( model_name='person', name='id', field=models.AutoField(auto_created=True,serialize=False, verbose_name='ID'), preserve_default=False, ), migrations.AlterField( model_name='person', name='padress', field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='kammem.adress'), ), ] -
Post is not liking or Disliking
I am making a Blog app and I built a Like or Dislike Feature BUT that is not working. It is showing custom error. views.py def post_like_dislike(request, post_id): post = get_object_or_404(Post, pk=post_id) # Like if request.GET.get('submit') == 'like': if request.user in post.dislikes.all(): post.dislikes.remove(request.user) post.likes.add(request.user) return JsonResponse({'action': 'undislike_and_like'}) elif request.user in post.likes.all(): post.likes.remove(request.user) return JsonResponse({'action': 'unlike'}) else: post.likes.add(request.user) return JsonResponse({'action': 'like_only'}) # Dislike elif request.GET.get('submit') == 'dislike': if request.user in post.likes.all(): post.likes.remove(request.user) post.dislikes.add(request.user) return JsonResponse({'action': 'unlike_and_dislike'}) elif request.user in post.dislikes.all(): post.dislikes.remove(request.user) return JsonResponse({'action': 'undislike'}) else: post.dislikes.add(request.user) return JsonResponse({'action': 'dislike_only'}) else: messages.error(request, 'Something went wrong') return redirect('home') detail.html <form method="GET" class="likeForm d-inline" action="{% url 'comments:post_like_dislike' post.id %}" data-pk="{{post.id}}"> <button type="submit" class="btn"><i class="far fa-thumbs-up"></i> <span id="id_likes{{post.id}}"> {% if user in post.likes.all %} <p style="color:#065FD4;display: inline">{{post.likes.count}}</p> {% else %} <p style="color:black;display: inline">{{post.likes.count}}</p> {% endif %} </span> Like</button> </form> <form action="{% url 'comments:post_like_dislike' post.id %}" method="GET" class="d-inline dislikeForm" data-pk="{{ post.id }}"> <button type="submit" class="btn"><i class="far fa-thumbs-down"></i> <span id="id_dislikes{{post.id}}"> {% if user in post.dislikes.all %} <p style="color:#065FD4; display: inline;">{{post.dislikes.count}}</p> {% else %} <p style="color:black; display: inline;">{{post.dislikes.count}}</p> {% endif %} </span> Dislike </button> </form> urls.py path('post_like_dislike/<int:post_id>/',views.post_like_dislike, name='post_like_dislike'), models.py class Post(models.Model): description = models.TextField() likes = models.ManyToManyField(User, related_name='post_like', blank=True) dislikes = models.ManyToManyField(User, related_name='post_dislike', blank=True) ERROR When i click … -
Django returns relative path to image field not url
I have following AdminUserSerializer serializer and PersonSerializer serializer class AdminUserSerializer(serializers.ModelSerializer): persons = PersonSerializerForUser(many=True) verifications = serializers.SerializerMethodField('users_for_verification') class Meta: model = User fields = ['id', 'persons', 'verifications'] @staticmethod def users_for_verification(obj): persons = obj.persons.filter(status=1, paid=True) serializer = PersonSerializer(persons, many=True) return serializer.data class PersonSerializer(serializers.ModelSerializer): comments = serializers.SerializerMethodField('paginated_comments') images = ImageSerializer(source='image_set', many=True) class Meta: model = Person exclude = ('paid', 'status', 'register_date', 'paid_date') def paginated_comments(self, obj): .... The request returns { "id": "bf6e227b-5037-4475-b07e-7dbf44bcbfa1", "persons": [ { "id": "8aec320c-2f0d-4f46-8ba9-1ad9428e2218", "images": [ {"image": "http://127.0.0.1:8000/media/images/1_skR8WG9.jpg"} ], "name": "123", "city": "123", "bio": "123" } ], "verifications": [ { "id": "8aec320c-2f0d-4f46-8ba9-1ad9428e2218", "comments": {} ] }, "images": [ {"image": "/media/images/1_skR8WG9.jpg"} ], "name": "123", "city": "123", "bio": "123", ]} For person.images.image contains url to image, but verifications.images.image returns a relative path to image, but i want an url -
how do I apply bootstrap styles only for django-crispy-forms not for other tags in the html template
Upto know I used Bootstrap for the total project. But now I wanted to use my own styling for my Whole project. And I want to use crispy form tags for some forms like registration and login form.But when I tried it bootstrap styles are applying to my whole project.I don't want that I just want styling for only forms from crispy_forms. How can I achieve this. Thanks in advance. {% extends '../base.html' %} {% load crispy_forms_tags %} {% block extra_head %} <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous"> {% endblock extra_head %} {% block content %} <form method="post"> {{ form|crispy }} <button class="btn btn-outline-primary" type="submit">SignUp</button> #styles applying for this button also </form> {% endblock content %} -
Changing the default value of a field in django models, can't run migrations
So here's what happened, i am designing a website for my college and the user model has an integer field named "year". I added this field after i migrated once with the " AbstractUser " model. I run "makemigrations" again and it asks me to set a default value for year as it is a not null field. I mistakenly put "undefined" as the default in an Integer Field, and it gave me an error. so i changed the default as 1 in the models file and run makemigrations again. It worked, but when i run python manage.py migrate, it gave me the same error again: ValueError: Field 'year' expected a number but got 'undefined'. I don't understand what to do now... -
django button -> start script -> stay on same page (no redirects/no refresh)
Im working on a simple web app - that turns on a led on a arduino. I'v got it working, but the problem is i dont want for the page to redirect/refresh after i press the button. So once again; after i press the button i just want it to start a python script and dont redirect to a other page or refresh the current page. Do i need to implement ajax or is there any other way? Tried some stuff with ajax but couldnt get it to work. Code: # urls.py urlpatterns = [ path('admin/', admin.site.urls), path('', include('app.urls')), path(random_string(5), views.ledOn, name = "ledikaOn"), path(random_string(5), views.ledOff, name= "ledikaOff"), # views.py def ledOn(request): s.send(ledOnUkaz.encode('ascii')) # to poslje kodo "ukaz ON" v server return render(request, 'home.html') # home.html <a class="btn btn-primary text-uppercase font-weight-bold bg-primary" href="'{% url 'ledikaOn' %}'" role="button">LED ON</a> -
How to get model name used in view from a Django request object in middleware?
I have an a django app for which I am writing middleware for. In the middleware, I have process_exception function where I have a the request object which is a WSGI Request object. I want to get the view that the request has passed through. How can I do that? If I try request.view, I get: AttributeError: 'WSGIRequest' object has no attribute 'view' -
Get reverse lookup model instances without repeating the parent model values in Django
I have the following models: class Company(BaseModel): name = models.CharField("Company Name", max_length = 200) started_date = models.DateField() class Car(BaseModel): name = models.CharField("Car Name", max_length = 200) display_name = models.CharField("Brand Display Name", max_length=200, blank=True, null=True) company = models.ForeignKey(Company, blank = True, null = True, on_delete=models.CASCADE, related_name="cars") Now if I query like this: Company.objects.filter(started_date=some_date).values('id', 'name', 'cars__name') I get: <QuerySet [{'id': 1, 'name': 'Ford', 'cars__name': 'Mustang'}, {'id': 1, 'name': 'Ford', 'cars__name': 'Shelby Mustang'}]> But I do not want the values of the Company model repeated every time because there are multiple Cars associated with a Company. I would like to get the values something like this: <QuerySet [{'id': 1, 'name': 'Ford', cars: { 'name': 'Mustang', 'name': 'Shelby Mustang'}}]> How can I do that? -
What are the different smoke testing packages available for Django? [closed]
I would like to learn what the different packages for smoke testing and health checks are available for Django. I have trying to look online but cannot find any resources. If anyone could point me in the right direction would hugely appreciate :) -
Rest API to find import file data type
I am trying to write a Django rest api to get user imported data (ex: excel, csv, json) from data source. After received an excel file need to show table data with individual column data type to html. In this project I have store the data into models but I want Input file data and data type without storing to models. I have shared a screenshot for required output. Request your suggestion. def import_data(request): if request.method == 'POST': file_format = request.POST['file-format'] employee_resource = EmployeeResource() dataset = Dataset() try: new_employees = request.FILES['importData'] except: raise if file_format == 'CSV': imported_data = dataset.load(new_employees.read().decode('utf-8'),format='csv') data = pd.read_csv(imported_data, index_col=0) datatype = data.dtypes # result = employee_resource.import_data(dataset, dry_run=True) elif file_format == 'JSON': imported_data = dataset.load(new_employees.read().decode('utf-8'),format='json') data = pd.read_json(imported_data, index_col=0) datatype = data.dtypes # result = employee_resource.import_data(dataset, dry_run=True) elif file_format == 'XLS (Excel)': imported_data = dataset.load(format='xlsx') data = pd.read_excel(imported_data, index_col=0) datatype = data.dtypes # result = employee_resource.import_data(dataset, dry_run=True) if not result.has_errors(): employee_resource.import_data(dataset, dry_run=False) return render(request, 'import.html') HTML Code: {% block content %} <h3>Import Data</h3> <p>importing to database</p> <form method="post" enctype="multipart/form-data"> {% csrf_token %} <input type="file" name="importData"> <p>Please select format of file.</p> <select name="file-format" class="form-control my-3"> <option selected>Choose format...</option> <option>CSV</option> <option>JSON</option> <option>XLS (Excel)</option> </select> <button class="btn btn-primary" type="submit">Import</button> … -
Create charts with a loop in Django with charts.js
I created a project in Django. I need charts in my project. I use chart.js library and Json. I use an API for take values. In the API page there are 5 objects.Every object has title, value1 and value2. When I create a table it works. I can get values but I cannot display values in charts. How can I create several charts with a loop? views.py def Jdeneme(request): response = requests.get('https://api....t') data = response.json() return render(request, 'charts.html', {'data': data}) charts.html {% extends "layouts/base.html" %} {% load static %} {% block content %} <div class="content"> <div class="page-inner"> <h4 class="page-title">Chart.js</h4> <div class="page-category"></div> {% for dt in data %} <div class="row"> <div class="col-md-6"> <div class="card"> <div class="card-header"> <div class="card-title">{{ dt.title }} Doughnut Chart</div> </div> <div class="card-body"> <div class="chart-container"> <canvas id="doughnutChart" style="width: 50%; height: 50%"></canvas> </div> </div> </div> </div> </div> {% endfor %} </div> </div> {% endblock content %} {% block javascripts %} <script> doughnutChart = document.getElementById('doughnutChart').getContext('2d'); var myDoughnutChart = new Chart(doughnutChart, { type: 'doughnut', data: { datasets: [ { data: [ {{ dt.value1 }}, {{ dt.value2 }} ], backgroundColor: ['#e95bda','#4bbffd'] } ], labels: [ 'value 1', 'value 2' ] }, options: { responsive: true, maintainAspectRatio: false, legend : { position: 'bottom' }, … -
How to setup calm antivirus in k8s environment and interact from a django app pod?
I am using django-clamd (https://github.com/vstoykov/django-clamd) inside my django app. The scanning works fine on my local system while uploading files and virus containing files are detected. I want to achieve the same for my app pod in kubernetes environment. Any ideas how to setup clam antivirus as a single instance(one pod per node in the cluster) in k8s so that apps deployed in different namespaces can be scanned using the clamav? I do not want to setup a separate instance of clamav for every app deloyment as a single clam av instance needs around 1 GB of RAM. -
Best way to implement a cookie consent banner in a Django project
Can someone propose a proper way of implementing a cookie consent banner in a Django project? Meaning a popup message to appear when a user visits a website. I found django-cookie-consent application as an option, has anyone tried it? Any alternatives? Thank you. Any help appreciated. -
operationalError at admin/.... at most 64 tables in a join
I am facing problem operationalError at /admin... at most 64 tables in a join. I am using sqlite db. Please see code and help me. class ReagentInventory(models.Model): company = models.ForeignKey(Company, on_delete=models.CASCADE) manufacturing_unit = models.ForeignKey( ManufacturingUnit, on_delete=models.CASCADE) ManufacturingPlant = models.ForeignKey( ManufacturingPlant, on_delete=models.CASCADE) reagent_name = models.ForeignKey(Reagent, on_delete=models.CASCADE) storage_location = models.ForeignKey( StorageLocation, on_delete=models.CASCADE) current_stock = models.DecimalField(decimal_places=3, max_digits=10, ) measuring_unit = models.ForeignKey( MeasurementUnit, on_delete=models.CASCADE) reagent_lot_no = models.CharField(max_length=20) reagent_mother_lot_no = models.CharField(max_length=20) challan_no = models.CharField(max_length=20) mother_expiry_date = models.DateField() assigned_expiry_date = models.DateField() received_date = models.DateField() opening_date = models.DateField(blank=True) number_of_container = models.IntegerField() packing_mode = models.ForeignKey(PackingMode, on_delete=models.CASCADE) manufacturing_country = models.ForeignKey( Country, on_delete=models.CASCADE) supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE) manufacturer = models.ForeignKey(Manufacturer, on_delete=models.CASCADE) class Meta: verbose_name_plural = 'Reagent Inventories' def __str__(self): return self.reagent_name def __unicode__(self): return self.reagent_name Thanks -
How to insert a class in a HTML element iteratively based on a range of values
When a given page loads with a table, which is created iteratively with a for loop and a context variable, I want to change the font color of the values in a row depending in which range they are from 0 to 100%. Right now I am doing a bunch of if statements for comparison but I am looking for a better solution with javascript. This is how I am doing {% if value == 'n/a' %} <td class="class0">{{ value }}</td> {% elif similarity <= 25 %} <td class="class1">{{ value }}%</td> {% elif similarity <= 50 %} <td class="class2">{{ value }}%</td> {% elif similarity <= 75 %} <td class="class3">{{ value }}%</td> {% elif similarity <= 100 %} <td class="class4">{{ value }}%</td> {% endif %} And the class0 to class4 are the classes I am trying to insert. -
Django ImageField null=True doesn't make blank field equal to NULL
I have a model with this field: carousel_image = models.ImageField(upload_to='news/%Y/%m/%d, null=True, blank=True) I was wondering why exclude(carousel_image__isnull=True) and other queries that check if field is or isn't null aren't working. I checked my sqlite3 db and received this: sqlite> select carousel_image from asgeos_site_news; news/2020/12/23/index.jpeg news/2020/12/23/gradient-1.jpeg ( 3 blank lines ) I also tried adding WHERE carousel_image = NULL and it returned nothing. Why my images are not null? They're just a blank lines. I have to use carousel_image__exact='' to exclude them right now. -
open redirect bug in django 2.2 on chrome browser?
I have a url which is supposed to do the redirects to the allowed hosts only after login. but when I am tying to login using https://example.com/login/?redirect_to=/%09/stackoverflow.com which checks the condition of allowed urls to be redirected using is_safe_url https://github.com/django/django/blob/2.2.17/django/utils/http.py#L295 it is redirecting me to stackoverflow which it should not. And this is happening only in chrome. Here :https://github.com/django/django/blob/2.2.17/django/utils/http.py#L386 it checks for the Control characters but it doesn't seem to work (%09 is a control character) -
How to deploy reactjs and django webpack in azure webapp
I used ReactJS web-pack for frontend and Django django-webpack-loader . It is working fine in localhost. But when I reployed into production index page {% render_bundle 'main' %} bundle.js file showing html code only. So I'm getting uncaught syntaxerror unexpected token <. -
How to run makemigrations for dockerized django app
I have been trying to setup a django app using this guide: https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/ And it was a great resource to get everything up and running. However i have problem now when it comes to migrations. Say i add a model, add data into my db, and later i change the model. Now i can run makemigrations using the exec method on the container, but when i shut down my migrations are not stored in my local files i save to my git project, instead they are lost as i spin down the container. Does anyone know how to solve this, how do you makemigrations is such a setup where you run two dockerized django/postgres dev/prod environments?