django migrate/migrations - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: django migrate/migrations (/thread-1042.html) |
django migrate/migrations - lewashby - Nov-29-2016 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.
RE: django migrate/migrations - Mike Ru - Dec-01-2016 Did you add the app into the settings.py? RE: django migrate/migrations - lewashby - Dec-02-2016 (Dec-01-2016, 08:25 PM)Mike Ru Wrote: Did you add the app into the settings.py? Yes. INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'msg', ]It's the msg app at the very bottom. |