Source

django / tests / regressiontests / admin_widgets / widgetadmin.py

The default branch has multiple heads

ja...@bcc190cf-c… a70a9fe 









ja...@bcc190cf-c… 4d57074 


ja...@bcc190cf-c… a70a9fe 







kmtr...@bcc190cf… acf502b 


Ian Struble fb6fad2 





russ...@bcc190cf… f7b4019 
ja...@bcc190cf-c… a70a9fe 
ja...@bcc190cf-c… 4d57074 
Ian Struble fb6fad2 
ja...@bcc190cf-c… 4d57074 
ja...@bcc190cf-c… a70a9fe 
kmtr...@bcc190cf… acf502b 
"""

"""
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']


class AlbumAdmin(admin.ModelAdmin):
    autocomplete_fields = {
        'band': { 'fields': ('name',), 'id': 'pk' }
            }

site = WidgetAdmin(name='widget-admin')

site.register(models.User)
site.register(models.Album, AlbumAdmin)
site.register(models.Car, CarAdmin)
site.register(models.CarTire, CarTireAdmin)
site.register(models.Event, EventAdmin)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.