mirror of
https://github.com/django/django.git
synced 2024-12-27 03:25:58 +00:00
290d7d4d21
Also, converted these widgets to reverse named URLs instead of hard-coded '../../...'-style links, refs #15294. Thanks Florian Apolloner for the initial patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16578 bcc190cf-cafb-0310-a4f2-bffc1f526a37
41 lines
1010 B
Python
41 lines
1010 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)
|
|
|
|
class EventAdmin(admin.ModelAdmin):
|
|
raw_id_fields = ['band']
|
|
|
|
site = WidgetAdmin(name='widget-admin')
|
|
|
|
site.register(models.User)
|
|
site.register(models.Car, CarAdmin)
|
|
site.register(models.CarTire, CarTireAdmin)
|
|
|
|
site.register(models.Member)
|
|
site.register(models.Band)
|
|
site.register(models.Event, EventAdmin)
|
|
site.register(models.Album)
|
|
|
|
site.register(models.Inventory)
|
|
|
|
site.register(models.Bee)
|
|
|
|
site.register(models.Advisor)
|