First time here? Check out the FAQ!
0

add a new app to askbot - syncdb doesn't create model

I have created a new app when I run python manage.py syncdb it get listed under synced module but when I go and take a look at the database tables have not been created. I have added the new app to installed_apps.

Here is how my model looks like:

from django.db import models from askbot.deps.django_authopenid.models import User

class MyUser(models.Model):
    auth_user = models.ForeignKey(User)
    my_username = models.CharField(max_length = 200)
    my_user_role = models.CharField(max_length = 200)

    class Meta:
        app_label = 'askbot'

How can I integrate this with syncdb and migration process. Regardless the migration I thought when you add it to installed_apps it should create the database. Am I wrong? or is there anything else that I should be doing?

SocialQA's avatar
265
SocialQA
asked 2013-11-14 13:27:58 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

1

That's because app askbot requires migrations. It will be better to make your own app with different name then syncdb will work.

If you add tables in the askbot app, then you will need to add a migration creating that table and in the future maintain your migrations within the askbot/migrations directory.

Evgeny's avatar
13.2k
Evgeny
answered 2013-11-14 13:34:13 -0500
edit flag offensive 0 remove flag delete link

Comments

I have named my app as myuser thats the name of the app its in askbot/myuser, should I create a migration folder there and run migration? I created another app but that worked find in that app i didn't use app_label = 'askbot' may be thats the reason?

SocialQA's avatar SocialQA (2013-11-14 13:39:35 -0500) edit
1

Try changing "applabel" parameter to something else, and it will be better to place your app in a separate directory at the same level as "askbot". You could even keep your app in a separate repository.

Evgeny's avatar Evgeny (2013-11-14 13:45:30 -0500) edit
1

Interesting thing was as it is mysql database generate the table during syncdb but postgres doesnt. So I tried askbot_myapp, this way it generate and empty migration script. I want my table to by askbot_myuser how can I get that with migration. i do following: python manage.py schemamigration askbot.myapp --initial with app_label = askbot_myapp then it generates empty migration 0001 file.

SocialQA's avatar SocialQA (2013-11-14 18:25:03 -0500) edit
add a comment see more comments