On Tue, 2008-09-02 at 21:40 -0700, Justin Fagnani wrote: > I have a very, very simple model that when I register with the admin > completely kills my app/project. I can't for the life of me figure out > what's going on. If I don't register the admin class, everything works > fine, if I do, the nothing that's loaded after the registration can be > imported, including classes/function from other modules. > > Here's the model and admin: > > class Carrier(models.Model): > name = models.CharField(max_length=128) > url = models.URLField(null=True, verify_exists=False) > > def __unicode__(self): > return self.name > > class CarrierAdmin(admin.ModelAdmin): > pass > admin.site.register(Carrier, CarrierAdmin)
Don't put admin registration in the same file as the model definitions. Model files are imported more than once, which leads to registration problems. It's also pretty easy to get circular dependencies problems because of some validation code in the admin interface. In short, follow the recommended practice and put the Admin class and reistration into admin.py, rather than models.py Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---