开发者

Django 1.2 : Multiple database and Generic Content Types

I am working on one project with django 1.2.

I have 2 databases : - First, for users, user's profile, session ... - Second is to store data from my specifics models like post of blog, pictures, files ...

I made a router (dbrouter.py) to manage where each models are stored (instead of using 'using' for each queryset). When I sync my project there is no problem.

So, I need content types framework in first and second databases. Now, how do I do to declare cont开发者_运维技巧enttypes app on my two databases and how I will be sure that data of contenttypes are synchronized on my two databases ?

The only workaround I found, was :

  • Declare contenttypes framework two times in settings.py.
  • Manage with dbrouter this two contenttypes for each databases
  • When I sync project, only table django_content_type from my first database is updated with data.
  • Manually I copy data from first database (table django_content_type) to the second.

Finally, can you tell me what are the best practices when you want to manage content types on multiple databases ?


I think the "best practice" here would be to not use two different databases in the way you are doing. I can't think of any truly useful reason to separate out users/profiles/sessions from the rest of the data for your application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜