Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Dynamic action URL in Django Template
I have a form in Django and would like to add the correct id at the end of the URL. I am not sure how to add the ID at the end dynamically however. Here's some example code. {% for dealer_payment_account in dealer.dealerpaymentaccount_set.all %} <p>Account: {{ dealer_payment_account.last_4_digits }}</p> <form id="verifyDealerBankAccountForm" action="/verify-dealer-payment-account/{{ dealer_payment_account.id }}" method="POST"> <div class="form-row"> <label>Payment</label> <input type="text" name="amount"> </div> <button type="submit">Submit</button> </form> {% endfor %} Specifically I am wondering how to format this: action="/verify-dealer-payment-account/{{ dealer_payment_account.id }}" so that I can add the dealer_payment_accound.id to the end of each form. -
'django_extensions' 'show_urls' closes within a blink of a second
I use Django extensions as shown here: Django : How can I see a list of urlpatterns? to get a list of exposed urls. I'm on win 10. Cmd.exe opens and closes immediatly. With a highspeed cam i could figure out that whats written in the cmd.exe makes senes. How can I prevent cmd.exe from closing by auto. -
how can i invalidate page cache in django
How can I invalidate page cache in django. I am trying to cache a page displays a list that is unique for each user using django-rest-framework. I can not figure out how to invalidate the page cache when the another object is added, updated, deleted from the model. I am open to using an external package or signals. I don't know what the key is for @page_cache to invalidate the cache I have tried to use django-fancy-cache but I just get an error unsupported operand type(s) for +: 'float' and 'function' my cache settings CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': 'unique-snowflake', } } -
Pushing Django app to Docker Container failing
I've been trying to push my django app to a Docker container but i keep getting the error below and i dont quite understand what it all means. executor failed running [/bin/sh -c bash -c "diff -u0 <(sed -e 's, *#.*,,' -e '/^$/'d /tmp/app/requirements.txt | sort -f) <(pip3 freeze | sort -f)"]: exit code: 1 ERROR: Service 'website' failed to build : Build failed Thanks -
Test case for using ForeignKey in multiple databases in Django
In Django, if I specify the key of another scheme's Model as the ForeignKey, I can usually get the object of the ForeignKey automatically. However, why do I get the following error only in testcase? I can find id, but can't get object. Environment is Django3.0 Postgresql12. django/db/models/query.py", line 417, in get self.model._meta.object_name I tried some solutions. But, I'm still facing the error... from django.test import TestCase TestCase.databases = {'default', 'another_db'} databases = '__all__' multi_db = True -
Preload FK relation in different column Django
I have Django models that looks like this class Customer(models.Model): name = models.CharField(_("Name")) class Feature(models.Model): label = models.CharField(_("Name")) class AddOn(models.Model): customer = models.ForeignKey(Customer) feature = models.ForeignKey(Feature) Given that I have an instance of Customer e.g customer = Customer.objects.get(pk=1) How do I get all the labels in feature in one query to avoid N+1 query? For now what I've done is: [addon.feature.label for addon in self.addon_set.all()] But I think for each addon.feature will create a query that is not very optimized if there is a lot of addon -
smart way to "break" for loops when iterating
I want to iterate over a list of items and put them in a table, but I want the table to break after x items. I am using bootstrap5 to format my table. I want to display the following dict as table: {'store_6': [ProductData(id=1516004, stat=0), ProductData(id=1516028, stat=2)]} {'store_3': [ProductData(id=590418, stat=5), ProductData(id=590422, stat=1), ProductData(id=590423, stat=1), ProductData(id=590424, stat=2), ProductData(id=590425, stat=0), ProductData(id=590427, stat=4), ProductData(id=590432, stat=0)), ProductData(id=1590418, stat=0), ProductData(id=1590422, stat=0), ProductData(id=1590423, stat=0), ProductData(id=1590424, stat=0), ProductData(id=1590425, stat=0), ProductData(id=1590427, stat=2), ProductData(id=1590432, stat=0)), ProductData(id=1690418, stat=0), ProductData(id=1690422, stat=0), ProductData(id=1690423, stat=1), ProductData(id=1690424, stat=3), ProductData(id=1560425, stat=0), ProductData(id=1690427, stat=5), ProductData(id=1690432, stat=0))]} I want to have a table like this: where every row starts with the store name and then uses one column for every product. If a store has more than 10 products, the first column is blank. There cannot be more than 32 products. I have a working solution, but it looks ... quirksy: {% for store_number, products in all_store_data.items %} {% for device in products %} {% if forloop.first %} <tr> <td class="col-sm-2">{{ store_number }}</td> {% endif %} {% if forloop.counter == 11 or forloop.counter == 21 or forloop.counter == 31 %} <tr> <td class="col-sm-2"></td> {% endif %} <td class="col-sm-1"> {{ device.id }} </td> {% if forloop.last %} {% … -
I tried to install django using pip install django but still i am getting this error any comments
from django.core.management import execute_from_command_line ModuleNotFoundError: No module named 'django' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\emin\Desktop\fliteplan\gen_angular\arinc_424_19_db\multi\src\manage.py", line 22, in main() File "C:\Users\emin\Desktop\fliteplan\gen_angular\arinc_424_19_db\multi\src\manage.py", line 13, in main raise ImportError( ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment? -
Sorl-Thumbnail not appearing
Firstly i'm very much a beginner and learning Django, but I just cannot get Sorl-Thumbnail to work in the Gallery aspects of a photography site I am developing. The site is in development and DEBUG = True, all installs went well including dependencies as far as I can see. 'sorl.thumbnail', is added to apps and migrations have gone through. I am using is to generate thumbnail within a template for loop to generate my galleries. But I get broken thumbnails for each image objects. On inspecting i get a tag img tag <img src="/media/cache/5c/58/5c58ba75425e372e94b739e292690b85.jpg"> All other images work in Admin, and on the rest of the site. I've checked MEDIA_URL but this seems ok. I cannot see a cache folder within my media folder though, does sorl generate one? I've changed my model so it is using the Sorl-Thumnail imagefield, but this didn'd achieve anything, I have THUMBNAIL_DEBUG = True in setting but this is not giving me anything in terminal. {% for img in album.images %} {% thumbnail img "100x100" crop="center" as im %} <img src="{{ im.url }}"> {% empty %} -
What is the correct method to link a homepage to multiple views in a django app
As the titles, I'm looking for the correct way to "link" views to a homepage, so whenever I press one of the buttons in the homepage, it will redirect me to a view related to a form. Right now my django app is composed by multiple views where each one of them are forms that have their own .html but I'm having a hard time to understand or find a way to make a homepage where I have links to specific views and whenever I press the submit button inside the respective form, it would redirect me to the homepage. I was thinking that the correct way to do it was making a new view that will take the role of my "homepage" but I don't know if its possible to have multiple views related to the same view Note: I understand that coding an example for this would take a while, I am just making this question so I can get a better idea and start looking in right the direction -
Django - Testing a view name retrieved from a url parameter ie. ref=home
Simply put, I am trying to test a view name, captured from a URL parameter, within one of my view functions to see if it is valid. If not, to redirect to another page. For example, take this url... www.site.com/users/?ref=view_name Then in my view ref = request.GET.get('ref', None) return redirect(ref) if ref else redirect('users') The problem is, of course, that if a user alters the ref parameter, it will kick back a 404. I was hoping to be able to test if ref=home is a valid view and return it, if not then redirect to another view. I have been messing with Django's resolve and reverse but I am not getting the results I was looking for. I also tried to use a try/finally in all sorts of ways mixed in with resolve and reverse. Yeah, dumb...I know. try: if ref: return redirect(resolve(ref)) finally: return redirect('user') I have searched for almost two hours to try to fund a succinct way to do this. Any help would be appreciated! -
Kendo Grid Datasource binding from Django Views
I am new in Django and I am trying to bind queryset from my Django model to Kendo Grid datasource. Kendo Grid displays but data is not loaded. return render is getting data as dictionary so I tried to use JsonResponse but it just renders Json string in a blank page. How I can succesfully load the grid with JSON data ? Here is what I have done so far: models.py class FromClientTransmittal (models.Model): transmittal_no = models.CharField(max_length=255) document_no = models.CharField(max_length=255) rev = models.CharField(max_length=20) subject = models.TextField() client_response = models.CharField(max_length=20) def __str__(self): return self.document_no project urls.py urlpatterns = [path('components/',include('components.urls',namespace='components')),] app urls.py from django.urls import path from components import views app_name ='components' urlpatterns = [ # Transmittals path('tables/from-client-transmittal',views.FromClientTransmittalView.as_view(),name='from-client-transmittal'),] views.py class FromClientTransmittalView(LoginRequiredMixin,View): def get(self,request): transmittals_qs = FromClientTransmittal.objects.all().values("transmittal_no","document_no","rev","client_response") transmittals = list(transmittals_qs) data={} data['title'] = "From Client Transmittals" data['pageview'] = "Transmittals" data['transmittals'] = transmittals return render(request,'components/tables/from-client-transmittal.html', data) template (html) {% extends 'partials/base.html' %} {% load static %} {% block kendojs %} <script src="https://kendo.cdn.telerik.com/2022.1.119/js/jquery.min.js"></script> <script src="https://kendo.cdn.telerik.com/2022.1.119/js/kendo.all.min.js"></script> {% endblock kendojs %} {% block extra_css %} <link href="https://fonts.googleapis.com/css2?family=Lato&display=swap" rel="stylesheet" /> <link href="https://cdn.kendostatic.com/2022.1.119/styles/kendo.common.min.css" rel="stylesheet" /> <link href="https://kendo.cdn.telerik.com/2022.1.119/styles/kendo.default.min.css" rel="stylesheet" /> <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2022.1.119/styles/kendo.default.mobile.min.css" /> {% endblock extra_css %} {% block content %} <div id="fbt-grid"></div> <script> $(document).ready(function () { var dataSourceArguments … -
How can I add a class to a particular inline row based on the date recorded in a field of the row?
I have an inline model DayOff where I would like to gray out the entire row if the date entered on the DayOff object is a past date. Any idea how to add a class or styling to an entire row, based on the date field recorded in it? -
Running Django makemigrations Docker container
I have two Docker containers, one for MySQL and one for Django. I modify a model that requires a migration, and therefore the need to run makemigrations: what do I do such that I end up with a 000X_stuff.py file on my local drive that, when I fire up the Django container and it runs the migration action, the migration occurs? The only option that comes to mind is to run docker exec -it CONTAINER_NAME python ./manage.py makemigrations APP_NAME. Two problems with this: It only works the first time. Successive reruns of makemigrations claim there are no changes. The only way to overcome this is to drop the table and the appropriate row in the migrations table. If any Python migration files are generated, they are generated within the container. I would have to copy them manually from container to host if I want to commit them. -
Django wsgi.py can't initialize the settings module: "ModuleNotFoundError: No module named 'config'"
My Django dev environment runs fine with the native server, but when I try to execute wsgi.py, either locally or on the production server, I get the extremely popular ModuleNotFoundError: No module named 'config' error. The traceback suggests that the failure happens when django/core/wsgi.py attempts to execute django.setup(set_prefix=False) and that method needs to call settings.[ANYTHING], in this case configure_logging(settings.LOGGING_CONFIG, settings.LOGGING). Calling the settings.LOGGING_CONFIG variable tells django.conf.settings to initialize, but in this context it fails: Traceback (most recent call last): File "./config/wsgi.py", line 35, in <module> application = get_wsgi_application() File "C:\...\anaconda\envs\venvname\lib\site-packages\django\core\wsgi.py", line 12, in get_wsgi_application django.setup(set_prefix=False) File "C:\...\anaconda\envs\venvname\lib\site-packages\django\__init__.py", line 18, in setup configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) File "C:\...\anaconda\envs\venvname\lib\site-packages\django\conf\__init__.py", line 82, in __getattr__ self._setup(name) File "C:\...\anaconda\envs\venvname\lib\site-packages\django\conf\__init__.py", line 69, in _setup self._wrapped = Settings(settings_module) File "C:\...\anaconda\envs\venvname\lib\site-packages\django\conf\__init__.py", line 170, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "C:\...\anaconda\envs\venvname\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 1014, in … -
Django : can't login in django administration
First of all, I've created a User model, which inherits from AbstractUser. I use another model which is called CustomUserManager (which inherits from UserManager). In CustomUserManager, i rewrote the create_user method, and the create_superuser method. When i create a simple active user, it works fine (i can connect the user). When i create a superuser, it works fine ("Superuser created successfully") BUT when i go to the django administration pannel, and i enter the correct information of the superuser, it doesn't work and display the following message : "Please enter the correct email and password for a staff account. Note that both fields may be case-sensitive. " Here's my models.py : class CustomUserManager(UserManager): def _create_user(self,email,password,first_name,last_name,**extra_fields): email = self.normalize_email(email) user = User(email=email) user.is_active=True user.password = make_password(password) user.save(using=self._db) return user def create_user(self,email,password,first_name,last_name,**extra_fields): return self._create_user(email,password,first_name,last_name,**extra_fields) def create_superuser(self,email,password,first_name,last_name,**extra_fields): """ Create and save a SuperUser with the given email and password. """ extra_fields.setdefault('is_staff', True) extra_fields.setdefault('is_superuser', True) extra_fields.setdefault('is_active',True) if extra_fields.get('is_staff') is not True: raise ValueError('Superuser must have is_staff=True.') if extra_fields.get('is_superuser') is not True: raise ValueError('Superuser must have is_superuser=True.') return self.create_user(email,password,first_name, last_name, **extra_fields) class User(AbstractUser): username = None email = models.EmailField(unique=True, blank=False) first_name = models.CharField(blank=False,max_length=50) last_name = models.CharField(blank=False,max_length=50) REQUIRED_FIELDS=["first_name","last_name"] USERNAME_FIELD = 'email' objects = CustomUserManager() -
ValueError at /testimonials/ The view resort.views.ReviewsView didn't return an HttpResponse object. It returned None instead
"""Renders web pages for the reviews and reviews form.""" from django.shortcuts import render, redirect, get_object_or_404 from .models import * from django.views import View from .forms import * from django.views.generic import ListView, DetailView from django.http import HttpResponseRedirect, HttpResponse from django.core.mail import send_mail, BadHeaderError from django.contrib import messages class ReviewsView(ListView, View): template_name = "resort/testimonial.html" model = Review form = ReviewForm def post(self, request, *args, **kwargs): """Renders the form and creates an instance.""" form = ReviewForm(request.POST) if form.is_valid(): review = Review.clean_fields() form.instance.name = request.name form.instance.review = review form.save_m2m() return redirect('reviews') def get_context_data(self, **kwargs): """load data into thecontext dictionary to be rendered on the page.""" context = super().get_context_data(**kwargs) context.update({ 'form': self.form, }) return context -
Authorization between services Django and NodeJs
I'm building an app using React on the frontend and Django and Nodejs on the backend. On the Django side I store the users and user authorization. Right now I'm using django-rest-knox to generate the user token, but the problem is that if I make a request to Nodejs service I cannot decrypt the token there. I must to make another request to Django service to verify the token. A solution would be to use JWT Token. But the JWT Token is not stored to database ( I cannot change the expiration type per individual token) I somebody here that faced the same problem like me or can give me an advice ? -
How to use insomnia with django?
running django locally and with firefox, i login with http://localhost:8000/admin/ and after that i can access http://localhost:8000/myCustomApi successfully. on insomnia every time i login with 8080/admin/ i get {"code": "csrf", "reason": "CSRF cookie not set."} on the response. i tried this but didn't work. is there any tutorial to what should a do? -
Trouble rendering form in Django
I cannot get the "quote_form" to render in the post_detail template. The form is intended to write data to the quote model that will include the post id of the post object. Please let me know if more details are needed. Thank you in advance! views.py: model = Post def post_data(request, post): post = get_object_or_404(Post, slug=post) seller_quote = None if request.method == 'POST': quote_form = NewQuoteForm(request.POST) if quote_form.is_valid(): seller_quote = quote_form.save(commit=False) seller_quote.post = post seller_quote.save() return HttpResponseRedirect('/' + post.slug) else: quote_form = NewQuoteForm() context = {'quote_form': quote_form} return render(request, "post/post_detail.html", context) forms.py: from quote.models import Quote class NewQuoteForm(forms.ModelForm): class Meta: model = Quote fields = ('title','content') template: {% extends "post/base.html" %} {% block content %} <article class="media content-section"> <img class="rounded-circle article-img" {{ object.author.profile.image.url }}></img> <div class="media-body"> <div class="article-metadata"> <a class="mr-2" href="{% url 'user-posts' object.author.username %}">{{ object.author }}</a> <small class="text-muted">{{ object.date_posted }}</small> {% if object.author == user %} <div> <a class= "btn btn-secondary btn-sm mt-1 mb-1" href="{% url 'post-update' object.id %}">Update</a> <a class= "btn btn-danger btn-sm mt-1 mb-1" href="{% url 'post-delete' object.id %}">Delete</a> </div> {% endif %} </div> <h2 class="article-title"> {{ object.title }}</h2> <p class="article-content">{{ object.content }}</p> </div> <div> </div> <div> <form id="myForm" method="post"> {{ quote_form.as_p }} </form> </div> </article> {% … -
Grab contents of FormFields and display on same page in django class-based views
I want to make a calculation using a FormView as input. The result should be displayed on the same page where the form is located. This is what I have so far: urls.py in the 'capsules'-app: from django.urls import path from . import views app_name = 'capsules' urlpatterns = [ path('functions/', views.CapsulesFunctionsView.as_view(), name='functions'), path('uniformity/', views.CapsulesUniformityOfMassView.as_view(), name='uniformity'), ] forms.py: from django import forms class CapsulesUniformityOfMass(forms.Form): mass_1_caps_empty = forms.FloatField(label='Mass of 1 empty capsules [g]') mass_20_caps_full = forms.FloatField(label='Mass of 20 full capsules [g]') mass_max1 = forms.FloatField(label='Mass of heaviest capsule [g]') mass_min1 = forms.FloatField(label='Mass of lightest capsule [g]') models.py is empty, since I do not want to save the contents to the database views.py: from django.views.generic import TemplateView from .forms import CapsulesUniformityOfMass from django.views.generic.edit import FormView # Create your views here. #View for Capsules class CapsulesFunctionsView(TemplateView): template_name = 'capsules/functions.html' # Create your views here. class CapsulesUniformityOfMassView(FormView): template_name = 'capsules/uniformity.html' form_class = CapsulesUniformityOfMass success_url = 'result' def form_valid(self, form): mass_1_caps_empty = form.cleaned_data['mass_1_caps_empty'] mass_20_caps_full = form.cleaned_data['mass_20_caps_full'] mass_max1 = form.cleaned_data['mass_max1'] mass_min1 = form.cleaned_data['mass_min1'] mean_content = mass_20_caps_full/20 - mass_1_caps_empty if mean_content <= 0.3: diff = 0.1 else: diff = 0.15 upper1 = mean_content*(1+diff) upper2 = mean_content*(1+2*diff) lower1 = mean_content*(1-diff) lower2 = mean_content*(1-2*diff) return super().form_valid(form) class ResultView(TemplateView): template_name = … -
What is the websocket url of my AWS EC2 Instance?
I have successfully implemented a chat system using Django Channels. I am trying to deploy it to my EC2 Instance. I am reading the official channels documentation and also following other tutorials. Before daemonising daphne and adding a proxy pass. I wanted to run it manually so I ran the following command. $ daphne -b 0.0.0.0 -p 5000 instagram.asgi:application INFO Starting server at tcp:port=5000:interface=0.0.0.0 INFO HTTP/2 support not enabled (install the http2 and tls Twisted extras) INFO Configuring endpoint tcp:port=5000:interface=0.0.0.0 INFO Listening on TCP address 0.0.0.0:5000 # chat/routing.py from django.urls import re_path from . import consumers websocket_urlpatterns = [ re_path(r'^ws/chat/(?P<room_name>[\w-]+)/', consumers.ChatConsumer.as_asgi()), ] #asgi.py """ ASGI config for instagram project. It exposes the ASGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/ """ import os from channels.routing import ProtocolTypeRouter, URLRouter from django.core.asgi import get_asgi_application import chat.routing from instagram.ChatJWTAuth import JWTAuthMiddleware os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'instagram.settings') application = ProtocolTypeRouter({ "http": get_asgi_application(), "websocket": JWTAuthMiddleware( URLRouter( chat.routing.websocket_urlpatterns ) ), }) -
group by week for each year in django
I did find this comment from @HenryHeikkinen very usefull How to group by week in postgresql So I did correct my code. But still it is not ok. I did find some situation when it is not working correctly. When year is chaning during first week. My data model keeps some value for each day in year. I want to group data by week and compare several years. year 2018 is interesting 1.1.2018 is monday so first week of 2018 start at that day. last week of 2018 is 52 and starting at 24.12.2018 31.12.2018 is monday next week, but it is first week of 2019 and thats OK. But grouping by week, the result for that week (week 1 of year 2019) has week date = 31.12.2018, so extracting year info from that gives 2018 instead 2019 and thats make duplicity for week 1 of 2018. Year 2019 has that problem at beging and at the end. Week 1 of 2019 start at 31.12.2018 Week 1 of 2020 start at 30.12.2019 here is my django code which return week data self.dataday_set.annotate(ww=TruncWeek('date')) \ .values('ww') \ .annotate(consumption=Sum('consumption'), amount=Max('amount'), w=ExtractWeek('ww'), r=ExtractYear('ww')) \ .order_by('-ww') here is output section between 2017 and 2018, which … -
Getting an Error in starting gunicorn on ubuntu virtual machine on azure
when i run sudo systemctl status gunicorn i get this Active: failed (Result: exit-code) since Mon 2022-01-24 20:00:09 UTC; 25min ago TriggeredBy: ● gunicorn.socket Process: 6889 ExecStart=/home/yawar/django_folder/myenv/bin/gunicorn --access-logfile - -- workers 3 --bind unix:/run/gunicorn.sock route_pro.wsgi:application (code=exited, status> Main PID: 6889 (code=exited, status=4) Jan 24 20:00:09 XPO gunicorn[6889]: [2022-01-24 20:00:09 +0000] [6889] [INFO] Starting gunicorn 20.1.0 Jan 24 20:00:09 XPO gunicorn[6889]: [2022-01-24 20:00:09 +0000] [6889] [INFO] Listening at: unix:/run/gunicorn.sock (6889) Jan 24 20:00:09 XPO gunicorn[6889]: [2022-01-24 20:00:09 +0000] [6889] [INFO] Using worker: sync Jan 24 20:00:09 XPO gunicorn[6891]: [2022-01-24 20:00:09 +0000] [6891] [INFO] Booting worker with pid: 6891 Jan 24 20:00:09 XPO gunicorn[6891]: Failed to find attribute 'application' in 'workers'. Jan 24 20:00:09 XPO gunicorn[6891]: [2022-01-24 20:00:09 +0000] [6891] [INFO] Worker exiting (pid: 6891) Jan 24 20:00:09 XPO gunicorn[6889]: [2022-01-24 20:00:09 +0000] [6889] [INFO] Shutting down: Master Jan 24 20:00:09 XPO gunicorn[6889]: [2022-01-24 20:00:09 +0000] [6889] [INFO] Reason: App failed to load. Jan 24 20:00:09 XPO systemd[1]: gunicorn.service: Main process exited, code=exited, status=4/NOPERMISSION Jan 24 20:00:09 XPO systemd[1]: gunicorn.service: Failed with result 'exit-code'. lines 1-17/17 (END) what could I be doing wrong , and before that it was throwing a error like no module named workers found so i ran pip3 … -
Running Django migrations within Docker container
Getting Django migrations to work within a Docker container has been tricky. Currently I spin up a MySQL container, then run ./manage.py makemigrations && ./manage.py migrate within wsgi-endpoint.sh to generate the SQL and apply it. I'm not fond of this workflow because there's no SQL paper trail to commit: any SQL created lives and dies within the container. I can't run makemigrations locally, though, because the database is containerized too. What's the best way to generate these files locally, or fetch them from the container? I realize I can copy them manually from container to host, but doing that after every database change is pretty rough.