Questions tagged [django-4.0]

Django 4.0 is a version of the Django framework, released in December 2021. Please only use this tag if your question relates specifically to this version.

Django 4.0 works with Python 3.8, 3.9, and 3.10.

Here are some of the salient features of Django 4.0:

Django 4.0 was released in December 2021 and was supported until April 2023.

88 questions
0
votes
0 answers

Is there any binding to declare a variable characters length in Django?

I am going to declare variable or function name around 50 characters strings. Is it okay to declare in this way in Django? Or it may arise any error in future? budgeted_cost_sheet_fabric_summary_obj_kg_consumption = 1.123 or def…
0
votes
1 answer

How to create a zip with multiple files from one folder and send it to the browser in modern Django

I was struggling with sending the downloadable Django zip with many files to browser, because many tutorials in the web are obsolete, like the one which was my inspiration to come up with what I will share with you: Django - Create A Zip of Multiple…
Swantewit
  • 966
  • 1
  • 7
  • 19
0
votes
0 answers

Performing multiple queries on Many to Many Field Django

My main models look like this, class BusStation(models.Model): name = models.CharField() location = models.CharField() class Bus(models.Model): name = models.CharField() routes = models.ManyToManyField(BusStation) If a user intends…
0
votes
0 answers

How to generate plaintext files from an HTML template?

Getting plaintext files from an HTML template using python code. Like Django, using jinja templating from the jinja2 library to display data parsed into the context from the view function. I'll like to know all the different ways in which I can get…
0
votes
1 answer

Apple SSO breaks after Django 4 upgrade

After upgrading from django 3 to django 4, the "Sign in with Apple" feature started breaking with the following error Your request could not be completed because of an error. Please try again later. The javascript, the frontend html, and the…
wonton
  • 7,568
  • 9
  • 56
  • 93
0
votes
1 answer

Why Django 4.0 can access static files only with STATICFILES_DIRS, not STATIC_ROOT

When I use STATIC_ROOT: STATIC_ROOT = BASE_DIR / 'static' Django cannot access static files and always return 404 error for them. But when I use STATICFILES_DIRS: STATICFILES_DIRS = [ BASE_DIR / "static", ] Everything works well. What's the…
0
votes
1 answer
0
votes
1 answer

django-import-export - Export one to many relationship with ForeignKeyWidget - returns an empty Field

I am trying to use the dajngo-import-export package to export data from two tables with a one to many relationship. I have a custom ForeignKeyWidget class that overrides the get_queryset method. The problem is that the export returns an empty field…
stevec
  • 155
  • 1
  • 3
  • 10
0
votes
0 answers

django 4 template output from db entries

in models.py from django.db import models class TimeItem(models.Model): WEEKDAYS = [ (0, _("Monday")), (1, _("Tuesday")), (2, _("Wednesday")), (3, _("Thursday")), (4, _("Friday")), (5,…
Ping
  • 3
  • 2
0
votes
1 answer

Django 4: settings.DEBUG not correct when running tests

I am trying to write a Django (4) test. It has to work differently depending on the DEBUG constant in my settings.py. So I started with something like: def my_test(self): from django.conf import settings if settings.DEBUG: .... …
Alfonso_MA
  • 537
  • 5
  • 26
0
votes
1 answer

CSRF token issue when upgrading Django to version 4.*

I was using the Django version 3, but then upgraded it to Django version 4(django==4.0.6). After logging to admin panel of Django project, it said that CSRF token is invalid. I found this link in Django documentation and tried to put such variable…
0
votes
2 answers

How to make Django messages framework play nicely with i18n?

Using django 4.0.6 I was using the messages framework to display messages when users successfully completed a form. Then I added i18n: When the default language is selected, messages are shown on the second screen after the form is submitted, not…
John
  • 949
  • 1
  • 9
  • 20
0
votes
0 answers

Django AppRegistryNotReady when running another multiprocessing.Process

Problem I needed to run multiple UDP servers on different ports that exchange data with a Django core, so I defined a Django command which calls a method (start_udp_core) that runs each UDP server in a separate process. I used socketserver.UDPServer…
Rooz
  • 21
  • 3
0
votes
1 answer

Populating choices from another Models objects

Quick question, I can not for the life of me figure out how to get this to work and need some help. Problem I need to be able to query another model's objects to use for choices in a different model. I was thinking about a foreign key but I really…
0
votes
1 answer

django social all auth - multiple user type

I have two Registration pages: Register as Buyer, Register as Seller. on both Pages , I've included Normal Registration and social authentication using Google and Facebook. I've added social authentication using Django all-auth, but cannot get…
devng2728
  • 3
  • 2