syncdb

ContentType matching query does not exist on post_syncdb

三世轮回 提交于 2020-01-21 08:40:07
问题 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

stale content types while syncdb in Django

拟墨画扇 提交于 2020-01-12 04:32:46
问题 While I'm trying to syncdb for my django project, I'm seeing following complains: The following content types are stale and need to be deleted: myapp | Any objects related to these content types by a foreign key will also be deleted. Are you sure you want to delete these content types? If you're unsure, answer 'no'. While I've also read the similar problem django-syncdb-many-to-many-stale, but I cannot risk myself typing yes since I'm on prod instance. Would yes safely delete those stale

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

谁说我不能喝 提交于 2020-01-10 05:11:27
问题 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

Django unit-testing with loading fixtures for several dependent applications problems

痴心易碎 提交于 2019-12-24 10:58:02
问题 I'm now making unit-tests for already existing code. I faced the next problem: After running syncdb for creating test database, Django automatically fills several tables like django_content_type or auth_permissions. Then, imagine I need to run a complex test, like check the users registration, that will need a lof ot data tables and connections between them. If I'll try to use my whole existing database for making fixtures (that would be rather convinient for me) - I will receive the error

Before syncdb, delete field from standard Django model

时光总嘲笑我的痴心妄想 提交于 2019-12-24 06:48:49
问题 This is a follow-up question on Delete field from standard Django model. In short: a field can be dynamically deleted from a model that is already created, in this case the field User.email . So field email would be deleted from User without changing the code for User. See code below for example. I can dynamically delete a a field from a model(1), but that happens when the server starts and is undone when it exists. Since syncdb doesn't require the server to be running, and generally seems to

OperationalError: no such table on initial syncdb

此生再无相见时 提交于 2019-12-24 03:02:34
问题 I'm running syncdb to create an sqlite db. It was working until recently, and I don't see anything I've changed that would cause it to fail. Mostly I just changed some field names. I have the following in models.py: class GC_User(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) email = models.EmailField() wp_userID = models.PositiveSmallIntegerField(unique=True) When I run syncdb after deleting the old db file, I get 150 lines of

Django 1.8, syncdb not working, throwing a foreign key constraint error

断了今生、忘了曾经 提交于 2019-12-24 02:56:24
问题 Since I upgrade to Django 1.8 from 1.7, I have got this foreign key constraint error. File "c:project\env\lib\site-packages\mysql_python-1.2.5-py2.7-win32.egg/MySQLdb\connections.py line 36, in defaulterrorhandler raise errorclass, errorvalue, Django.db.utils.IntergrityError: 'Cannot add foreing key contraint What's some wrong with django 1.8 (latest version)? 回答1: Try this DATABASES = { 'default': { ... 'OPTIONS': { "init_command": "SET foreign_key_checks = 0;", }, 'STORAGE_ENGINE': 'MyISAM

Why do I get this error when I run “python manage.py syncdb --all”?

好久不见. 提交于 2019-12-23 10:14:34
问题 I am trying to apply tutorial http://docs.django-cms.org/en/2.1.3/getting_started/tutorial.html. But I didn't succeed to perform the initial database setup Why do I get this error when I run "python manage.py syncdb --all" ? Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line utility.execute() File "C:\Python27\lib\site

Django syncdb and migrate

北城以北 提交于 2019-12-18 11:27:29
问题 I'm moving django website from one server to another, and I tried to syncdb, so i've put python manage.py syncdb , and i get this output: Syncing... Creating tables ... The following content types are stale and need to be deleted: orders | ordercontact Any objects related to these content types by a foreign key will also be deleted. Are you sure you want to delete these content types? If you're unsure, answer 'no'. Type 'yes' to continue, or 'no' to cancel: no Installing custom SQL ...

Can I create database tables automatically in Laravel like Django's 'python manage syncdb'?

倾然丶 夕夏残阳落幕 提交于 2019-12-13 04:55:00
问题 I came from Django(Python) background and these days I'm working on a project which is based on Laravel(PHP).Do I have some option like generating database tables automatically? 回答1: Yes, using the Schema Builder and Migrations. First you need to install the migrations table to the DB: $ php artisan migrate:install then create a migration $ php artisan migrate:make create_users_table this will create a PHP file in application/migrations . You may now edit it to have the settings you want, i.e