我的迁移文件如下所示:
from __future__ import unicode_literals
from django.db import migrations
from project.tools import do_nothing
def create_can_receive_group(apps, schema_editor):
Group = apps.get_model("django.contrib.auth", 'Group')
# Group operation added here
class Migration(
我正在尝试重命名我的django网站中的一个应用程序。还有另一个依赖于它及其mysql表的应用程序。我查看了两个应用程序中的所有文件,并将旧名称的实例更改为新名称。
但是,现在我在尝试执行迁移时遇到了此错误消息:
File "/Users/Limor/anaconda/lib/python2.7/site-packages/Django-1.10a1-py2.7.egg/django/db/migrations/loader.py", line 287,
in check_consistent_history
migration[0], migration[1], p
我试图按照中的文档创建一个迁移,该迁移实际上将在数据库上执行SQL语句CREATE EXTENSION IF NOT EXISTS hstore;。我尝试将以下名为create_extension_hstore.py的文件添加到migrations目录中:
from django.db import migrations
from django.contrib.postgres.operations import CreateExtension
class Migration(migrations.Migration):
operations = [CreateExtension(
enter code here(kemgo-api-v2) ronnie@vax-PC-88:/var/www/html/kemgo-api-v2$ python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
Unhandled exception in thread started by <function wrapper at 0x7f22b50abcf8>
Traceback (most recent call last):
我在用Django 2.x。
我有一个user_setting模型,它具有Country模型的外键,该模型是在address模块下创建的。
现在,我使用djanog-countries-plus添加Country数据,从而将user_setting模块更改为现在指向django-countries-plus的Country模型。
from countries_plus.models import Country
from django.contrib.auth.models import User
class UserSetting(models.Model):
id = model
我已经为一个特定的Django 1.11应用程序手动创建了一个数据迁移文件:
from __future__ import unicode_literals
from django.db import migrations, models
def set_item_things(apps, schema_editor):
MyModel = apps.get_model('my_app', 'MyModel')
# NOTE: if I remove this line then the tests will work
MyOtherM
我想要做的是将站点显示名称和域从example.com更改为mydomain.com。通常,我可以进入django管理员并执行此操作。但我想使用数据迁移。我的代码如下: from django.db import migrations
def change_site_name_from_example_to_mydomain_func(apps, schema_editor):
Site = apps.get_model('sites', 'Site')
site = Site.objects.get(name='example.c
当我跑的时候
manage.py test myapp
它会因为这个错误而死
Creating test database for alias 'default'...
! Error found during real run of migration! Aborting.
_mysql_exceptions.OperationalError: (1005, "Can't create table
'test_dom.#sql-49b_1a1' (errno: 150)")
我使用south来处理模式迁移,django 1.3和
我正在尝试为我的Django项目运行迁移,但是我得到了错误:
AttributeError: 'ManyToManyField' object has no attribute 'm2m_reverse_field_name'
当我在我的所有应用程序上运行make migrations时,我没有收到任何错误。只有当我尝试实际迁移时才会这样。我不能从回溯信息中看出是哪个模型造成了问题,甚至不知道是哪个应用程序造成的。我已经看过我的模型了,我没有看到任何东西突然出现在我面前。
下面是堆栈跟踪:
Operations to perform:
Apply all m
我正在尝试使用django 1.7原生迁移系统实现数据迁移。这就是我所做的。
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
def create_basic_user_group(apps, schema_editor):
"""Forward data migration that create the basic_user group
"""
Group = app
我想我做错了什么我需要删除它。但我不能修好它。我该怎么做呢?
我迁移,我得到了这个错误
File "C:\Users\HP\Desktop\venv\lib\site-packages\django\db\models\fields\__init__.py", line
1990, in get_prep_value
raise e.__class__(
TypeError: Field 'amount' expected a number but got datetime.datetime(2022, 3, 27, 10, 46,
51
一个源Django 3通过实例,第14章
当我试图运行python manage.py迁移
另一个文件是这本书的副本和粘贴物。
结果是
File "C:\Python\educa\manage.py", line 22, in <module>
main()
File "C:\Python\educa\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\DELL\AppData\Local\Programs\
我最近从django-social-auth转到python-social-auth,但这显然损害了我的迁移系统。每当我尝试迁移更改时,我都会得到以下更改:
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from
我无法启动manage.py runserver 0.0.0.0:8000。我正在使用一个MySQL数据库,并且我已经导入了所有需要的模块。我正在尝试运行非常基本的应用程序。
我在Windows10上运行python 3.7.3。下面是我得到的错误:
System check identified no issues (0 silenced).
Unhandled exception in thread started by <function check_errors.<locals>.wrapper
at 0x0000000005A89E18>
Traceback
我从事一个项目已经有一段时间了,我在移民方面没有遇到任何问题。我决定重置数据库和迁移,这是我经常做的。我删除了所有的迁移,再次进行迁移,在重新创建数据库之后,应用迁移,此时我得到了错误"Migration users.0001_initial is applied before its dependency auth.0012_alter_user_first_name_max_length on database 'default'.“。
现在,auth.0012_alter_user_first_name_max_length显然来自于django.contrib.
我正在尝试迁移这个模型:
class Questionpart_image(models.Model):
questionpart = models.ForeignKey(Questionpart, null=True, blank=True)
image = models.ImageField()
对此:
class Questionpart_image(Questionpart): # notice this base class
image = models.ImageField()
利用遗产。Django产生了以下迁移:
class Migration(migr
我需要创建自定义用户。我在AbstractUser中使用用户模型: from django.contrib.auth.models import AbstractUser
from django.db import models
from django.utils.html import escape, mark_safe
class User(AbstractUser):
is_student = models.BooleanField(default=False)
is_teacher = models.BooleanField(default=False) sett