I have pulled myproject updates from bitbucket and tried following commands 'python3 manage.py makemigrations', 'python3 manage.py migrate vehicle', 'python3 manage.py migrate'. But I am getting the following error. vehicle app is new and some of its models use foreign keys from other apps which were migrated before and are in database. I tried different ways, but cannot find the solution. I am using django-1.7.4 I appreciate any advice.
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...
vehicle app, make model:
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',
)
for what i've seen, I tries to validade the AdvancedVehicleSearchForm before it runs the migration, try to pass the form related to the vehicle to the vehicle app in the way django can makes the migration first. I can't help you more for the files you show there sorry. I hope it helps you somehow
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments