Pardon me.
I incorrectly followed the suggestion, should have been the following
in admin.py:

admin.site.register(Book)
admin.site.register(Author)
admin.site.register(Publisher)

What is the difference between this and, say,

class BookAdmin(admin.ModelAdmin):
   pass
admin.site.register(Book, BookAdmin)

When I entered just this class, it worked for me the first time
around, though later adding more fields I still do not understand what
provoked that error.

Thanks for helping me get it running at any rate!


On Dec 3, 4:39 am, djan <[EMAIL PROTECTED]> wrote:
> Thanks for the replies. I restarted the dev server (and even my x
> session).
> I first tried:
>
> class BookAdmin(admin.ModelAdmin):
>     pass
> #admin.site.register(Book, BookAdmin)
>
> class AuthorAdmin(admin.ModelAuthor):
>     pass
> #admin.site.register(Author, AuthorAdmin)
>
> class PublisherAdmin(admin.ModelPublisher):
>     pass
> #admin.site.register(Publisher, PublisherAdmin)
>
> And received the following error:
> AttributeError: 'module' object has no attribute 'ModelAuthor'
>
> I then tried the second suggestion:
> #class BookAdmin(admin.ModelAdmin):
> #    pass
> admin.site.register(Book, BookAdmin)
>
> #class AuthorAdmin(admin.ModelAuthor):
> #    pass
> admin.site.register(Author, AuthorAdmin)
>
> #class PublisherAdmin(admin.ModelPublisher):
> #    pass
> admin.site.register(Publisher, PublisherAdmin)
>
> And receive the error:
>   File "$HOME/djcode/mysite/books/admin.py", line 6, in <module>
>     admin.site.register(Book, BookAdmin)
> NameError: name 'BookAdmin' is not defined
>
> Any other thoughts?
>
> On Dec 2, 10:21 am, "please smile" <[EMAIL PROTECTED]> wrote:
>
> > hi,
>
> > class BookAdmin(admin.ModelAdmin):
> >    pass
> > # admin.site.register(Book, BookAdmin)
>
> > Just put '#' in front of admin.site.register(Book, BookAdmin) .Now run the
> > server ,if it s ok then remove the #
>
> > On Tue, Dec 2, 2008 at 12:47 PM, Roland van Laar <[EMAIL PROTECTED]> wrote:
>
> > > djan wrote:
> > > > Hello.
>
> > > > I'm following along with djangobook.com and trying to make necessary
> > > > changes to port django to version 1.0. In Django's Site
> > > > Administration, chapter 6, I run into the error:
>
> > > > Exception Type:       AlreadyRegistered
> > > > Exception Value:      The model Book is already registered
> > > > Exception Location:   /usr/local/lib64/python2.5/site-packages/django/
> > > > contrib/admin/sites.py in register, line 64
>
> > > Probably:
> > > Try to restart the django development server.
> > > The django dev server doesn't reload the admin.py file properly when it's
> > > edited or when it encounters an error in that file.
>
> > > > I used the site administration site successfully with just "Book", and
> > > > then when I attempted to add the other models (Auther, Publisher), I
> > > > received the above error.
>
> > > > in admin.py I have:
>
> > > > from django.contrib import admin
> > > > from models import Book, Author, Publisher
>
> > > On another note, you don't have to do this:
>
> > > > class BookAdmin(admin.ModelAdmin):
> > > >     pass
> > > > admin.site.register(Book, BookAdmin)
>
> > > admin.site.register(Book)
>
> > > would suffice.
>
> > > > class AuthorAdmin(admin.ModelAuthor):
> > > >     pass
> > > > admin.site.register(Author, AuthorAdmin)
>
> > > > class PublisherAdmin(admin.ModelPublisher):
> > > >     pass
> > > > admin.site.register(Publisher, PublisherAdmin)
>
> > > > When I updated admin.py I ran:
> > > > python manage.py syncdb
>
> > > > It is as if the database wasn't "synced" though, and that two
> > > > instances of this model are trying to be created.
>
> > > > When I searched around for this error, I found instances of this
> > > > occuring in 0.96, with the model being called several times. The Admin
> > > > changes in 1.0 were said to resolve this, so perhaps it is something
> > > > else.
>
> > > > I appreciate any help. Thanks!
>
> > > Regards,
>
> > > Roland
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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