>> > > I'm installing it from SVN and got "You don't have permission to edit
>> > > anything", I made it work before, but now when I try to follow the
>> > > book can't. Could you tell me what should I add to have full
>> > > permissions?
>>
>> > I have no idea what is going on in cases where people have
>> > admin.autodiscover() in their urls.py yet still get this "You don't have
>> > permission to edit anything" message.  I'd suggest you put a print 
>> > statement
>> > in django/contrib/admin/__init__.py after the __import__ in autodiscover()
>> > and verify that the auth app, at a minimum, is being found by
>> > autodiscover(). If not put a print in before the import and ensure
>> > adutodiscover() is really being called and attempting to import the admin
>> > module for each installed app.

Okay, I've spent a little time on this. There seem to be a few problems.

First of all, I'm a little confused about where to use
admin.site.register(). A few months ago I checked out the
newforms-admin branch to try to get a head start, and I followed the
instructions on this wiki page[1], which recommended importing
django.contrib.admin at the top of models.py in a given app, then
registering the models at the bottom of the same file. Of course, I
realise that the documentation is in flux, but at the time, doing that
worked.

I've now moved that code into admin.py in my app folder. It looks
something like this:

-----8<-----

from django.contrib import admin
from myproj.people.models import Person

class PersonAdmin(admin.ModelAdmin):
        pass

admin.site.register(Person, PersonAdmin)

-----8<-----

However, when I *also* include admin.autodiscover() in my project-root
urls.py, the following exception is raised:

ImproperlyConfigured at /admin/
Error while importing URLconf 'myproj.urls': The model Person is
already registered

If I comment out the contents of my admin.py file, then that exception
is not raised, and also if I comment out the call to
admin.autodiscover(), the exception is not raised, however I cannot
have both active at the same time. A little googling brought up ticket
6776 [2], which seems to have been closed, with the introduction of
admin.autodiscover() as the resolution. I'm not entirely sure what is
going on there.

Regardless, I took Karen's advice, and modified the __init__.py in
django.contrib.admin, and added a print statement to see which
applications were being loaded. In my case, the output was this:

django.contrib.auth
django.contrib.contenttypes
django.contrib.sessions
django.contrib.sites
django.contrib.admin
myproj.people

... which looks reasonable to me (auth is being loaded before admin,
which would suggest that the permissions would be available to the
admin app), but I still see the same 'you don't have permission to
edit anything' message in the admin application.

Any help debugging this would be much appreciated - now that
newforms-admin is in trunk, I can't justify continuing development
without it, so I'd really like to solve this :-)

--Jon

[1] http://code.djangoproject.com/wiki/NewformsHOWTO
[2] http://code.djangoproject.com/ticket/6776

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to