Questions tagged [django-2.2]

Django 2.2 is a version of the Django framework, released April 2019. It is a Long Term Support (LTS) release, and will be supported until at least April 2022. Please only use this tag if your question relates specifically to this version.

Django 2.2 works with Python 3.5, 3.6, 3.7, 3.8, and 3.9.

release notes

261 questions
2
votes
0 answers

Django Concat cannot be used in AddConstraint

I have a constraint like this CheckConstraint( check=Q(full_path__endswith=Concat(Value("/"), F("identifier"), Value("/"))) # | Q(full_path="/"), name="path_endswith_identifier_if_not_root", ), Makemigrations runs fine, but when I try…
Pinna_be
  • 4,517
  • 2
  • 18
  • 34
2
votes
2 answers

Django template for loop is empty

I am trying to build a detail view in django, but nothing is displayed in the template. views.py class MyDetailView(DetailView): model = Article template_name = 'detail.html' detail.html {% extends 'base.html' %} {% load i18n %} {% endblock…
Snowball
  • 35
  • 5
2
votes
1 answer

Django get count of nested related object

I'm using Django 2.2 I have three models class LeadList(SafeDeleteModel): user = models.ForeignKey(User, on_delete=models.CASCADE) name = models.CharField(max_length=128, verbose_name='Lead List Name') def entries_count(self): …
Anuj TBE
  • 9,198
  • 27
  • 136
  • 285
2
votes
1 answer

How to load an instance in class based views using form_valid

I'm trying to build a form that automatically fills some fields in a class based create view that lets logged in users create a Job. However, I can't seem to find the correct way of doing this for fields that aren't the user (eg. request.user). So…
S.Hefer
  • 91
  • 1
  • 2
  • 9
2
votes
1 answer

How to automatically delete records from database after a specific time in Django

I have a model named 'Complaint' with numerous entries and I want to delete the entry if it is in database for more than 3 days. How can I do that is there any query for specifying the time. I'm also storing the time at which the entry was stored.…
Nouman Javed
  • 129
  • 1
  • 1
  • 13
2
votes
1 answer

Django Url Path for web app is duplicated. Can't figure out how it is doing that

I ran into a issue with my URL patterns in Django 2.2.5. I cannot navigate to the proper URL patterns for my apps. When I run my server I able to navigate to the base url ":8000/" as defined in APP1/url.py and views.py. When I enter :8000/signin I…
2
votes
0 answers

ListView and DetailView in Django

I have 4 categories on my site. How can I write one class PageViews(ListView) for four same pages with different posts. And same question, how to write class DeteilViews(DetailView) for each posts? My models below. class Category(models.Model): …
Alexxx
  • 49
  • 3
2
votes
2 answers

How to solve TypeError: create_superuser() got an unexpected keyword argument 'paid' in django

I am implementing custom user model extending AbstractBaseUser. Here is my account/models.py file. from django.db import models from django.contrib.auth.models import ( BaseUserManager, AbstractBaseUser ) class…
2
votes
3 answers

Django & Django ORM: performance improvements to bulk updating records

I'm hoping this will be a really simple question. I just wanted some advise on the bulk updating of records. An example bulk update may go something like this: for user in User.objects.all().iterator(): user.is_active = False user.save() Is…
Micheal J. Roberts
  • 3,735
  • 4
  • 37
  • 76
2
votes
1 answer

django: uploaded images won't be displayed

my uploaded images can't be displayed even though i'm not getting any errors: instead it looks like this and here are my settings and codes: settings.py: STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR,…
Nour Adel
  • 21
  • 6
2
votes
2 answers

Django unable to create tables for unit testing after upgrade from 1.8 to 2.2.4

After a successful upgrade from Django 1.8 to Django 2.2.4, when I run the tests it fails because Django does not create the database tables. My test_settings.py file was working appropriately before the upgrade. after debugging the Django…
2
votes
2 answers

How to change the default search query parameter in URL in Django REST framework?

In Django REST Framework. By default it uses - /?search= in URL while searching for anything. For Example http://127.0.0.1:8000/api/branches/?search=RTGS And this url successfully getting the result. But I need to change the URL to…
2
votes
1 answer

Optimising API queries using JSONField()

Initial opening: I am utilising postgresql JSONFields. I have the following attribute (field) in my User model: class User(AbstractUser): ... benefits = JSONField(default=dict()) ... I essentially currently serialize benefits for each User…
2
votes
1 answer

Django REST framework - reverse ForeignKey relations

I have the following three models structured around the premise of the Survey. class Survey(models.Model): ... id = models.UUIDField(_('Id'), primary_key=True, default=uuid.uuid4, editable=False,) name = models.CharField(_('Name'),…
Micheal J. Roberts
  • 3,735
  • 4
  • 37
  • 76
1 2
3
17 18