AlreadyRegistered at /admin/, The model #### is already registered

2,893 views
Skip to first unread message

rabbi

unread,
Jan 8, 2009, 6:01:04 PM1/8/09
to Django users
Hi,
I've search around a bit and found a few references to this error, but
it seems that everyone else was getting this when they migrated to
Django 1.0 and newforms... for me it's a different situation, as I
started on 1.0 from the beginning

Background:
Went through tutorial, got a basic site working fine on runserver
Migrated site to Apache, site worked fine

I wanted to extend the site a bit, so I modified the models and
performed the following steps:
modified models.py (changed existing and added new)
modifed admin.py accordingly
ran python manage.py syncdb
restarted Apache
ALREADY REGISTERED error
deleted existing db file
ran python manage.py syncdb
ALREADY REGISTERED error

Does anyone have any suggestions?

Thanks,
Alex

rabbi

unread,
Jan 8, 2009, 6:22:09 PM1/8/09
to Django users
here's my admin.py

from mysite.swenglish.models import User
from mysite.swenglish.models import Entry
from mysite.swenglish.models import Category
from mysite.swenglish.models import Language
from django.contrib import admin

class UserAdmin(admin.ModelAdmin):
list_display = ('name', 'password')

class EntryAdmin(admin.ModelAdmin):
fieldsets = [
(None,{'fields': ['value']}),
('Created Details',{'fields': ['created_date','created_user'],
'classes': ['collapse']}),
('Language & Category',{'fields': ['language','category'],
'classes': ['collapse']}),
('Translations',{'fields': ['translations'], 'classes':
['collapse']}),
]
list_filter = ['value']
search_fields = ['created_user','category']
date_hierarchy = 'created_date'

class CategoryAdmin(admin.ModelAdmin):
fieldsets = [
(None,{'fields': ['value']}),
('Created Details',{'fields': ['created_date','created_user'],
'classes': ['collapse']}),
('Language',{'fields': ['language'], 'classes':
['collapse']}),
('Translations',{'fields': ['translations'], 'classes':
['collapse']}),
]
list_filter = ['value']
search_fields = ['created_user']
date_hierarchy = 'created_date'

class LanguageAdmin(admin.ModelAdmin):
fieldsets = [
(None,{'fields': ['value','value_english']}),
('Created Details',{'fields': ['created_date','created_user'],
'classes': ['collapse']}),
('Translations',{'fields': ['translations'], 'classes':
['collapse']}),
]
list_filter = ['value']
search_fields = ['created_user','value_english']
date_hierarchy = 'created_date'

admin.site.register(User,UserAdmin)
admin.site.register(Entry,EntryAdmin)
admin.site.register(Category,CategoryAdmin)
admin.site.register(Language,LanguageAdmin)

adrian

unread,
Jan 8, 2009, 6:17:01 PM1/8/09
to Django users
syncdb does not modify already existing tables.
so if you modified a model - syncdb will not modify the tables ....

rabbi

unread,
Jan 8, 2009, 6:33:40 PM1/8/09
to Django users
OK, thanks
I also tried deleting the db file and then calling syncdb again... it
didn't help
Do you have any suggestions?

Karen Tracey

unread,
Jan 8, 2009, 7:40:05 PM1/8/09
to django...@googlegroups.com
On Thu, Jan 8, 2009 at 6:33 PM, rabbi <alex.a...@gmail.com> wrote:

OK, thanks
I also tried deleting the db file and then calling syncdb again... it
didn't help
Do you have any suggestions?

Try importing your admin.py from a manage.py shell prompt, and see if that shows a more useful exception.

Karen

rabbi

unread,
Jan 8, 2009, 7:48:22 PM1/8/09
to Django users
I get the same exception(s)

The 1st time I try to import swenglish.admin I get:
ImproperlyConfigured: 'EntryAdmin.fieldsets[3][1]['fields']' refers to
field 'created_date' that is missing from the form.

The 2nd time I try to import swenglish.admin I get:
AlreadyRegistered: The model User is already registered

These are the same exceptions that I get when trying to load the admin
page.
The 1st time I try to load admin page I get ImproperlyConfigured
After I press refresh (and every subsequent refresh) I get
AlreadyRegistered

rabbi

unread,
Jan 8, 2009, 7:56:04 PM1/8/09
to Django users
I've solved it.
In case anyone has the same problem, I think it's because
'created_date' is set to auto_now, which means it's not editable and
should be in fieldsets

This link was helpful:
http://www.nabble.com/-Django-Code---7993:-Admin-complains-about-a-missing-field-even-if-it-is-not-missing-td18680119.html

Thanks for the suggestions

Karen Tracey

unread,
Jan 8, 2009, 8:24:19 PM1/8/09
to django...@googlegroups.com
You did not mention the ImproperlyConfigured  exception in your original report :)  I though it was likely a case of this:

http://code.djangoproject.com/ticket/8245

so was trying to get at what the real problem was, which I see by your follow-up mail you have solved.  There's been a fix made for that behavior of the real exception getting hidden by AlreadyRegistered on subsequent requests, but it seems (based solely on the last comment on that ticket, I haven't had time to look at it in any detail) there may be more work to be done for this situation.

Karen
Reply all
Reply to author
Forward
0 new messages