Hallo everybody!

I've got problem exteding the admin's index view. I need to pass
extra_context to the index of the admin, after the administrator logged
in, that's why I'm trying to extend the view. So...

What I've got is:

In the root of the project I modified urls.py like following:
                       (r'^admin/$', project.admin.admin_site.index),
                       (r'^admin/', include(admin.site.urls)),

Again in the root of the project I've got admin.py with the following
snippet of code:

[...]
class AdminSiteRegistryFix( object ):
    '''
    This fix links the '_registry' property to the orginal AdminSites
    '_registry' property. This is necessary, because of the character of
    the admins 'autodiscover' function. Otherwise the admin site will
say, that you havn't permission to edit anything.
    '''

    def _registry_getter(self):
        return default_site._registry

    def _registry_setter(self,value):
        default_site._registry = value

    _registry = property(_registry_getter, _registry_setter)


class MyAdmin(sites.AdminSite, AdminSiteRegistryFix):
    @never_cache
    def index(self, request, extra_context={}):
        last_report_date = models.Reports.objects.latest().entry_date
        now = datetime.now() 
        delta = now - last_report_date
        extra_context['last_report_interval'] = delta.days

        return super(MyAdmin, self).index(request, extra_context)

admin_site = MyAdmin()


And it works. I've got the last_report_interval in the index.html
template and I can write my lovely message to the admin. The problem
is, that the ^admin/$ address swiches between the login and index view,
despite of users authentication status. And this is nice, but not
working after my changes, written above. Now I see only the app list of
the index. When I'm not logged in, I just see an empty list, but I've
got no login form...

Can anyone help me, understanding why has my login form disappeared?

What I can see from the django.contrib.admin.sites is that the
admin_view function is the one, calling the login view. But I have
noting to do with it, I haven't modify it and I don't understand what
disturbs it's functionallity.

Thank you in advance for your help!

Ivan Ivanov











-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to