Answer the question
In order to leave comments, you need to log in
How to make a migration in django?
Created a class in models.py
class Post(models.Model):
title = models.CharField(max_length=200)
pdf = models.FileField()
time = models.DateTimeField(auto_now_add = True)
def __unicode__(self):
return self.title
def __str__(self):
return self.title
def get_absolute_url(self):
return reverse("posts:detail", kwargs={"id": self.id})
class Meta:
ordering = ['-time']
Answer the question
In order to leave comments, you need to log in
you need to run ./manage.py makemigrations, and then ./manage.py migrate from the directory where the manage.py file is located, and accordingly, you first need to start the virtual environment, if it was supposed to work from under it, and you also need to add to admin.py models, like from .models import Post and admin.site.register(Post)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question