私はbitbucketからmyprojectのアップデートを取り出し、 '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'に' models.py'と 'INSTALLED_APPS'を与えてください。 –
これらの情報を更新しました。助けてください –