mirror of
https://github.com/django/django.git
synced 2024-11-18 23:44:22 +00:00
8d48eaa064
This change is backwards incompatible for anyone that is using the named URLs introduced in [9739]. Any usage of the old admin_XXX names need to be modified to use the new namespaced format; in many cases this will be as simple as a search & replace for "admin_" -> "admin:". See the docs for more details on the new URL names, and the namespace resolution strategy. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11250 bcc190cf-cafb-0310-a4f2-bffc1f526a37
27 lines
728 B
Python
27 lines
728 B
Python
"""
|
|
|
|
"""
|
|
from django.contrib import admin
|
|
|
|
import models
|
|
|
|
class WidgetAdmin(admin.AdminSite):
|
|
pass
|
|
|
|
class CarAdmin(admin.ModelAdmin):
|
|
list_display = ['make', 'model', 'owner']
|
|
list_editable = ['owner']
|
|
|
|
class CarTireAdmin(admin.ModelAdmin):
|
|
def formfield_for_foreignkey(self, db_field, request, **kwargs):
|
|
if db_field.name == "car":
|
|
kwargs["queryset"] = models.Car.objects.filter(owner=request.user)
|
|
return db_field.formfield(**kwargs)
|
|
return super(CarTireAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
|
|
|
|
site = WidgetAdmin(name='widget-admin')
|
|
|
|
site.register(models.User)
|
|
site.register(models.Car, CarAdmin)
|
|
site.register(models.CarTire, CarTireAdmin)
|