I have this model which map to a postgresql view
What I want to achieve is to have region > sum(nbr), so:
But Django is throwing an exception:
Am I missing something ?
-- class AppModel(models.Model):
nbr = models.BigIntegerField(blank=True, null=True)
region = models.ForeignKey(AppWilaya,blank=True, null=True)
date_preorder = models.DateField(blank=True, null=True)
id = models.IntegerField(primary_key=True,blank=True, db_column='dummy_id')
What I want to achieve is to have region > sum(nbr), so:
class AppModelAdmin(admin.ModelAdmin):
....
def queryset(self, request):
qs = super(AppModelAdmin, self).get_queryset(request)
qs=qs.values("region").annotate(total=Sum( 'nbr'))
But Django is throwing an exception:
Exception Value: 'dict' object has no attribute '_meta'Note when I remove .values("region") the exception doesn't occure.
Exception Location: D:\Python335\lib\site-packages\django\contrib\admin\util.py in lookup_field, line 242
Am I missing something ?
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0809fcb9-238c-4495-9ed3-7fb1d78e6b21%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment