Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 样式表位置引用(?)导致Django NoReverseMatch错误_Python_Html_Django_Web - Fatal编程技术网

Python 样式表位置引用(?)导致Django NoReverseMatch错误

Python 样式表位置引用(?)导致Django NoReverseMatch错误,python,html,django,web,Python,Html,Django,Web,我目前正在Django做一个项目,我遇到了一个奇怪的问题。在深入了解细节之前,以下是相关的html文档和python函数: def editpage(request, name): page = util.get_entry(name) #Imported forms as django_forms as not to interfere with forms.py class WikiEditForm(django_forms.Form): titl

我目前正在Django做一个项目,我遇到了一个奇怪的问题。在深入了解细节之前,以下是相关的html文档和python函数:

def editpage(request, name):

    page = util.get_entry(name)

    #Imported forms as django_forms as not to interfere with forms.py
    class WikiEditForm(django_forms.Form):
        title = django_forms.CharField(initial={"title":name}, label='Title:', required=True, widget=django_forms.TextInput(attrs={'placeholder':'Title'}))
        body = django_forms.CharField(initial={"body":page}, widget=django_forms.Textarea(attrs={'placeholder':'Enter Markdown Content','style':'text'}), required=True, label='Body')

    if request.method == "GET":
        search_form = forms.SearchWikiForm()
        return render(request, 'encyclopedia/editpage.html', {
        "search_form":search_form,
        "wiki_edit_form":WikiEditForm(),
    })

    else:
        search_form = forms.SearchWikiForm()
        wiki_edit_form = WikiEditForm(request.POST)

        if wiki_edit_form.is_valid():
            page_content = util.get_entry(name)

            util.save_entry(name, page_content)

            return HttpResponseRedirect(reverse('encyclopedia:wikipage', name))
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 action="{% url 'encyclopedia:findpage' %}" method="get">
                    {% csrf_token %}
                    {% block search %}{% endblock %}
                </form>
                <div>
                    <a href="{% url 'encyclopedia:index' %}">Home</a>
                </div>
                <div>
                    <a href="{% url 'encyclopedia:newpage' %}">Create New Page</a>
                </div>
                <div>
                    <a href="{% url 'encyclopedia:randompage' %}">Random Page</a>
                </div>
                {% block nav %}
                {% endblock %}
            </div>
            <div class="main col-lg-10 col-md-9">
                {% block body %}
                {% endblock %}
            </div>
        </div>

    </body>
</html>
{% extends "encyclopedia/layout.html" %}

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

{% block search %}
    {{form}}
{% endblock %}

{% block body %}
    <div style="padding-left: 15px;">
        {{ content|safe }}
        <br>
        <form action="{% url 'encyclopedia:editpage' title %}" method="get">
            {% csrf_token %}
            <button class='btn btn-primary' type='button'>Edit Page</button>
        </form>
    </div>
 
{% endblock %}
{% extends "encyclopedia/layout.html" %}

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

{% block search %}
{{ search_form }}
{% endblock %}

{% block body %}

<form action="{% url 'encyclopedia:editpage' title %}" method="post">
    {% csrf_token %}
    {% for field in wiki_edit_form %}
        {{ field.errors }}
        {{ field }}
        <br>
    {% endfor %}
    <button type='submit' class='btn btn-primary'>Submit Entry</button>
    <p style="display:inline-block">
        Note: Your work will be lost if another submission with the same title already exists.
    </p>
</form>

{% endblock %}
 /home/quinn/.local/lib/python3.8/site-packages/django/core/handlers/exception.py, line 47, in inner

                    response = get_response(request)

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/core/handlers/base.py, line 179, in _get_response

                    response = wrapped_callback(request, *callback_args, **callback_kwargs)

     …

▶ Local vars
/home/quinn/Desktop/cs50web/pset1/wiki/encyclopedia/views.py, line 116, in editpage

            return render(request, 'encyclopedia/editpage.html', {

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/shortcuts.py, line 19, in render

        content = loader.render_to_string(template_name, context, request, using=using)

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/template/loader.py, line 62, in render_to_string

        return template.render(context, request)

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/template/backends/django.py, line 61, in render

                return self.template.render(context)

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/template/base.py, line 170, in render

                        return self._render(context)

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/template/base.py, line 162, in _render

            return self.nodelist.render(context)

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/template/base.py, line 938, in render

                    bit = node.render_annotated(context)

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/template/base.py, line 905, in render_annotated

                return self.render(context)

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/template/loader_tags.py, line 150, in render

                return compiled_parent._render(context)

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/template/base.py, line 162, in _render

            return self.nodelist.render(context)

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/template/base.py, line 938, in render

                    bit = node.render_annotated(context)

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/template/base.py, line 905, in render_annotated

                return self.render(context)

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/template/loader_tags.py, line 62, in render

                    result = block.nodelist.render(context)

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/template/base.py, line 938, in render

                    bit = node.render_annotated(context)

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/template/base.py, line 905, in render_annotated

                return self.render(context)

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/template/defaulttags.py, line 446, in render

                url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/urls/base.py, line 87, in reverse

        return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))

     …

▶ Local vars
/home/quinn/.local/lib/python3.8/site-packages/django/urls/resolvers.py, line 685, in _reverse_with_prefix

            raise NoReverseMatch(msg)

     …

▶ Local vars