Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I'm using Django 1.7, PostgresApp (PostgreSQL 9.4), Python 2.7.

I have followed this tutorial for setting up and creating the app: https://docs.djangoproject.com/en/1.9/intro/tutorial02/

In the Python shell, I kept getting errors like "ProgrammingError: relation "app_table" does not exist" for my database schema.

So I used the classes from the tutorial:

class Question(models.Model):
  question_text = models.CharField(max_length=200)
  pub_date = models.DateTimeField('date published')


class Choice(models.Model):
  question = models.ForeignKey(Question, on_delete=models.CASCADE)
  choice_text = models.CharField(max_length=200)
  votes = models.IntegerField(default=0)

and then in the shell I got (the correct values):

>>> Question.objects.all()
[]
>>> Choice.objects.all()
[]

Then, modifying the name Choice to MyChoice gives this:

>>> Question.objects.all()
[]
>>> MyChoice.objects.all()
...
ProgrammingError: relation "app_mychoice" does not exist.

Why is this happening? I tried the answers suggested in other posts

./manage.py makemigrations; 
./manage.py migrate auth; 
./manage.py migrate and 
python manage.py syncdb

but nothing worked.

share|improve this question
    
A bit confused, did you change Choice(models.Model) to MyChoice(models.Model)? – Hybrid Jan 7 at 14:03
    
You shouldn't have to use syncdb for Django 1.7+. Why are you trying to change the model name from Choice to MyChoice? Did running ./manage.py makemigrations create a migration to rename the table? What are the contents of your app's migrations folder, and which ones have you run? You could try dropping and recreating the database, then deleting the migrations and running makemigrations again. – Alasdair Jan 7 at 14:03
    
@Hybrid yes, that was the only change. – daria Jan 7 at 14:06
    
@Alasdair I changed it to see if it still works. makemigrations created a migration with the names updated. I dropped and recreated the database and I get the same error. – daria Jan 7 at 14:06
    
Alright so this looks like it is a migration issue, I always have problems with them as well, and end up having to fake and use flags like initial, but I don't want to give you a trial and error answer, hopefully someone who sees this has more experience with migrations and will be able to help – Hybrid Jan 7 at 14:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.