Nov-29-2016, 02:42 AM
I'm following a Django course on Udemy.com and there is what my django app's (msg) models.py file looked like before I hit the latest problem in the course.
from django.db import models # Create your models here. class Message(models.Model): message = models.CharField(max_length=400) username = models.CharField(max_length=100)The video then had me add the following to the file
def __unicode__(self): return self.messageSo now this is what my models.py file looks like.
from django.db import models # Create your models here. class Message(models.Model): message = models.CharField(max_length=400) username = models.CharField(max_length=100) [align=left]def __unicode__(self): # is indented[/align] [align=left]return self.message # is indented[/align]I am then told told to run
syncdb
which didn't work, a quick web search showed that it was an obsolete or deprecated function and that instead I should run makemigrations
and then migrate
, In both cases it returned No changes detected & No migrations to apply. The video then goes on to run python3 manage.py shell >>> Message.objects.all()
which on my system returns <QuerySet [<Message: Message object>, <Message: Message object>, <Message: Message object>]> and as you can see it's not dispalying the messages for each of the objects despite the unicode function because it's not migrating my changes. There is a username and a message string for each of the three message objects. I keep hearing that python is the future of web programming, I'm still struggling with the idea of giving up php for this madness.