I have a problem with migration in this model.
(我在此模型中有迁移问题。)
So this is my initial class Post, it works perfectly(migration worked): (这是我的第一堂课Post,它可以很好地工作(迁移有效):)
Initial Class Post
(头等舱职位)
class Post(models.Model):
title = models.CharField(max_length=100)
content = models.TextField()
date_posted = models.DateTimeField(default=timezone.now)
author = models.ForeignKey(User, on_delete=models.CASCADE)
def __str__(self):
return self.title
I want to add a new column:
(我想添加一个新列:)
photos = models.ImageField(upload_to="/images/", default = None)
I deleted all migrations and so when i used makemigrations it works, but when i try to migrate i get nothing:
(我删除了所有迁移,因此当我使用makemigrations时,它可以工作,但是当我尝试迁移时,我什么也没得到:)
PowerShell Result:
(PowerShell结果:)
Apply all migrations: blog
Running migrations:
No migrations to apply.
When i try to fake migrations it also is not working:
(当我尝试伪造迁移时,它也不起作用:)
PowerShell Result:
(PowerShell结果:)
Target specific migration: 0001_initial, from blog
Running migrations:
No migrations to apply.
After i run the server i get this error:
(运行服务器后,出现此错误:)
Trying to acces my local website:
(尝试访问我的本地网站:)
Error during template rendering
In template C:UsersAdministrator PCDesktopmysitelogemplateslogase.html, error at line 6
no such column: blog_post.photos
{% load static %}
<!DOCTYPE html>
<html>
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="{% static 'blog/main.css' %}">
{% if title %}
<title>Django Blog - {{ title }}</title>
Please help i don't know what to try more.
(请帮助我不知道该如何尝试。)
Thank you in advance. (先感谢您。)
ask by Nick Druta translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…