raiseImproperlyConfigured("Put 'django.core.context_processors.auth' in your TEMPLATE_CONTEXT_PROCESSORS setting in order to use the admin application.")
self.check_dependancies()
# Delegate to the appropriate method, based on the URL.
ifurlisNone:
@@ -285,6 +278,23 @@ class ModelAdmin(BaseModelAdmin):
else:
returnself.change_view(request,unquote(url))
defcheck_dependancies(self):
"""
Check that all things needed to run the admin have been correctly installed.
The default implementation checks that LogEntry, ContentType and the
auth context processor are installed.
"""
fromdjango.confimportsettings
fromdjango.contrib.admin.modelsimportLogEntry
ifnotLogEntry._meta.installed:
raiseImproperlyConfigured("Put 'django.contrib.admin' in your INSTALLED_APPS setting in order to use the admin application.")
ifnotContentType._meta.installed:
raiseImproperlyConfigured("Put 'django.contrib.contenttypes' in your INSTALLED_APPS setting in order to use the admin application.")
raiseImproperlyConfigured("Put 'django.core.context_processors.auth' in your TEMPLATE_CONTEXT_PROCESSORS setting in order to use the admin application.")
def_media(self):
fromdjango.confimportsettings
@@ -360,13 +370,94 @@ class ModelAdmin(BaseModelAdmin):
forinlineinself.inline_instances:
yieldinline.get_formset(request,obj)
deflog_addition(self,request,object):
"""
Log that an object has been successfully added.
The default implementation creates an admin LogEntry object.
request.user.message_set.create(message=_('The %(name)s "%(obj)s" was added successfully. You may edit it again below.')%{'name':force_unicode(opts.verbose_name),'obj':new_object})
msg=_('The %(name)s "%(obj)s" was added successfully. You may edit it again below.')%{'name':force_unicode(opts.verbose_name),'obj':new_object}
self.message_user(request,msg)
returnHttpResponseRedirect("../%s/"%pk_value)
elifrequest.POST.has_key("_addanother"):
request.user.message_set.create(message=msg+''+(_("You may add another %s below.")%force_unicode(opts.verbose_name)))
self.message_user(request,msg+''+(_("You may add another %s below.")%force_unicode(opts.verbose_name)))