Using the 'app_label' in the 'Class Meta' will solve this problem. But it won't create tables while issuing 'syncdb' command. Because the app name won't match with INSTALLED_APPS entry. Is there any way to achieve both (custom app name and creating tables with syncdb)
Asked
Active
Viewed 1.3k times
6
-
Are you trying to have custom table names? What are you trying to achieve? – Dominic Rodger Oct 30 '10 at 08:51
-
@Dominic I think he wants to change the application names(labels) which appear in the admin interface to some custom names. – Ankit Jaiswal Oct 30 '10 at 14:48
-
@Dominic @anand is correct. I would like to have custom application names in the admin interface. – Siva Arunachalam Oct 31 '10 at 07:12
-
The problem here is that, if we use app_label in models, it won't create the database tables while doing 'syncdb'. – Siva Arunachalam Oct 31 '10 at 11:35
-
Not an elegant solution but you can follow the second answer in the stackoverflow.com/questions/612372/ . Copy admin template and define app name there. – Ankit Jaiswal Nov 01 '10 at 11:45
1 Answers
0
I haven't tried this, but here there is a solution that should allow changing the app label while working with syncdb.
class model_module1(models.model):
[...]
class Meta:
app_label = "Cool module name"
db_table = "module1_model"
class model_module2(models.model):
[...]
class Meta:
app_label = "Cool module name"
db_table = "module2_model"
This makes sense, since the name of the table is made explicit, so there is no guessing when running syncdb. The downside is that this two Meta options must be specified in every model of the app.
Community
- 1
- 1
Armando Pérez Marqués
- 5,661
- 4
- 28
- 45