Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django not creating db tables for models (neither with syncdb nor South)

I have a Django project on a Centos VPS.

I created some models and debugged them so they validate and give no errors. I have them in a "models" folder in my myapp and have added each model to the init file in this directory, for example:

from category import Category

I added the app to settings.py INSTALLED_APPS and ran:

Python manage.py syncdb

It appeared to work fine and added all tables apart from the ones for my app.

I then installed South and added that to INSTALLED_APPS and, tried syncdb again and ran:

Python manage.py schemamigration myapp --initial

It generated the file correctly but nothing was in it (none of the tables my models).

An example file in "models" folder (usertype.py)

from django.db import models

class UserType(models.Model):
    usertype_id = models.PositiveIntegerField(primary_key=True)
    description = models.CharField(max_length=100)
    is_admin = models.BooleanField()
    is_moderator = models.BooleanField()

class Meta:
    app_label = 'myapp'

Any ideas what could be going wrong here and why I can't get anything to detect my models?

like image 615
user3227889 Avatar asked Dec 01 '22 17:12

user3227889


1 Answers

Run the following commands

python manage.py makemigrations yourappname

python manage.py migrate

Note it works on django 1.7 version for me.

like image 179
Rafiq Avatar answered May 03 '23 11:05

Rafiq