Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
django migrate/migrations
#1
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.message
So 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.
Reply


Messages In This Thread
django migrate/migrations - by lewashby - Nov-29-2016, 02:42 AM
RE: django migrate/migrations - by Mike Ru - Dec-01-2016, 08:25 PM
RE: django migrate/migrations - by lewashby - Dec-02-2016, 03:18 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Flask migrate sqlalchemy not found TomasAm 2 3,449 Dec-01-2020, 10:04 AM
Last Post: TomasAm
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,246 Jun-30-2019, 12:21 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020