(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py migrate
Operations to perform:
Synchronize unmigrated apps: colleges, ads, debug_toolbar, comments, communities, main, athletes, ad_manager
Apply all migrations: admin, contenttypes, sites, auth, sessions
Synchronizing apps without migrations:
Creating tables...
Creating table athletes_athlete_athletecolleges
Creating table athletes_athlete_athletecommunities
Creating table athletes_athlete
Creating table athletes_registrationprofile
Creating table colleges_college
Creating table colleges_collegeevent_attendees
Creating table colleges_collegeevent
Creating table communities_community
Creating table communities_country
Creating table communities_city
Creating table communities_communitypost_city
Creating table communities_communitypost_country
Creating table communities_communitypost
Creating table comments
Creating table comment_flags
Creating table main_teammember
Creating table ads_partner
Creating table ads_ad
Creating table ad_manager_target
Creating table ad_manager_adgroup
Creating table ad_manager_ad
Creating table ad_manager_pagetype
Creating table ad_manager_adtype
Creating table ad_manager_tagtype
Installing custom SQL...
Installing indexes...
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying sessions.0001_initial... OK
Applying sites.0001_initial... OK
Next up I called to create a super user and that went fine as well:
(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py createsuperuser
Username (leave blank to use 'jjz'):
Email address:
Password:
Password (again):
Superuser created successfully.
Then I ran the makemigrations command for the respective apps and their models that I wanted to have:
(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py makemigrations colleges
Migrations for 'colleges':
0001_initial.py:
- Create model College
- Create model CollegeEvent
(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py makemigrations ads
Migrations for 'ads':
0001_initial.py:
- Create model Ad
- Create model Partner
- Add field partner to ad
(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py makemigrations comments
Migrations for 'comments':
0001_initial.py:
- Create model Comment
- Create model CommentFlag
- Alter unique_together for commentflag (1 constraint(s))
(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py makemigrations communities
Migrations for 'communities':
0001_initial.py:
- Create model City
- Create model Community
- Create model CommunityPost
- Create model Country
- Add field country to communitypost
- Add field user to communitypost
(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py makemigrations main
Migrations for 'main':
0001_initial.py:
- Create model TeamMember
(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py makemigrations athletes
Migrations for 'athletes':
0001_initial.py:
- Create model Athlete
- Create model RegistrationProfile
Up until this point I had no concerns, things seemed to be working as expected, but what happened next stunned me. The migrate command hung it just sat there seemingly doing nothing. I hit command c to cancel because I'm on a mac thinking maybe I had done something wrong and it wouldn't happen again but it continues.
I tried to run runserver next:
(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
^C(zcosystem)jjs-macbook-pro:athletesunited JJZ$ python manage.py migrate
^C
As you can see it hung and I had to cancel and hit command c on both runserver and the following migrate.
Sorry for the wall of text but I just want to put this all out there in case it gives any awareness. Anyways, here is my speculation to what is causing the "endless loop" within my models, I say this because I didn't have this issue up until I started messing with this part of my models. Here is one of those models (because it has the user FK):
# College Event
class CollegeEvent(models.Model):
collegeid = models.CharField(max_length=30)
user = models.ForeignKey('athletes.Athlete', verbose_name=_('user'), blank=True, null=True, related_name="%(class)s_events")
creatorname = models.CharField(max_length=30)
creatorurl = models.CharField(max_length=30)
ispublished = models.BooleanField(default=False)
name = models.CharField(max_length=30)
description = models.TextField()
startdate = models.CharField(max_length=30)
enddate = models.CharField(max_length=30)
attendees = models.ManyToManyField(settings.AUTH_USER_MODEL, null=True, blank=True)
objects = models.Manager()
ceobjects = CollegeEventManager()
def __unicode__(self):
return self.name
def get_creator_full_name(self):
return self.user.first_name + " " + self.user.last_name
The key line being:
user = models.ForeignKey('athletes.Athlete', verbose_name=_('user'), blank=True, null=True, related_name="%(class)s_events")
# Athlete User
class Athlete(models.Model):
athleteuser = models.OneToOneField(User)
athleteavatar = models.ImageField("Profile Pic", upload_to="images/", blank=True, null=True, default='images/None/no-img.jpeg')
athletebirthday = models.DateField()
athleteurl = models.CharField(max_length=30, unique=True) # Must limit to a-z && A-Z && and 0-9 chars, validators=[validate_slug]
athletecommunities = models.ManyToManyField('communities.Community')
athletecolleges = models.ManyToManyField('colleges.College')
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/dd5c0b56-44fd-436f-b957-ad2cbfcd63a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
jjs-macbook-pro:~ JJZ$ python -m smtpd -n -c DebuggingServer localhost:1025
which I don't think would cause an issue and just to check I used control c to close it down and tried to migrate but again it hangs there.
As you can see so far I'm in a pretty big bind, I wish I had any sort of lead on this issue. Feel free to ask me for any other code etc or do any sort of method or operation to hopefully shed more light on this.
Thanks a lot,
JJ
Warning
It is not recommended to have a ForeignKey from an app without migrations to an app with migrations. See thedependencies documentation for more details.
and thus:
https://docs.djangoproject.com/en/1.7/topics/migrations/#unmigrated-dependencies
So basically as it was shown I made migrations for my user app athletes with the model being Athlete, and so when I tried to establish the migrations for all my apps with migrate I was basically presenting this dependency issue. I should have left athlete unmigrated and create migrations for all my other apps. It is the nature of the FK and I didn't catch onto it. There is no output as was stated before, which I'm not sure if that is possible in the code but if so I think it could be nice to tell people what is going on if at all possible. Tell them that if they have some apps with a FK to a model in another app that that other app cannot have migrations.
I still have a lot to learn with migrations, but for the time being things are operational again.
As time goes on, more and more third-party apps will get migrations, but in the meantime you can either give them migrations yourself (using MIGRATION_MODULES to store those modules outside of the app’s own module if you wish), or keep the app with your user model unmigrated.
Maybe in the future I won't have to even think about this if improvements are made to this situation. I might follow option 1 with giving it migrations outside the app's own module, but for the time being my quick fix is leaving my athlete app unmigrated, whereas everything else is.
JJ