django-syncdb

In django, how do I call the subcommand 'syncdb' from the initialization script?

流过昼夜 提交于 2020-01-09 08:39:12
问题 I'm new to python and django, and when following the Django Book I learned about the command 'python manage.py syncdb' which generated database tables for me. In development environment I use sqlite in memory database, so it is automatically erased everytime I restart the server. So how do I script this 'syncdb' command?(Should that be done inside the 'settings.py' file?) CLARIFICATION The OP is using an in-memory database, which needs to be initialized at the start of any process working

syncdb not adding fixtures in 3rd party project

大兔子大兔子 提交于 2020-01-06 23:42:10
问题 I've written a pretty simple Django application called django-locality which takes the headache out of working with countries and territories. It provides a lot of initial data for countries and territories. I just the 0.1 release up to PyPI, and installed it in my project which I'm currently working on. (I basically created it out of a need I found in my original project.) When I ran syncdb , however, it didn't install any of my fixtures from locality . In the output, it printed "No fixtures

auth_user error with Django 1.8 and syncdb / migrate

两盒软妹~` 提交于 2019-12-31 08:55:09
问题 When upgrading to Django 1.8 (with zc.buildout) and running syncdb or migrate, I get this message: django.db.utils.ProgrammingError: relation "auth_user" does not exist One of my models contains django.contrib.auth.models.User: user = models.ForeignKey( User, related_name='%(app_label)s_%(class)s_user', blank=True, null=True, editable=False ) Downgrading to Django 1.7 removes the error. Do I have to include the User object differently in Django 1.8? 回答1: I fix this by running auth first, then

Problem running syncdb in django

て烟熏妆下的殇ゞ 提交于 2019-12-25 02:22:44
问题 I am trying to go through the django docs tutorial and having a problem syncing mysql. On the command python manage.py syncdb I get the following error (note I'm running in windows 7): ... File "C:\python27\lib\site-packages\django\db\backends\mysql\base.py", line 14, in <module> raise Improperlyconfigured("Error loading Mysqldb module: %s" % e) django.core.excepions.Improperlyconfigured: Error loading Mysqldb module: No module named mySQLdb I have initialized the db in setting.py as: 'ENGINE

syncdb ignores imported models

一曲冷凌霜 提交于 2019-12-24 10:37:21
问题 I have a project, structured like this: project/ __init__.py db/ models/ __init__.py article.py project.py ontology/ __init__.py coded.py It's a little bit bigger, but that's the idea. models.__init__.py contains: from db.models.article import * from db.models.project import * from db.models.ontology.coded import * When running syncdb, it ignores all models imported in models.__init__.py . There are no ImportError 's, and when adding a print statement to the __init__.py , it happily prints

django manage.py syncdb not working?

自作多情 提交于 2019-12-22 10:43:37
问题 Trying to learn Django, I closed the shell and am getting this problem now when I call python manage.py syncdb, any idea what happened?: I've already set up a db. I have manage.py set up in the folder django_bookmarks. What's up here? Traceback (most recent call last): File "manage.py", line 2, in <module> from django.core.management import execute_manager ImportError: No module named django.core.management my-computer:~/Django-1.1.1/django_bookmarks mycomp$ export PATH=/Users/mycomp/bin:

manage.py syncdb doesn't add tables for some models

☆樱花仙子☆ 提交于 2019-12-22 08:45:24
问题 My second not-so-adept question of the day: I have a django project with four installed apps. When I run manage.py syndb, it only creates tables for two of them. To my knowledge, there are no problems in any of my models files, and all the apps are specified in INSTALLED_APPS in my settings file. Manage.py syndb just seems to ignore two of my apps. One thing that is unique about the two "ignored" apps is that the models files import models from the other two apps and use them as foreign keys

Can I use a database view as a model in Django?

馋奶兔 提交于 2019-12-17 10:34:13
问题 i'd like to use a view i've created in my database as the source for my django-view. Is this possible, without using custom sql? ******13/02/09 UPDATE*********** Like many of the answers suggest, you can just make your own view in the database and then use it within the API by defining it in models.py. some warning though: manage.py syncdb will not work anymore the view need the same thing at the start of its name as all the other models(tables) e.g if your app is called "thing" then your

Django - Why doesn't syncdb respect the database router?

我是研究僧i 提交于 2019-12-12 12:35:33
问题 I have set up a database router to direct different apps and different models to different databases using the db_for_read and db_for_write router methods. That works very well, except that ./manage.py syncdb does't respect those router settings. When I syncdb my models, all of them are created in the default database. The database router only provides an allow_syncdb method, but no sync_to method. Is there a way to tell the syncdb command where to create the new tables? Note: I can't use the

Django Is telling me table already exists on syncdb - can't figure out why

烈酒焚心 提交于 2019-12-11 12:37:08
问题 Posted the model at http://pastebin.com/f609771cc getting error: (yes it's windows) File "C:\Python25\lib\site-packages\MySQLdb\connections.py", line 35, in defaulterrorhandler raise errorclass, errorvalue _mysql_exceptions.OperationalError: (1050, "Table 'memorial_music' already exists") scanned the whole project directory and memorial_music is only referenced twice once as a table name and once as table name 'memorial_music_category' this one has me scratching my head, any ideas? 回答1: