1

DatabaseError at /admin/delmarva/event/ no such column: delmarva_event.eventdate

I created a class in my models.py file:

from django.db import models
from django.contrib.auth.models import User

class Event(models.Model):
    eventname = models.CharField(max_length = 100)
    eventdate = models.DateField()
    eventtime = models.TimeField()
    address = models.CharField(max_length = 200)
    user = models.ForeignKey(User)

    def __unicode__(self):
        return self.eventname

and now when i try to view my events in my admin or my main_page it gives me the error that there is no eventdate. I tried syncing the db again but nothing changed. Also, I hashtagged eventdate out to see if I get a different error and then it states that delmarva_event.eventtime does not exist as well. I It is weird because it does not have a problem with eventname. Any suggestions would be greatly appreciated!

3 Answers 3

3

If you modify the models, syncdb does not work. You need a 3rd party tool called south which manages these "migrations" for you.

If not, - the other - NON PREFERRED method would be to drop the table and create it again

Sign up to request clarification or add additional context in comments.

Comments

1

The problem is probably that you did syncdb and then added the eventdate column. Syncdb creates tables only once and don't update them furthermore. You will need to use South app and make migrations or delete the table and then use syncdb again.

2 Comments

how do you call the south app?
You will find instructions in the documentation. In short, you create the first migration by manage.py schemamigration appname --initial and from this point, the syncdb ignores all models in this app and you have to use manage.py migrate appname (appname is mandatory). If you already have tables, you have to fake the first migration (parameter --fake 0001). Then you change the model and call manage.py schemamigration appname --auto and then migrate again. If you rename a field, you have to migrate manually. Please check the documentation, there is all you need ;)
0

A quick solution is to remove the database and then run syncdb again. It should be in the same directory as your manage.py file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.