[Python] Circular references Django migration problem
Carlos Catucci
carlos.catucci a gmail.com
Gio 18 Giu 2015 17:52:07 CEST
Ho un simpatico side effects, eseguendo una makemigrations (a meno che non
abbia la cartella migrations vuota, ma in tal caso provvede gentilmente la
successiva migrate a dare il side effect) ottengo un messaggio come questo
(server)globex a Globex:~/server/globextest$ ./manage.py migrate
Operations to perform:
Synchronize unmigrated apps: apis_manage, socials_manage, users_manage,
data_filler, statistics_manage, recensioni_manage, corsheaders
Apply all migrations: messages_manage, hosters_manage, sessions, admin,
auth, contenttypes, push_notifications, routers_manage
Synchronizing apps without migrations:
Creating tables...
Installing custom SQL...
Installing indexes...
Running migrations:
No migrations to apply.
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File
"/home/globex/server/local/lib/python2.7/site-packages/django/core/management/__init__.py",
line 385, in execute_from_command_line
utility.execute()
File
"/home/globex/server/local/lib/python2.7/site-packages/django/core/management/__init__.py",
line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File
"/home/globex/server/local/lib/python2.7/site-packages/django/core/management/base.py",
line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File
"/home/globex/server/local/lib/python2.7/site-packages/django/core/management/base.py",
line 338, in execute
output = self.handle(*args, **options)
File
"/home/globex/server/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
line 153, in handle
executor.loader.project_state(),
File
"/home/globex/server/local/lib/python2.7/site-packages/django/db/migrations/loader.py",
line 272, in project_state
return self.graph.make_state(nodes=nodes, at_end=at_end,
real_apps=list(self.unmigrated_apps))
File
"/home/globex/server/local/lib/python2.7/site-packages/django/db/migrations/graph.py",
line 158, in make_state
for migration in self.forwards_plan(node):
File
"/home/globex/server/local/lib/python2.7/site-packages/django/db/migrations/graph.py",
line 60, in forwards_plan
return self.dfs(node, lambda x: self.dependencies.get(x, set()))
File
"/home/globex/server/local/lib/python2.7/site-packages/django/db/migrations/graph.py",
line 124, in dfs
self.ensure_not_cyclic(start, get_children)
File
"/home/globex/server/local/lib/python2.7/site-packages/django/db/migrations/graph.py",
line 112, in ensure_not_cyclic
raise CircularDependencyError(", ".join("%s.%s" % n for n in cycle))
django.db.migrations.graph.CircularDependencyError:
hosters_manage.0002_auto_20150609_0820, hosters_manage.0001_initial,
messages_manage.0001_initial
I models coinvolti sono i seguenti
users_manage - models.py
from django.db import models
#from hosters_manage.models import Hosters, HostersAddress
# Create your models here.
class FirstName(models.Model):
first_name = models.CharField(max_length=100)
#class Invitation(models.Model):
# inviting = models.ForeignKey("Users", related_name='invitante')
# invited = models.ForeignKey("Users", related_name='invitato')
class LastName(models.Model):
last_name = models.CharField(max_length=100)
class Users (models.Model):
email = models.EmailField()
password = models.CharField(max_length=100)
mac_address = models.CharField(max_length=100)
uuid = models.CharField(max_length=100)
telefono = models.CharField(max_length=30)
active = models.BooleanField(default=False)
deleted = models.BooleanField(default=False)
class UsersData(models.Model):
USER_TYPES = (
('1','Normale'),
('1','Pro'),
('1','Super'),
('1','Mega'),
)
users_id = models.ForeignKey("Users")
nome = models.CharField(max_length=100)
cognome = models.CharField(max_length=100)
nickname = models.CharField(max_length=100)
avatar = models.CharField(max_length=300)
data_nascita = models.DateField()
sesso = models.CharField(max_length=1)
eta = models.IntegerField()
latitudine = models.FloatField(default=0.0,blank=True,null=True)
longitudine = models.FloatField(default=0.0,blank=True,null=True)
codice = models.CharField(max_length=10)
conto = models.FloatField(default=2.0,blank=True,null=True)
activation_data =
models.DateTimeField(auto_now_add=True,null=True,blank=True)
tipo_utente = models.CharField(max_length=1,choices=USER_TYPES)
#registrar =
models.ForeignKey("hosters_manage.HostersAddress",null=True,blank=True)
changed = models.BooleanField(default=False)
conto_paypal = models.TextField()
device = models.CharField(max_length=100,null=True, blank=True)
platform = models.CharField(max_length=100,null=True, blank=True)
version = models.CharField(max_length=100,null=True, blank=True)
last_lat = models.FloatField(null=True, blank=True)
last_lng = models.FloatField(null=True, blank=True)
invited_by = models.ForeignKey("Users",null=True,blank=True,
related_name='invitato_da')
token = models.CharField(max_length=300)
hosters_manage - models.py
from django.db import models
from jsonfield import JSONField
#from statistics_manage.models import Categories
#from messages_manage.models import HostersMessages
#from users_manage.models import Users
# Create your models here.
class Hosters(models.Model):
ragione_sociale = models.CharField(max_length=100) #,unique=True)
categories = models.ForeignKey("statistics_manage.Categories", default=0,
null=True, blank=True)
active = models.BooleanField(default=False)
deleted = models.BooleanField(default=False)
class HostersAddress(models.Model):
hoster = models.ForeignKey("Hosters")
logo = models.CharField(max_length=300,blank=True,null=True)
indirizzo = models.CharField(max_length=100, default='')
cap = models.CharField(max_length=10, default='')
localita = models.CharField(max_length=100, default='')
provincia = models.CharField(max_length=10, default='')
telefono = models.CharField(max_length=30, null=True, blank=True)
fax = models.CharField(max_length=30, null=True, blank=True)
email = models.CharField(max_length=100, null=True, blank=True)
descrizione = models.TextField(null=True,blank=True)
latitudine = models.FloatField(default=0.0)
longitudine = models.FloatField(default=0.0)
primary = models.NullBooleanField(default=True, null=True, blank=True)
wifi_quality = models.IntegerField(default=1)
link_fb = models.CharField(max_length=300,null=True,blank=True)
rating = models.FloatField(default=0.0)
active = models.NullBooleanField(default=False, null=True, blank=True)
deleted = models.NullBooleanField(default=False, null=True, blank=True)
user_attorney = models.ForeignKey("users_manage.Users", null=True,
blank=True, related_name="user_attorney")
class Meta:
unique_together = (('hoster', 'indirizzo','cap','localita','provincia'),)
class HostersAddressMedia(models.Model):
MEDIA_TYPES = (
('1', 'FOTO'),
('2', 'VIDEO'),
('3', 'AUDIO'),
)
hoster_address = models.ForeignKey("HostersAddress")
tipo = models.CharField(max_length=1, choices=MEDIA_TYPES)
media = JSONField()
pubblicato = models.BooleanField(default=True)
class UsersHosters(models.Model):
user = models.ForeignKey("users_manage.Users")
hoster = models.ForeignKey("messages_manage.HostersMessages")
preferred = models.BooleanField(default=False)
class Meta:
unique_together = (('user', 'hoster'),)
Ho provato di ogni da googolare a dare testate sul muro (non la mia di
testa ovviamente) ma senza risultato.
La versione django e' la 1.7.6 final 0
Sugerimenti?
Gracias
Carlos
--
EZLN ... Para Todos Todo ... Nada para nosotros
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.python.it/pipermail/python/attachments/20150618/7ae501eb/attachment-0001.html>
Maggiori informazioni sulla lista
Python