Найти - Пользователи
Полная версия: Ошибка миграции 1.6.7=>1.7.1
Начало » Django » Ошибка миграции 1.6.7=>1.7.1
1
eboome
Здраствуйте! Нужно мигрировать проект, который начали писать на 1.6.7
что уже выполнялось:
1. установили Джанго 1.7.1: pip instal -U Django
2. Потом делаю миграцию ./manage.py migrate но у меня ошибка:
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 89, in populate
    "duplicates: %s" % app_config.label)
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: messages

Если откатиться на 1.6.7 то всё работает отлично
Alen
Версия 1.6 + south и версия 1.7 не совместимы по миграциям, 1.7 не умеет старые миграции south.
Старые файлы миграций надо либо удалять, либо переместить в другую директорию.
eboome
Alen
Версия 1.6 + south и версия 1.7 не совместимы по миграциям, 1.7 не умеет старые миграции south.Старые файлы миграций надо либо удалять, либо переместить в другую директорию.

все мигрировалось, причина в дублированом названии в Instaled_apps


правда теперь никак не могу отобразить модели в админке….
вот модель:
from django.conf import settings
from django.db import models
from django.contrib.auth.models import User
from django.contrib.auth.models import AbstractUser
class Organizations(models.Model):
    org_name = models.CharField(max_length = 50)
    org_address = models.TextField()
    org_rate = models.DecimalField(max_digits=3, decimal_places=2)
    org_owner = models.CharField(max_length = 50)
    def __unicode__(self):
        return self.org_name
    class Meta:
      db_table = 'organizations'
      verbose_name_plural = "Organizations"
      ordering = ['org_name']
class Profiles(AbstractUser):
    organization = models.ForeignKey(Organizations)
    pid = models.ForeignKey('self', blank=True, null=True)
    path = models.CharField(max_length = 50)
    address = models.TextField()
    phone = models.IntegerField(max_length=13, unique=True)
    user_ip = models.GenericIPAddressField(unpack_ipv4=False)
    def __unicode__(self):
        return self.username
    class Meta:
      db_table = 'profiles'
      verbose_name_plural = "Profiles"
    
class Documents(models.Model):
    owner = models.ForeignKey(settings.AUTH_USER_MODEL)
    doc = models.FileField(upload_to = 'file_archive/')
       
    class Meta:
      db_table = 'documents'
      verbose_name_plural = "Documents"

admin.py:
class ProfilesAdmin(admin.ModelAdmin):
    list_display = ('organization', 'address','phone', )
    list_filter = ('organization',)
    search_fields = ('phone',)
    #cant edit this field
    #exclude = ('pid','path',)
    #readonly_fields = ('user',)
    #fields = (('owner','created'),'text',)
    list_per_page = 50
class OrganizationAdmin(admin.ModelAdmin):
    list_display = ('org_name','org_address','org_owner',)
    list_filter = ('org_rate',)
    search_fields = ('org_name','org_owner')
    list_per_page = 10
admin.site.register(profiles, ProfilesAdmin)
admin.site.register(organizations, OrganizationAdmin)
в сеттингах так же прописал
Alen
eboome
все мигрировалось, причина в дублированом названии в Instaled_apps

Это как? https://docs.djangoproject.com/en/dev/topics/migrations/

Upgrading from South
If you already have pre-existing migrations created with South, then the upgrade process to use django.db.migrations is quite simple:

Ensure all installs are fully up-to-date with their migrations.
Remove ‘south’ from INSTALLED_APPS.
Delete all your (numbered) migration files, but not the directory or __init__.py - make sure you remove the .pyc files too.
Run python manage.py makemigrations. Django should see the empty migration directories and make new initial migrations in the new format.
Run python manage.py migrate. Django will see that the tables for the initial migrations already exist and mark them as applied without running them.
That’s it! The only complication is if you have a circular dependency loop of foreign keys; in this case, makemigrations might make more than one initial migration, and you’ll need to mark them all as applied using:

python manage.py migrate –fake yourappnamehere


eboome
Alen
я не использовал South
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB