Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
Bottom Page

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.
Quote
#2
Did you add the app into the settings.py?
Quote
#3
(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.
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)