Using yawd-admin

Set up

To use the yawd-admin website you first need to include yawdadmin in your INSTALLED_APPS setting. You also not need to include django.contrib.admin in INSTALLED_APPS and place it after yawdadmin for yawd-admin to work properly. In settings.py:

INSTALLED_APPS = (
        ...
        'yawdadmin',
        'django.contrib.admin',
        ...
)

yawd-admin uses the yawdadmin.middleware.PopupMiddleware middleware to replace the standard django admin popups with fancybox. Make sure the middleware is enabled in your MIDDLEWARE_CLASSES setting. In settings.py:

MIDDLEWARE_CLASSES = (
        ...
        'yawdadmin.middleware.PopupMiddleware',
        ...
)

Note:

If you're running Django 1.6 and above, you don't need to use this middleware.

Finally, the django.core.context_processors.request context processor must also be enabled:

TEMPLATE_CONTEXT_PROCESSORS = (
        ...
        "django.core.context_processors.request",
        ...
)

Registering the yawd-admin urls

To register the admin site views, use the following (inside your urls.py):

from yawdadmin import admin_site

patterns = (''
        url(r'^admin/', include(admin_site.urls)),
        ...
)

You do not need to register the django admin urls as well, the yawd admin_site extends the original admin class.

ModelAdmin registration and auto-discovery

Normally, to register your normal ModelAdmin class with yawd-admin you should use yawdadmin.admin_site instead of the original django.contrib.admin.site instance (in admin.py):

from django.contrib import admin
from models import MyModel

class MyModelAdmin(admin.ModelAdmin):
        pass

from yawdadmin import admin_site
#you can use this instead of admin.site.register():
admin_site.register(MyModel, MyModelAdmin)

However, many applications might have registered their ModelAdmin classes with the default django admin site. As you can see from the above snippet yawd-admin uses the ModelAdmin class as well, therefore you can easily add all standard registrations to the yawd-admin website. To do so, use the standard admin.autodiscover() method and then update the yawd-admin registry as follows (in urls.py):

from django.contrib import admin
from yawdadmin import admin_site

admin.autodiscover()
admin_site._registry.update(admin.site._registry)

Integration with Custom User Models

yawdadmin comes with a new admin view to allow staff users edit their own account information (username, first name, last name and email). This view uses a ModelForm of the standard django.contrib.auth.models.User model.

If your projects makes use of the new django 1.5 custom user functionality you can set the ADMIN_USER_MODELFORM yawd-admin setting to override the ModelForm used by the view (in settings.py):

ADMIN_USER_MODELFORM = 'myapp.module.MyModelForm'

Note that the setting value can be a string or Class. A string is normally preferred to avoid import errors during environment initialization.

Settings

ADMIN_DISABLE_APP_INDEX

With yawd-admin you can optionaly disable the app index view (the one that lists an application’s models). Doing so will raise “Page Not Found” (404) errors when accessing the application urls and will also hide all corresponding links from breadcrumbs.

ADMIN_DISABLE_APP_INDEX = True

ADMIN_GOOGLE_ANALYTICS

A dictionary holding configuration of the connected google analytics account. Please see Integration with Google Analytics.

ADMIN_SITE_NAME / ADMIN_SITE_DESCRIPTION

You can change the admin site name and add a description to the login page by adding a couple attributes to your settings:

ADMIN_SITE_NAME = 'My Admin Site'
ADMIN_SITE_DESCRIPTION = 'This is a private site.  Please don\'t hack me'

If you don’t want a description at all just null the attribute:

ADMIN_SITE_DESCRIPTION = None

ADMIN_SITE_LOGO_HTML

To set a logo that will show up in the right side of the header:

ADMIN_SITE_LOGO_HTML = '<div id="myproject-logo hidden-phone">Logo</div>'

ADMIN_JS_CATALOG

Additional javascript translation messages for use in the admin interface. Please see Javascript message translations.

ADMIN_JS_CATALOG_CACHE_TIMEOUT

For how long you want the js catalog view to be cached. Yawd-admin will cache a different version of the view per language. Use 0 if you want to disable caching on the jsi18n view. Defaults to 60 * 60 (1 hour).

ADMIN_USER_MODELFORM

If you implement a custom user model (django 1.5 and above) you can override the ModelForm that yawd-admin uses to allow staff users edit their account data. For more info please see Integration with Custom User Models.

ADMIN_USER_MODELFORM = 'myapp.module.MyModelForm'

ADMIN_CACHE_DB_OPTIONS

default: 3600

Cache duration (in seconds) for the admin database options. Cache gets updated each time an option value changes. That way cached values always reflect the db values. If set to 0 there will be no caching.