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
2
votes
2 answers

Can't login into admin URL on production with Django 4

Can't seem to login into Django admin URL on my production but it works fine on my local. For context, currently my site does not have SSL. Debug is set to False as well. This was working prior to Django 4 upgrade (was previously on Django…
6ixpaths
  • 21
  • 1
  • 4
2
votes
1 answer

Django how to include all columns from one table, but a only subset of columns in a different table, using tbl.only?

I want to join a child table to the parent table, and return all columns from the child table (child.*), but only specific columns from a parent table (parent.foo, parent.bar), using only but not defer. Is there any syntax to issue a SQL similar to…
Matthew Moisen
  • 16,701
  • 27
  • 128
  • 231
1
vote
2 answers

Django admin show only current user for User field as ForeignKey while creating and object

I'm working on a Django ( 4.0 +) project, where I have a model named Post in which we have a ForignKey field as Author, a user with is_staff and in Authors group can create an object of Post from admin. Now the problem is when user click on Add Post…
Abdul Rehman
  • 5,326
  • 9
  • 77
  • 150
1
vote
2 answers

Django: Add is_staff permission to user inside view based on a condition

I'm working on a Django (4.0+) project,, where I'm using the default User model for login, and a custom form for signup, and I have a Boolean field named: blogger in signup form, if user check this, i have to set is_staff true, otherwise it goes as…
Abdul Rehman
  • 5,326
  • 9
  • 77
  • 150
1
vote
1 answer

How to access the names of fields in Django UniqueConstraint?

Accepted answer for original question. Still not OK for "edit 1" (below) Original Question I want to access the field names when declared in Meta class : class Book(models.Model): name = CharField(...) author = CharField(...) class…
cedrik
  • 541
  • 7
  • 17
1
vote
1 answer

Implementing Custom TokenBackend for rest_framework_simplejwt

I am migrating our Django code that uses djangorestframework-jwt to the latest version of djangorestframework-simplejwt(5.2.2) in Django 4.0.8. I am having an issue while trying to verify the token. The issue is because of the fact that our pem file…
1
vote
0 answers

I want test the post method by django

I created a "Like" function that works properly. good. good. good. # a test file from django.test import TestCase from django.urls import reverse from register.models import User from vietnam_research.models import Articles, Likes class…
yoshitaka okada
  • 113
  • 1
  • 12
1
vote
0 answers

How to solve CSRF verification faileld?

Request aborted. Help Reason given for failure: Origin checking failed - https://teamsparrowpp-qrgen-production 6a43.up.railway.app does not match any trusted origins. I have
{% csrf_token %} on my html. I have tried adding on…
1
vote
1 answer

the method form.is_valid always returns always

I do my own project and I'm stuck on this problem. My form always returns False when calling form.is_valid. This is my code: forms.py: I need to let user to choose the size he need from the list of available sizes, so I retrieve sizes from the…
pizhlo
  • 107
  • 6
1
vote
1 answer

What does it mean "to=" when creating model field in django?

Are those tree ways giving the same result/field, is there any other way? class Message(models.Model): user = models.ForeignKey(to=User) user = models.ForeignKey(User) user = models.ForeignKey("User")
kubaSpolsky
  • 357
  • 2
  • 10
1
vote
1 answer

How to render model a single row text area for TextField in django admin form

I have a Django 4.0 model that includes some TextField fields. These are displayed in large text box in the corresponding admin form. How do I reduce the displayed size of a text field in a django admin form, e.g. to just one row? I have tried…
anon_dcs3spp
  • 2,342
  • 2
  • 28
  • 62
1
vote
2 answers

Django generic.UpdateView NOT updating values upon successful POST

Below I am trying to update a specific form (OrganizationForm): Template is Rendering with the form fields and existing values in the fields. Upon Submission of the form the POST request is successful. ISSUE: The changes are not being saved to the…
1
vote
0 answers

In Django, how to get the amount of space used by each user?

I have a site where users send emails and I want to know how many megabytes of memory used by each user, how can I get this?
user18556740
  • 57
  • 1
  • 4
1
vote
0 answers

how to use django redirect when we have dynamic url

i have dynamic uls urlpatterns=[path('author//',views.authorview,name='author')]` and i want to use it in redirect def authorview(request,pk): user=User.objects.get(id=pk) a=Blogmodel.objects.filter(author=pk) …
1
vote
1 answer

Upgrade to Django 4.0 has caused tests to fail even when the feature being tested works

A bit of an odd one. I've upgraded from Django 3.2 to 4.0. A lot of my tests fail and they all fail where I'm testing the result of a form submission. However the forms themselves work fine when I test them using my browser. And all the tests fail…
rcx935
  • 217
  • 5
  • 15