So I believe I have solved my issue. It has to do with the inexperience I 
still have with migrations and how certain aspects are approached. I was 
not aware of this issue until now:

https://docs.djangoproject.com/en/1.7/ref/models/fields/#foreignkey

Warning

It is not recommended to have a ForeignKey from an app without migrations 
to an app with migrations. See thedependencies documentation 
<https://docs.djangoproject.com/en/1.7/topics/migrations/#unmigrated-dependencies>
 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 
<https://docs.djangoproject.com/en/1.7/ref/settings/#std:setting-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



On Saturday, October 25, 2014 5:15:04 PM UTC-4, Carl Meyer wrote:
>
> Hi JJ,
>
> One thing that can cause hangs when running migrations is having another 
> process (say a ‘manage.py shell’) with a connection to the same database 
> sitting open, possibly with a transaction in progress that is holding locks 
> on the tables the migrations need to touch. Any possibility that’s what 
> happened here?
>
> Carl
>
> On Oct 25, 2014, at 2:23 PM, JJ Zolper <jzt...@gmail.com <javascript:>> 
> wrote:
>
> I really wish I could give some useful information in the terms of a 
> traceback so others may have an idea what is happening to me but I'm 
> completely serious when I say I don't even get a traceback right now. Here 
> is the break down of what I did to give an idea of how I ended up at this 
> point, hopefully. I will continue to try to iterate upon this discussion as 
> well through observations to try to work on my own or with others to get 
> down to the cause of the issue.
>
> First with a clean and empty database I ran the migrate command and 
> everything went fine. There were no issues as it ran through:
>
> (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")
> I thought maybe it couldn't migrate this because of the FK to Athlete, 
> even though I used this declaration before my understanding is it includes 
> that model in the FK. I tried importing the the athlete model from the 
> database above this definition but there was still no output or change in 
> the issue. What I'm saying is before this line is the way it is above I had 
> a foreignkey to settings.AUTH_USER_MODEL. But the funny thing is I actually 
> had that definition commented out in my settings.py. The reason being I 
> thought I needed to go that route originally with my Athlete django users 
> but then realized I would just use a one to one field to a django user. 
> Thus why I changed it to 'athletes.Athlete'.
>
> # 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')
>
> I wish I could give more information but I simply can't think of anything 
> else right now that could be relevant. It's funny because I saw this:
>
>
>    - Modified migrations dependency algorithm to avoid possible infinite 
>    recursion.
>
>
> on the new release notes:
>
> https://docs.djangoproject.com/en/1.7/releases/1.7.1/
>
> and it honestly seems to sound exactly like that. It seems like some sort 
> of infinite recursion or something similar it can't get out of it. It can't 
> identify the issue it gets thrown through and so it sits there endlessly.
>
> And yes again I am using 1.7.1, I just updated the other day.
>
> Thanks a lot,
>
> JJ Zolper
>
>
>
>
> -- 
> 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 <javascript:>.
> To post to this group, send email to django...@googlegroups.com 
> <javascript:>.
> 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
>  
> <https://groups.google.com/d/msgid/django-users/dd5c0b56-44fd-436f-b957-ad2cbfcd63a4%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/c30af891-d3bc-434e-86e7-e0248066d3aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to