This has gone well so far -- I ended up pointing my new comment app
models at the old database tables using the db_table meta option, and
then manually altering the table definitions, that kept things a lot
simpler.

I'm getting an AlreadyRegistered exception for a custom CommentsAdmin
definition in my own custom comments admin.py. Looking at the code,
the builtin contrib admin should not be registered so long as I've got
a COMMENTS_APP defined in settings.py, and that comments app has a
get_model() method that returns something other than the default
Comment model. Both of those things are true, yet I'm
AlreadyRegistered. I see that the traceback goes through my
admin.autodiscover() statement, I wonder if that could have something
to do with it. I've also named my COMMENTS_APP 'comments' and the main
model Comment – could there be a clash somewhere? I'm running a newly-
updated django.

Traceback:
File "/Library/Python/2.5/site-packages/django-trunk/django/core/
handlers/base.py" in get_response
  83.                     request.path_info)
File "/Library/Python/2.5/site-packages/django-trunk/django/core/
urlresolvers.py" in resolve
  184.             for pattern in self.url_patterns:
File "/Library/Python/2.5/site-packages/django-trunk/django/core/
urlresolvers.py" in _get_url_patterns
  208.         patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)
File "/Library/Python/2.5/site-packages/django-trunk/django/core/
urlresolvers.py" in _get_urlconf_module
  203.             self._urlconf_module = import_module
(self.urlconf_name)
File "/Library/Python/2.5/site-packages/django-trunk/django/utils/
importlib.py" in import_module
  35.     __import__(name)
File "/dev/myproject/urls.py" in <module>
  17. admin.autodiscover()
File "/Library/Python/2.5/site-packages/django-trunk/django/contrib/
admin/__init__.py" in autodiscover
  56.         import_module("%s.admin" % app)
File "/Library/Python/2.5/site-packages/django-trunk/django/utils/
importlib.py" in import_module
  35.     __import__(name)
File "/dev/myproject/comments/admin.py" in <module>
  21. admin.site.register(Comment, MyCommentAdmin)
File "/Library/Python/2.5/site-packages/django-trunk/django/contrib/
admin/sites.py" in register
  80.                 raise AlreadyRegistered('The model %s is already
registered' % model.__name__)

Exception Type: AlreadyRegistered at /admin/
Exception Value: The model Comment is already registered

On Apr 9, 10:15 pm, Eric Abrahamsen <[email protected]> wrote:
> I'm planning on migrating an existing (django.contrib) comments setup  
> into a custom comment app, and I'm wondering if anyone's got any  
> experience to impart in this regard. I have done cross-app data  
> migration before, and cocked it up horribly. These are the steps I'm  
> considering; if anyone's got suggestions, or sees anything wrong here,  
> for god's sake speak up please.
>
> 1. Make my custom comment app, then copy all models, forms, peripheral  
> models, comment-related signals, etc etc, into it. Leave existing  
> stuff in place. Add the appropriate get_model() and get_form()  
> functions to __init__.py. Augment new models as necessary. Run syncdb  
> to make tables for the new app.
>
> 2. Add COMMENTS_APP to settings.py, pointing to my new app. Alter the  
> existing django_content_type table to also point to this new app. (I  
> see the existing app_label is just 'comments', if I call my custom app  
> 'comments' too, can I get away with not changing anything in this  
> table?).
>
> 3. Go into the shell and copy data from existing comment instances  
> (I've also got Commenter and CommentNotification models) into the new  
> app models.
>
> 4. Pull changes onto production server, run syncdb, repeat steps 2 and  
> 3 above, restart.
>
> 5. Delete old code and old db tables from both development and  
> production environments.
>
> 6. Golden.
>
> Does this seem right? I'm particularly worried about problems that  
> might arise from having the existing code pointing to a new app. Is  
> there anything besides django_content_type that needs to know what's  
> changed?
>
> If this works I hope it will be useful as a roadmap to others equally  
> frightened of databases.
>
> Thanks,
> Eric
--~--~---------~--~----~------------~-------~--~----~
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