Re: use same database across various applications in a django project?

38 views
Skip to first unread message

Gink Labrev

unread,
Jul 12, 2012, 8:07:40 PM7/12/12
to django...@googlegroups.com
https://docs.djangoproject.com/en/dev/topics/db/models/#meta-options 

2012/7/12 Gink Labrev <gink....@gmail.com>
If the problem is the table name, use  db_table  to set database table name. 

2012/7/12 Burhan <its.bu...@gmail.com>
Hi,

I have a project which has two applications, app_1 and app_2, when I run "python manage.py syncdb" it creates tables defined in model.py (same for both apps), but it creates tables like app_1_table1, app_1_table1, app_2_table1, app_2_table2, however, i want both applications use the same table prefix rather two different prefix.

more precisely I want my both apps use same model and one single database.

any help in this regard would be appreciated.

Thanks,
Burhan

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/CCUnqkFgfS4J.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


Gink Labrev

unread,
Jul 12, 2012, 8:07:28 PM7/12/12
to django...@googlegroups.com

Burhan

unread,
Jul 13, 2012, 6:46:57 AM7/13/12
to django...@googlegroups.com
Hi,

Thanks for the relpy, i set db_name under as meta information, now i am getting this error

django.db.utils.DatabaseError: table "mytable_author" already exists

this is because, for the app1 python syncdb has already created this table, now it attempts to create the same tables for app2.

is it possible to use the same model class for both app, at the moment models.py is placed in both app1 and app2.



regards
Burhan

Сергей Фурсов

unread,
Jul 13, 2012, 6:50:52 AM7/13/12
to django...@googlegroups.com
Why do you define this model in app1 and in app2? Define it only in app1 and import it in app2 where you need (models, views, etc)

2012/7/13 Burhan <its.bu...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/-HSSLSfEuwoJ.

Burhan

unread,
Jul 13, 2012, 6:53:43 AM7/13/12
to django...@googlegroups.com
sounds like a great idea! I never thought of this. thanks again :)
Reply all
Reply to author
Forward
0 new messages