django-syncdb

Django workflow when modifying models frequently?

Hi gents, 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. De...

can i use a database view as a model in Django?

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 sy...

How to get './manage.py syncdb' to create additional views or run custom SQL?

Is there a way to run some custom SQL statements after syncdb does it thing creating the tables for the models? Specifically, I would like to create some database views. Thanks in advanced. ...

Django syncdb locking up on table creation

I've added new models and pushed to our staging server, run syncdb to create their tables, and it locks up. It gets as far as 'Create table photos_photousertag' and postgres output shows the notice for creation of 'photos_photousertag_id_seq', but otherwise i get nothing on either said. I can't ctrl+c the syncdb process and I have no ind...

Django/Python EnvironmentError?

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: ...

Keep code from running during syncdb

hello again! I have some code that throws causes syncdb to throw an error (because it tries to access the model before the tables are created). Is there a way to keep the code from running on syncdb? something like: if not syncdb: run_some_code() Thanks :) edit: PS - I thought about using the post_init signal... for the code th...

Right way to create custom pgsql types in django

What is the right way to create custom pgsql types for django application so that each time database is created with syncdb, all custom types are created prior to creating any tables (so that tables can use this type)? I also use django-evolution, but that's not an appropriate solution — it runs after syncdb. I can imagine doing a worka...

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

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 m...

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

Hello, 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' # ...

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

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 ...

Django syncdb on SQL initial data using PostgreSQL yields "column ... does not exist"

Platform: Python 2.5, Django development root, PostgreSQL 8.4, Windows Vista Ultimate SP2. Procedure: Django Documentation, Release 1.0, link text, Section 34.2, Providing initial SQL data. CODE: models.py: class aisc_customary(models.Model): MTYPE = models.CharField(max_length=4, editable=False, ...

Automatically create an admin user when running Django's ./manage.py syncdb

My project is in early development. I frequently delete the database and run manage.py syncdb to set up my app from scratch. Unfortunately, this always pops up: You just installed Django's auth system, which means you don't have any superusers defined. Would you like to create one now? (yes/no): Then you have supply a username, vali...

Can someone help clarify my confusion about syncdb and import loops, 'Do you have to be explicit on imports?'

I have been having a difficult time building the database with syncdb on Python2.5. I think that some of this issue is because of the use of wildcard* for importing forum.models it seems to be creating a loop. >>> import settings >>> from forum.managers import QuestionManager, TagManager, AnswerManager, VoteManager, FlaggedItemManager...

What does this error mean: The model User has two manually-defined m2m relations ...

I'm running into this error when I attempt to syncdb: auth.user: The model User has two manually-defined m2m relations through the model FavoriteQuestion, which is not permitted. Please consider using an extra field on your intermediary model instead. I'm really don't understand what it means because I only see 1 model-to-model relation...

manage.py syncbd not syncing django.contrib apps

This is probably a setting error somewhere. I have a django app that works fine on my desktop with the developer server and sqlite3. I upload it to my server and syncdb and it only syncs my custom apps to my database, not the django.contrib apps. My apache config: ServerRoot "/home/myusername/webapps/accounting/apache2" LoadModule ...

Can't get python.manage.py syncdb to work

I just created my first django app, initialized variables DATABASE_ENGINE and DATABASE_NAME in settings.py, but now when I run python manage.py syncdb, I get the following error Can somebody help? Does this have to do with having two python versions installed? I'm a django/python noob, please help. thanks!! my-computer:~/Django-1.1.1 m...

django manage.py syncdb not working?

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.manage...

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

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 d...

How *not* to run Django code on syncdb

Hello, I have some server startup code that is lying in the "models.py" of one of my Django apps. I need to run that code on server startup time. The problem is, that code issues a SQL query, which prevents me from running syncdb with psycopg2 (it breaks the transaction, and tables are not created.) Putting the code in a middleware an...