Django Tutorial – models, database, admin
Code / Syntax stuff from the tutorial that I’m definitely going to forget, so putting it here for easy reference:
q = Question(question_text=”What’s new?”, pub_date=timezone.now())
t’s important to add __str__() methods to your models, not only for your own convenience when dealing with the interactive prompt, but also because objects’ representations are used throughout Django’s automatically-generated admin.
q = Question.objects.get(pk=1)
c = q.choice_set.create(choice_text=’Just hacking again’, votes=0)1
After logging in to Django admin, add the polls app to admin.py to make it modifiable in the admin section.