syncdb

manage.py syncdb error while Django model using non-ascii verbose_name

懵懂的女人 提交于 2019-12-11 13:39:40
问题 I am pretty new to Django. I want the name of my models to be displayed in Chinese, so i used verbose_name in my meta class of my model, codes below: #this models.py file is encoded in unicode class TS_zone(models.Model): index = models.IntegerField() zone_name = models.CharField(max_length=50); zone_icon = models.ImageField(upload_to='zone_icon', null=True) is_active = models.NullBooleanField(blank=True, null=True) status = models.CharField(max_length=7,choices=SETTING_STATUS_CHOICES) class

heroku: relation “auth_group” does not exist

随声附和 提交于 2019-12-07 12:30:59
问题 I'm facing problem while doing syncdb on heroku. I have a custom user model and when I try to sync,heroku gives this error. django.db.utils.ProgrammingError: relation "auth_group" does not exist I tried python manage.py makemigrations but nothing is getting resolved. Help me find the solution. 回答1: I just had a similar problem. It seems that the auth module should be the first module to migrate but for some reason that isn't happening. All what I did to solve this was ./manage.py migrate auth

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

ContentType matching query does not exist on post_syncdb

天涯浪子 提交于 2019-12-01 08:36:01
I am trying to add add some data to the database as soon as tables are created, using the post_syncdb signal. signals.post_syncdb.connect(init) Then in the init function, I want to set permission, so I use ct = ContentType.objects.get(app_label='news', model='Article') Permission(name='Approve articles', codename='can_approve_article', content_type=ct) But if I drop all the tables and run syncdb , I get ... File "...\base\functions\init.py", line 11, in init ct = ContentType.objects.get(app_label='news', model='Article') ... django.contrib.contenttypes.models.DoesNotExist: ContentType matching

django: update database schema without losing data

纵饮孤独 提交于 2019-11-30 07:32:50
What is the best solution if I want to upgrade (alter) my database schema (add new fields to tables by adding them just to django models) without losing data in these tables? "syncdb" not adding them of course, so I need your advices how to alter tables without deleting them and recreating again with syncdb. Thanks, Ignas James Khoury When south isn't an option I just manually write scripts for small changes. and big ones i use ./manage.py dumpdata appname http://docs.djangoproject.com/en/dev/ref/django-admin/#dumpdata-appname-appname-appname-model Throw that into a file. Run a regex replace

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

别等时光非礼了梦想. 提交于 2019-11-29 15:02:44
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

django: update database schema without losing data

喜夏-厌秋 提交于 2019-11-29 09:56:04
问题 What is the best solution if I want to upgrade (alter) my database schema (add new fields to tables by adding them just to django models) without losing data in these tables? "syncdb" not adding them of course, so I need your advices how to alter tables without deleting them and recreating again with syncdb. Thanks, Ignas 回答1: When south isn't an option I just manually write scripts for small changes. and big ones i use ./manage.py dumpdata appname http://docs.djangoproject.com/en/dev/ref

Postgresql socket error on OSX 10.7.3 when running Django's syncdb

社会主义新天地 提交于 2019-11-27 12:28:34
问题 Since upgrading OSX to version 10.7.3, when I attempt to run a Django "syncdb" command, I receive the following psycopg2 error from Postgresql 8.4.2: psycopg2.OperationalError: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"? I'm able to open psql without incident, but when I attempt to run "pg_ctl status", I receive this error as well: pg_ctl: could not open PID file "