Python 没有这样的表格:(Django)

Python 没有这样的表格:(Django),python,html,django,Python,Html,Django,当我运行我的代码(它用于一个项目)时,我得到了这样一个错误:“没有这样的表:百科全书文章”。错误似乎来自9行views.py(obj=article.objects.get(id=1)。以下是代码: views.py from django.shortcuts import render from django.http import HttpResponse from . import util import random from .models import article from .f

当我运行我的代码(它用于一个项目)时,我得到了这样一个错误:“没有这样的表:百科全书文章”。错误似乎来自9行views.py(obj=article.objects.get(id=1)。以下是代码:

views.py

from django.shortcuts import render
from django.http import HttpResponse
from . import util
import random
from .models import article
from .forms import ArticleForm

def index(request):
    obj = article.objects.get(id=1)    #THIS IS WHAT APPERS TO CAUSE THE ERROR
    context = {
        'object': obj
    }
    entries = util.list_entries()
    random_page = random.choice(entries)
    return render(request, "encyclopedia/index.html", {
        "entries": util.list_entries(),
        "random_page": random_page,
    })
def CSS(request):
    return render(request, "encyclopedia/css_tem.html", {
        "article_css": "css is slug and cat"
    })
def Python(request):
    return render(request, "encyclopedia/python_tem.html", {
        "article_python": "python says repost if scav"
    })
def HTML(request):
    return render(request, "encyclopedia/HTML_tem.html", {
        "article_HTML": "game theory: scavs are future humans"
    })
def Git(request):
    return render(request, "encyclopedia/Git_tem.html", {
        "article_Git": "github is git"
    })
def Django(request):
    return render(request, "encyclopedia/Django_tem.html", {
        "article_Django": "this is a framework"
    })
def new_article(request):
    form = ArticleForm(request.POST or None)
    if form.is_valid():
        form.save()
    context = {
        'form': form
    }
    return render(request, "encyclopedia/new_article_tem.html", context)

models.py:


class article(models.Model):
    title = models.CharField(max_length = 120)
    description = models.TextField(blank=True, null = False)
forms.py:

from django import forms
from .models import article
class ArticleForm(forms.ModelForm):
  class Meta:
      model = article
      fields = [
        'title',
        'description'
      ]
网址:

第二个URL(在其他目录中(有百科全书和wiki,这一个在wiki中,最后一个在百科全书中)):

新文章_tem.html:

{% extends "encyclopedia/layout.html" %}

{% block title %}
    New Article
{% endblock %}

{% block body %}

    <h1>Create Article</h1>
    <form method = 'POST' action = "{% url 'index' %}"> {% csrf_token %}
      
        <input type = 'submit' value='Save'>
    </form>
{% endblock %}

{%extends“encyclopedia/layout.html”%}
{%block title%}
新文章
{%endblock%}
{%block body%}
创作文章
{%csrf_令牌%}
{%endblock%}
我不确定这些是否有用,但我仍然把几乎所有的东西: index.html:

{% extends "encyclopedia/layout.html" %}

{% block title %}
    Encyclopedia
{% endblock %}

{% block body %}
<h1 id="demo" onclick="add_article()">Add article</h1>


    <ul>
        {% for entry in entries %}
            <li><a href = /{{entry}}>{{ entry }}</a></li>
        {% endfor %}
        {% for article_title in created_articles %}
            <li>{{article_title}}</li>
        {% endfor %}
        <li>{{title}}</li>
    </ul>

{% endblock %}
{%extends“encyclopedia/layout.html”%}
{%block title%}
百科全书
{%endblock%}
{%block body%}
附加条款
    {entries%%中的条目的百分比}
  • {%endfor%} {已创建的文章%中的文章标题为%}
  • {{文章标题}
  • {%endfor%}
  • {{title}}
{%endblock%}
layout.html:

{% load static %}
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>{% block title %}{% endblock %}</title>
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
        <link href="{% static 'encyclopedia/styles.css' %}" rel="stylesheet">
    </head>
    <body>
        <div class="row">
            <div class="sidebar col-lg-2 col-md-3">
                <h2>Wiki</h2>
                <form>
                    <input class="search" type="text" name="q" placeholder="Search Encyclopedia">
                </form>
                <div>
                    <a href="{% url 'index' %}">Home</a>
                </div>
                <div>
                    <a href = "/new_article" >Create New Article</a>
                </div>
                <div>
                    <a href = "http://127.0.0.1:8000/{{random_page}}">Random Page</a>
                </div>
                {% block nav %}
                {% endblock %}
            </div>
            <div class="main col-lg-10 col-md-9">
                {% block body %}
                {% endblock %}
            </div>
        </div>

    </body>
</html>
{%load static%}
{%block title%}{%endblock%}
维基
{%block nav%}
{%endblock%}
{%block body%}
{%endblock%}
尝试使用以下方法:-

python manage.py makemigrations
然后

python manage.py migrate

您进行了迁移并应用了吗?谢谢,成功了
python manage.py makemigrations
python manage.py migrate