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
0
votes
1 answer

Can't dismiss message from SuccessMessageMixin in UpdateView

Update: Problem was more wide ranging in that no JS was working - see my own answer below. I have an UpdateView where I am using the SuccessMessageMixin to display an "updated" message. This works fine, but I can't seem to dismiss the message -…
michjnich
  • 2,796
  • 3
  • 15
  • 31
0
votes
0 answers

How to template tag for @property in django

I defined field in air with @property. this is my @property field: @property def points(self): if self.pk: return self.questions.all().aggregate(Sum('point'))['point__sum'] else: return 0 Then I create…
rahnama7m
  • 865
  • 10
  • 38
0
votes
1 answer

Use ManyToMany field in add object raise needs to have a value for field "id" before this many-to-many relationship can be used

I have two models : Exam and Question. Each question has point that automatically calculate in each exam. So this is my files: #Models.py class Exam(models.Model): questions = models.ManyToManyField(Question) title =…
rahnama7m
  • 865
  • 10
  • 38
0
votes
1 answer

Save everything for new object except ManyToMany field in Django

I want to save object with ManyToMany relation. When I submit the form, all things save except field that have ManyToMany relation. These are my files: #Forms.py class ExamForm(ModelForm): class Meta: model = Exam fields =…
rahnama7m
  • 865
  • 10
  • 38
0
votes
1 answer

Advanced ORM usage for constraint filtering by an annotated value

I have the following Query/(ies) that I have constructed: users = User.objects.filter(is_active=True) date_range = [start_date, timezone.now()] results = SurveyResult.objects.filter( user__in=users, …
Micheal J. Roberts
  • 3,735
  • 4
  • 37
  • 76
0
votes
1 answer

Django prefetch_related and performance optimisation with multiple QuerySets within loops

Effectively I have multiple Queries within loops that I am just not happy with. I am seeking some expertise with prefetch_related and other Django Query construction optimisations. I start with: users =…
Micheal J. Roberts
  • 3,735
  • 4
  • 37
  • 76
0
votes
1 answer

Select a valid choice. ["objects"] is not one of the available choices. in Django

I'm going to create a form where the user can select any number of objects from the options.(MultipleChoiceField) Here are my files: DAY_CHOICES = ( ('saturday', 'شنبه'), ('sunday', 'یکشنبه'), ('monday', 'دوشنبه'), ('tuesday', 'سه…
rahnama7m
  • 865
  • 10
  • 38
0
votes
1 answer

Change admin form name for overridden User

I've overridden the standard django User by extending AbstractUser. Now this all works fine, but for some reason I can't make the admin display "Profiles" (the name of the model now set in settings.AUTH_USER_MODEL instead of "Users". This is my…
michjnich
  • 2,796
  • 3
  • 15
  • 31
0
votes
1 answer

Include class based ListView as a template snippet in a TemplateView

I want to have the following: A template view (actually my landing page), that contains a number of items, including a list view. Now, I have a list view that works when I map it to it's own url: app/views.py class MymodelListView(ListView): …
0
votes
1 answer

"How to load map using leaflet in templates? "

It works in ![django default admin site form] (https://i.stack.imgur.com/RqIWN.jpg) but not on . i tried passing attributes on leafletwidget, load leaflet_tags . it's not working or as i am new, could't use them properly. create.html {% extends…
Rudra
  • 223
  • 2
  • 13
0
votes
2 answers

My code doesn't run it says there is a circular import error I'm try to load the home view so that it redirects me

I am working on a django project, but it returns the included urlconf "myapp.urls"does not appear to have any patterns in it. I tried checking my views to ensure I imported everything correctly from django.contrib import admin from django.urls…
Jbritz-
  • 13
  • 2
0
votes
1 answer

Make readable the post only if the user is staff

I'm developing the backend of my blog and I need to make a difference between the typology of posts: published, future post, draft. For do this I'm started with the indications comes inside my past request: Create a restricted area Django: put…
MaxDragonheart
  • 1,117
  • 13
  • 34
0
votes
2 answers

"Value error: Cannot use object with type int for spatial lookup parameter"

Added a Point field in one of my model to load map.to migrate the changes in model ,in pycharm terminal python manage.py makemigrations run okay. but python manage.py migrate raise ValueError('Cannot use object with type %s for a spatial lookup…
Rudra
  • 223
  • 2
  • 13
0
votes
1 answer

how to create model instance with circular foreign key that cannot be null

In my django app I have two Model in a one-to-many relationship: Term and TermName (Term has many TermName). I want to keep track in Term of a particular TermName instance, say TermName models are name alias or the related Term model, but one of…
0
votes
1 answer

Django2 is trying to render Jinja2 templates, even though it's a REST API

We're utilizing the django-rest-framework to create a RESTful API and using generic views or view sets to create the endpoint views. There is no templating happening, all the frontend is in React. However, upon watching the traces in Datadog, we're…