I am having a problem with admin.autodiscover(). I just moved my site from the system I was building it on to the server it will stay on for production use. The system that was being used to build it is Windows 7 however the production server is Debian Squeeze 64bit.
The problem is that I am getting the error The model UserProfile is already registered. I am not having this problem with the Windows 7 computer, only once it moves to Debian it does.
admin.py
class UserProfileadmin(admin.ModelAdmin):
list_display = ['user', 'country', 'totalflights', 'totalhours', 'hub']
search_fields = ['user']
list_filter = ['hub']
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'hub':
kwargs['queryset'] = Airports.objects.filter(hub=True)
return super(UserProfileadmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
admin.site.register(UserProfile,UserProfileadmin)
class PilotRankadmin(admin.ModelAdmin):
list_display = ['ranktitle', 'minimumhours', 'pay']
search_fields = ['ranktitle']
admin.site.register(PilotRank, PilotRankadmin)
class PIREPadmin(admin.ModelAdmin):
list_display = ['user', 'flightnumber']
search_fields = ['ranktitle']
admin.site.register(PIREP, PIREPadmin)
Any ideas? I have never had this before when working on a Windows system then moving to a Linux system for production.
Can you post the error stack details…
have you tried using admin.site.unregister(UserProfile) just before you call register ?
edit:
this seems to be working fine for me –