我已經從bitbucket中提取了項目更新並嘗試了以下命令'python3 manage.py makemigrations','python3 manage.py migrate vehicle','python3 manage.py migrate'。但是我收到以下錯誤。車輛應用程序是新的,它的一些模型使用其他應用程序的外鍵,這些應用程序之前已經遷移過,並且在數據庫中。我嘗試了不同的方式,但找不到解決方案。我正在使用django-1.7.4我很欣賞任何建議。Django:不存在關係
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/apps/project/beta/apps/site/admin.py", line 7, in <module>
from .forms import MenuSubItemAdminForm, MenuChildrenAdminForm
File "/apps/project/beta/apps/site/forms.py", line 18, in <module>
class AdvancedVehicleSearchForm(forms.Form):
File "/apps/project/beta/apps/site/forms.py", line 24, in AdvancedVehicleSearchForm
make_choices = [(make.id, '{} ({})'.format(make.name, make.stock_count)) for make in Make.objects.get_public().filter(stock_count__gt=0)]
File "/apps/project/.virtualenvs/beta/lib/python3.5/site-packages/django/db/models/query.py", line 141, in __iter__
self._fetch_all()
File "/apps/project/.virtualenvs/beta/lib/python3.5/site-packages/django/db/models/query.py", line 966, in _fetch_all
self._result_cache = list(self.iterator())
File "/apps/project/.virtualenvs/beta/lib/python3.5/site-packages/django/db/models/query.py", line 265, in iterator
for row in compiler.results_iter():
File "/apps/project/.virtualenvs/beta/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 700, in results_iter
for rows in self.execute_sql(MULTI):
File "/apps/project/.virtualenvs/beta/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 786, in execute_sql
cursor.execute(sql, params)
File "/apps/project/.virtualenvs/beta/lib/python3.5/site-packages/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/apps/project/.virtualenvs/beta/lib/python3.5/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/apps/project/.virtualenvs/beta/lib/python3.5/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/apps/project/.virtualenvs/beta/lib/python3.5/site-packages/django/utils/six.py", line 658, in reraise
raise value.with_traceback(tb)
File "/apps/project/.virtualenvs/beta/lib/python3.5/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "vehicle_make" does not exist
LINE 1: ..."."country_id", "vehicle_make"."stock_count" FROM "vehicle_m...
車輛應用,使模型:
from django.db import models
from django.utils.text import slugify
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from apps.location.models import Country
from project.abstract_classes import BaseModel, BaseManager
from .constants import FUEL_CHOICES, GEARBOX_GROUP_CHOICES, VEHICLE_TYPE_CHOICES
# Create your models here.
class Make(BaseModel):
name = models.CharField(_('name'), max_length=50, unique=True, db_index=True)
country = models.ForeignKey(Country, on_delete=models.CASCADE,
null=True, related_name='makes')
stock_count = models.PositiveIntegerField(_("Stock count"), default=0)
objects = BaseManager()
class Meta:
ordering = ['country', 'name']
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse('vehicles-stock-by-make', kwargs={'make': slugify(self.name)})
settings.py
INSTALLED_APPS = (
'django.contrib.admin',
'easy_thumbnails',
'adminsortable',
'apps.location',
'apps.vehicle',
)
請給我們'settings.py'和'INSTALLED_APPS'上'settings.py' –
更新這些信息。請幫助 –