Tag: django 1.8

更新到Django 1.8 – AttributeError:django.test.TestCase没有属性'cls_atomics'

我更新了Django 1.7项目到Django 1.8,现在运行testing(是django.test.TestCase子类)时会出错。 Traceback (most recent call last): File "env\lib\site-packages\django\test\testcases.py", line 962, in tearDownClass cls._rollback_atomics(cls.cls_atomics) AttributeError: type object 'SomeTests' has no attribute 'cls_atomics' 如果我通过testing进行debugging,则可以顺利执行所有行,但在最后一行之后会引发exception。 这是一个示例testing: import django import unittest from django.test import TestCase import logging import sys from builtins import classmethod, isinstance class ATestTests(TestCase): @classmethod def setUpClass(cls): django.setup() logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) def setUp(self): self._app = Application(name="a") […]

如何在使用–fake之后在django 1.8上重新进行迁移

我的迁移出了点问题,我添加了一个新的datetimefield到模型,然后我使用makemigrations进行迁移。 python manage.py makemigrations python manage.py migrate 但在此之后迁移得到了“表已经存在的错误”。 我想我可以伪造移民,重新开始,所以我做了 python manage.py makemigrations –fake core Operations to perform: Apply all migrations: core Running migrations: Rendering model states… DONE Applying core.0001_initial… FAKED Applying core.0002_auto_20150525_1331… FAKED Applying core.0003_auto_20150525_1348… FAKED Applying core.0004_processo_data_atualizacao… FAKED 但我刚刚创build的新迁移也是假的(当然!)。 在做这个之后,重做迁移的方法是什么(在这里是core.0004)?

在Django 1.8和Python 2.7.8中填充时,“模型尚未加载”错误

我正在使用此代码来填充我的数据库: import os def populate(): python_cat = add_cat('Python') add_page(cat=python_cat, title="Official Python Tutorial", url="http://docs.python.org/2/tutorial/") add_page(cat=python_cat, title="How to Think like a Computer Scientist", url="http://www.greenteapress.com/thinkpython/") add_page(cat=python_cat, title="Learn Python in 10 minutes", url="http://www.korokithakis.net/tutorials/python/") django_cat = add_cat(name="Django") add_page(cat=django_cat, title="Official Django Tutorial", url="http://djangoproject.com/en/1.5/intro/tutorial01/") add_page(cat=django_cat, title="Django Rocks", url="http://www.djangorocks.com/") add_page(cat=django_cat, title="How to Tango with Django", url="htttp://www.tangowithdjango.com/") frame_cat = add_cat(name="Other Frameworks") add_page(cat=frame_cat, title="Bottle", url="http://bottlepy.org/docs/dev/") […]

Django 1.8和syncdb / migrate引发的auth_user错误

升级到Django 1.8(使用zc.buildout)并运行syncdb或迁移时,我收到以下消息: django.db.utils.ProgrammingError: relation "auth_user" does not exist 我的一个模型包含django.contrib.auth.models.User: user = models.ForeignKey( User, related_name='%(app_label)s_%(class)s_user', blank=True, null=True, editable=False ) 降级到Django 1.7将消除错误。 我必须在Django 1.8中包含User对象吗?

在Django 1.9中我应该用什么来代替syncdb?

看看这个: $ pypy ./manage.py syncdb /usr/lib64/pypy-2.4.0/site-packages/django/core/management/commands/syncdb.py:24: RemovedInDjango19Warning: The syncdb command will be removed in Django 1.9 warnings.warn("The syncdb command will be removed in Django 1.9", RemovedInDjango19Warning) (cut) 我跑了一个快速的谷歌search ,但无法find答案 – 我应该用什么,而不是syncdb ?