On Monday, August 4, 2014 8:06:00 AM UTC-7, Sam Contapay wrote:
Hi,I tried adding a foreign key to a model in a Django app I'm building to learn 1.7. I am using Python 3.4 and Django 1.7c2#blog/models.pyfrom django.contrib.auth.models import Userfrom django.db import modelsclass Comment(models.Model):user = models.ForeignKey(User, blank=True, null=True)created_at = models.DateTimeField(auto_now=True) comment = models.CharField(max_length=255) This is an already existing database I ran "manage.py makemigrations" and "manage.py migrate". Make migration works fine but running migrate generates this error (I am not using a custom user model). I don't understand 'auth' not found as it is in my project settings and I am using the admin panel:(screens)➜ screens git:(maste
r ) ✗ ./manage.py migrateOperations to perform:
Synchronize unmigrated apps: django_extensions, crispy_forms
Apply all migrations: auth, admin, contenttypes, sessions, website
Synchronizing apps without migrations:
Creating tables...
Installing custom SQL...
Installing indexes...
Running migrations:
Applying website.0004_comment_created_
by_user...Traceback (most recent call last): File "/Users/scontapay/.pyenv/
versions/screens/lib/python3. 4/site-packages/django/apps/ registry.py", line 148, in get_app_config return self.app_configs[app_label]
KeyError: 'auth'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/scontapay/.pyenv/
versions/screens/lib/python3. 4/site-packages/django/db/ migrations/state.py", line 79, in render model = self.apps.get_model(lookup_
model[0], lookup_model[1]) File "/Users/scontapay/.pyenv/
versions/screens/lib/python3. 4/site-packages/django/apps/ registry.py", line 202, in get_model return self.get_app_config(app_label)
.get_model(model_name.lower()) File "/Users/scontapay/.pyenv/
versions/screens/lib/python3. 4/site-packages/django/apps/ registry.py", line 150, in get_app_config raise LookupError("No installed app with label '%s'." % app_label)
LookupError: No installed app with label 'auth'.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.
argv) File "/Users/scontapay/.pyenv/
versions/screens/lib/python3. 4/site-packages/django/core/ management/__init__.py", line 385, in execute_from_command_line utility.execute()
File "/Users/scontapay/.pyenv/
versions/screens/lib/python3. 4/site-packages/django/core/ management/__init__.py", line 377, in execute self.fetch_command(subcommand)
.run_from_argv(self.argv) File "/Users/scontapay/.pyenv/
versions/screens/lib/python3. 4/site-packages/django/core/ management/base.py", line 288, in run_from_argv self.execute(*args, **options.__dict__)
File "/Users/scontapay/.pyenv/
versions/screens/lib/python3. 4/site-packages/django/core/ management/base.py", line 337, in execute output = self.handle(*args, **options)
File "/Users/scontapay/.pyenv/
versions/screens/lib/python3. 4/site-packages/django/core/ management/commands/migrate. py", line 160, in handle executor.migrate(targets, plan, fake=options.get("fake", False))
File "/Users/scontapay/.pyenv/
versions/screens/lib/python3. 4/site-packages/django/db/ migrations/executor.py", line 63, in migrate self.apply_migration(
migration, fake=fake) File "/Users/scontapay/.pyenv/
versions/screens/lib/python3. 4/site-packages/django/db/ migrations/executor.py", line 91, in apply_migration if self.detect_soft_applied(
migration): File "/Users/scontapay/.pyenv/
versions/screens/lib/python3. 4/site-packages/django/db/ migrations/executor.py", line 135, in detect_soft_applied apps = project_state.render()
File "/Users/scontapay/.pyenv/
versions/screens/lib/python3. 4/site-packages/django/db/ migrations/state.py", line 89, in render model=lookup_model,
ValueError: Lookup failed for model referenced by field website.Comment.created_by_
user: auth.User
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+unsubscribe@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/46e2ed1b-caf7-43e3-9422-767c8b1eba13%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment