#19258: ModelAdmin customized queryset with extra option
-------------------------------+--------------------
     Reporter:  honyczek       |      Owner:  nobody
         Type:  Bug            |     Status:  new
    Component:  contrib.admin  |    Version:  1.4
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 If you customize queryset in ModelAdmin:

 {{{
 from app.models import License, Server
 from django.contrib import admin

 class LicenseAdmin(admin.ModelAdmin):
   def queryset(self, request):
     qs = super(LicenseAdmin, self).queryset(request)
     return qs.extra(select={'usage_count': "SELECT COUNT(id) FROM
 app_server WHERE license_id=license.id",})

   list_display = ('name','description','product_key', 'usage_count')

 admin.site.register(License, LicenseAdmin)
 }}}

 and want to use ''extra'' field called ''usage_count'', you get an error:

 {{{
 ImproperlyConfigured at /admin/app/license/

 LicenseAdmin.list_display[3], 'usage_count' is not a callable or an
 attribute of 'LicenseAdmin' or found in the model 'License'.
 }}}

 Django Admin interface ignores extra field ''usage_count'' from QuerySet,
 or validates columns by another way, which doesn't include QuerySet
 changes.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/19258>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to