Questions tagged [django-2.0]

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

Django 2.0 requires Python 3.4, 3.5, or 3.6. It is the first version of Django to support only Python 3.

Here are some of the salient features of Django 2.0:

Django 2.0 was released in December 2017 and was supported until April 2019.

423 questions
2
votes
1 answer

Django model aggregate sum and count at same time

So I have a query like SELECT sum(project_shares) as shares, count(*) as count FROM vv_projects Is there any syntax like below in django 2.0 Projects.objects.aggregrate(Sum('project_shares'),Count('*')) and output…
Sayok88
  • 2,038
  • 1
  • 14
  • 22
2
votes
0 answers

Group by day and then again group by user to get list of object or object's id

class Ticket(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) booked_at = models.DateTimeField(default=timezone.now) bought = models.BooleanField(default=False) I would like to group tickets by booked day, and…
Aamu
  • 3,431
  • 7
  • 39
  • 61
2
votes
2 answers

Django REST Framework ManyToMany Error

When I add a serializer for the ManyToMany Field, it displays the results on the REST API but when I post data then the serializer gives is_valid() as false. When I mention them as JSONFields, then the serializer is_valid() is True and the data gets…
Arjunsingh
  • 703
  • 9
  • 22
2
votes
1 answer

django 2 custom jwt_get_username_from_payload_handler

To validate the jwt token of auth0 in django, I use the following code in settings.py def jwt_get_username_from_payload_handler(payload): return 'authuser' JWT_AUTH = { 'JWT_PAYLOAD_GET_USERNAME_HANDLER':…
2
votes
3 answers

Django cleaned_data.get('obj') method returns none

I'm doing a little password confirmation form in django. But Im confused as the self.cleaned_data.get('confirm_password') always returns none and hence my passwords never match to one another. Heres the clean method in the forms.py def…
Kush
  • 644
  • 1
  • 12
  • 30
2
votes
2 answers

Issues printing Django email to console

I am not sure what is wrong with my logic, but when I submit a form, it renders the Httpresponse in the browser, but doesn't post the email to the console. I want the view function to be able to print to the console successfully. Later I am going to…
Ryan L
  • 39
  • 1
  • 5
2
votes
2 answers

Django: static folder for template's assets

I'm learning Django 2.0 I have a ready-made template, that contains all assets in assets folder.All references in template starts from assets/..., and I'm gonna keep it: all links should looks like {% static 'assets/...' %} My Django app has…
shmnff
  • 647
  • 2
  • 15
  • 31
2
votes
0 answers

How to use apps with the same name in django

I created a project say foo. And created an app named admin. But it causes an error django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: admin” So I read this and made changes as mentioned there. I marked the…
Dead Pool
  • 133
  • 2
  • 9
2
votes
0 answers

Django-role-permission duplicate queries

I am using django-role-permission in my django project and am controlling access to the views through a decorator as follows: @canAccessDashboard def index(request): """ Merchant settings main page""" try: return render(request,…
Kheshav Sewnundun
  • 1,236
  • 15
  • 37
2
votes
0 answers

Django 2 django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet

I currently have a django app running Django==2.0. I wasn't having this problem before but yesterday when I was running through some code I got the error from home.models import Notification ImportError: cannot import name 'Notification' This was…
Nathan Fon
  • 21
  • 3
2
votes
1 answer

Django add message to auth_view

Is it possible to pass a flash message along with a path in urls.py? Since I did not write the auth_views into my core views.py file I figured there might be an easy way to pass it along with the request. I'd prefer to use the auth_views out of the…
Kermit
  • 4,922
  • 4
  • 42
  • 74
2
votes
1 answer

How to make a couple of async method calls in django2.0

I am a doing a small project and decided to use Django2.0 and python3.6+. In my django view, I want to call a bunch of REST API and get their results (in any order) and then process my request (saving something to database). I know the right way to…
Gatothgaj
  • 1,633
  • 2
  • 16
  • 27
2
votes
1 answer

Are there any stable opensource rich text editor packages that are compatible with django-2?

I have tried tinymce. But, it has dependency of communicating to tinymce site for checking plugins. Is there any other completely opensource text editor to be used in django 2? Quill seems not stable for django 2. I need to make changes at serveral…
GP92
  • 433
  • 1
  • 12
  • 30
2
votes
1 answer

Model can have a ForeignKey with one of the two models

I need some help with an issue that I am not able to resolve on my own. So in this model, a tenancy document can either have a ForeignKey with Building or Property. We may have a tenancy agreement on the whole building or on a single property within…
Zed
  • 379
  • 2
  • 6
  • 17
2
votes
1 answer

Django Error on edit in Django admin

When I try to change one of my models in the django admin I am getting the below error. Here is my model. class Scan(models.Model): image = models.FileField(upload_to = 'images/', default = 'images/') R = models.IntegerField(255) G =…