django-syncdb

Django workflow when modifying models frequently?

会有一股神秘感。 提交于 2019-12-03 18:20:54
问题 as I usually don't do the up front design of my models in Django projects I end up modifying the models a lot and thus deleting my test database every time (because "syncdb" won't ever alter the tables automatically for you). Below lies my workflow and I'd like to hear about yours. Any thoughts welcome.. Modify the model. Delete the test database. (always a simple sqlite database for me.) Run "syncdb". Generate some test data via code. goto 1. A secondary question regarding this.. In case

Django flush vs sqlclear & syncdb

爱⌒轻易说出口 提交于 2019-12-03 08:40:25
问题 Can anyone tell if there is a difference between >manage.py flush # or reset and >manage.py sqlclear appname | python manage.py dbshell >manage.py syncdb 回答1: flush will truncate (delete data) sqlclear will drop (delete table, thus data too) => if you have structural modifications in your db, you have to do sqlclear (but better use south) Update: South has been deprecated. From Django 1.7 upwards, migrations are built into the core of Django. If you are running a previous version, you can use

Testing Django apps that use South migrations

前提是你 提交于 2019-12-03 03:38:11
问题 I'm trying to create some Functional tests for a Django app that uses South migrations. Eventually, I will also be creating Twill tests. When I try to run the existing tests, the test database is not created successfully because of a problem with the South migrations. ( Fails @ 7th of 58 migrations ) It would seem that for the purpose of testing, it's better to build the test database from the Django models, like a syncdb would, than from South. How do I set up the Django test suite to build

auth_user error with Django 1.8 and syncdb / migrate

佐手、 提交于 2019-12-02 17:24:49
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? I fix this by running auth first, then the rest of my migrations: python manage.py migrate auth python manage.py migrate On my environment, I fix

Testing Django apps that use South migrations

南笙酒味 提交于 2019-12-02 17:07:25
I'm trying to create some Functional tests for a Django app that uses South migrations. Eventually, I will also be creating Twill tests. When I try to run the existing tests, the test database is not created successfully because of a problem with the South migrations. ( Fails @ 7th of 58 migrations ) It would seem that for the purpose of testing, it's better to build the test database from the Django models, like a syncdb would, than from South. How do I set up the Django test suite to build the test database from the current model vs. trying to use South? Leopd The South setting SOUTH_TESTS

Django/Python EnvironmentError?

◇◆丶佛笑我妖孽 提交于 2019-11-29 23:23:06
问题 I am getting an error when I try to use syncdb : python manage.py syncdb Error message: File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 83, in __init__ raise EnvironmentError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e) EnvironmentError: Could not import settings '/home/simi/workspace/hssn_svn/hssn' (Is it on sys.path? Does ti have syntax errors?): Import by filename is not supported. I'm a

Django workflow when modifying models frequently?

那年仲夏 提交于 2019-11-29 19:45:31
as I usually don't do the up front design of my models in Django projects I end up modifying the models a lot and thus deleting my test database every time (because "syncdb" won't ever alter the tables automatically for you). Below lies my workflow and I'd like to hear about yours. Any thoughts welcome.. Modify the model. Delete the test database. (always a simple sqlite database for me.) Run "syncdb". Generate some test data via code. goto 1. A secondary question regarding this.. In case your workflow is like above, how do you execute the 4. step? Do you generate the test data manually or is

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

我怕爱的太早我们不能终老 提交于 2019-11-28 16:49:34
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 with Django models defined against that database. What is the best way to ensure that the database is

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

陌路散爱 提交于 2019-11-27 11:52:39
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 view will need to be called thing_$viewname Since Django 1.1, you can use Options.managed for that. For

Django/Python Beginner: Error when executing python manage.py syncdb - psycopg2 not found

拟墨画扇 提交于 2019-11-26 06:07:13
问题 I have Pythong2.6, psycopg2 and pgAdmin3 installed using Macports. My settings.py is: DATABASE_ENGINE = \'postgresql_psycopg2\' # \'postgresql_psycopg2\', \'postgresql\', \'mysql\', \'sqlite3\' or \'oracle\'. DATABASE_NAME = \'mysite\' # Or path to database file if using sqlite3. DATABASE_USER = \'postgres\' # Not used with sqlite3. DATABASE_PASSWORD = \'\' # Not used with sqlite3. DATABASE_HOST = \'\' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = \'\' # Set to