小编Cra*_*pus的帖子

Django 1.7冲突的模型

我在"project/apps/myapp"文件夹中安装我的应用程序.apps和myapp文件夹都有init .py文件(没有任何模块缺少模块错误).现在我有错误:

Exception Type: RuntimeError at /
    Exception Value: Conflicting 'person' models in application 'resume': <class
 'apps.resume.models.Person'> and <class 'resume.models.Person'>.
Run Code Online (Sandbox Code Playgroud)

Django使用两个不同的pathes导入相同的模型.我该如何解决?

完整错误日志:

Traceback:
File "/home/voxa/.virtualenvs/42-test/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  98.                 resolver_match = resolver.resolve(request.path_info)
File "/home/voxa/.virtualenvs/42-test/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve
  343.             for pattern in self.url_patterns:
File "/home/voxa/.virtualenvs/42-test/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in url_patterns
  372.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/voxa/.virtualenvs/42-test/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in urlconf_module
  366.             self._urlconf_module = import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/__init__.py" in import_module
  37.     __import__(name)
File "/home/voxa/django/FortyTwoTestTask/fortytwo_test_task/urls.py" in <module>
  4. from resume import views
File "/home/voxa/django/FortyTwoTestTask/apps/resume/views.py" in <module>
  4. from …
Run Code Online (Sandbox Code Playgroud)

django python-module django-models

23
推荐指数
2
解决办法
8417
查看次数

Django 测试错误安装夹具 - 没有这样的表

运行“python manage.py test”后出现奇怪的错误

django.db.utils.OperationalError: Problem installing fixture 
'/home/voxa/django/test_test/resume/fixtures/initial_data.json': Could not load 
resume.Person(pk=1): no such table: resume_person
Run Code Online (Sandbox Code Playgroud)

但是我使用了与“python manage.py loaddata initial_data.json”相同的装置

更新:

测试.py

from django.test import TestCase
from django.test import Client

from resume.models import Person

class ResumeTest(TestCase):

    def test_model(self):
        bio = Person(first_name="Homer", last_name="Simpson", birth_date="04.02.1978", email="mail@gmail.com", jabber="jabber@jabbim.com", skype="skype", other_contacts="tel: +380975322155", bio="Was born...")

    def test_index(self):
        client = Client()
        response = client.get('/')
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "Volodymyr")
Run Code Online (Sandbox Code Playgroud)

django unit-testing django-fixtures

3
推荐指数
1
解决办法
3206
查看次数