如何修复 NoReverseMatch?如果你没有授权工作

how to fix NoReverseMatch at? work if you not authorized

If you are not authorized, then everything will work fine, as soon as you authorize, for example, adeline, this error will be issued, I do not know what happened!

NoReverseMatch 在 /series/Colony/Season_1/Episode_1/

Reverse for 'post_of_serie' with no arguments not found. 1 pattern(s) tried: ['series/(?P<serial_slug>[\w-]+)/(?P<season_slug>[\w-]+)/(?P<series_slug>[\w-]+)/$']

主要urls.py

from django.conf.urls import include, url
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    url(r'^admin/', admin.site.urls),

    url(r'^series/', include("serials.urls", namespace='series')),
    url(r'^', include("serials.urls", namespace='homeview')),



]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

秒 urls.py 到应用程序(系列)

from django.conf.urls import include, url
from .views import homeview, post_of_serial, post_of_season, post_of_serie, validate_email, mark_and_unmark_this_episode

urlpatterns = [
   url(r'^$', homeview, name='homeview'),
   url(r'^subscribe/$', validate_email, name='subscribe'),   # /series/
   url(r'^mark_or_unmark_this_episode/$', mark_and_unmark_this_episode, name="mark_and_unmark_this_episode"),
   url(r'^(?P<serial_slug>[\w-]+)/$', post_of_serial, name='post_of_serial'),  # /series/Prison_Break/
   url(r'^(?P<serial_slug>[\w-]+)/(?P<season_slug>[\w-]+)/$', post_of_season, name='post_of_season'),  # /series/Prison_Break/season_5/
   url(r'^(?P<serial_slug>[\w-]+)/(?P<season_slug>[\w-]+)/(?P<series_slug>[\w-]+)/$', post_of_serie, name='post_of_serie'),  # /series/Prison_Break/season_5/2/  
]

错误

这是 view.py

的一部分
def post_of_serie(request, serial_slug=None, season_slug=None, series_slug=None):
    serie                           = get_object_or_404(Series, serial_of_this_series__slug=serial_slug, season_of_this_series__slug=season_slug, slug=series_slug)
    #print(serie)
    title                           = serie.serial_of_this_series.rus_name_of_seriall
    full_path                       = All_Images_Of_The_Series.objects.filter(to_series__serial_of_this_series__slug=serial_slug, to_series__season_of_this_series__slug=season_slug, to_series__slug=series_slug, is_poster=True)

    context = {"serie":serie, "full_path":full_path, "title":title,}
    try:
        userr                       = request.user          
        check_button                = watched_series.objects.filter(user=request.user, watched_serial__slug=serial_slug, watched_serie__season_of_this_series__slug=season_slug, watched_serie__slug=series_slug )
        context["check_button"]     = check_button
        context["userr"]            = userr
    except:
        pass


    return render(request, 'series.html', context)

如果在 views.py 中删除某些内容,则不会有任何变化!!!

主要html

{% load staticfiles %}

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
        <title>{{ title }}</title>

        <!-- Bootstrap -->
        <link href="{% static "css/bootstrap.min.css"%}" rel="stylesheet">
        <link href="{% static "css/footer.css"%}" rel="stylesheet">
        <link href="{% static "css/main.css"%}" rel="stylesheet">
        {% block styles %}{% endblock styles %}


    </head>
    <body>
        <a href="{{ advertise_for_header.link_for_advertise }}"><div class="advertises" ></div></a>
        <div class="wrapper">
            <div class="wrapper-content">
            {% include "navbar.html" %}
            {% block content %}
            {% endblock content %}
            </div>
            {% include "footer.html" %}
        </div>

        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
        <script src="{% static "js/bootstrap.min.js"%}"></script>
        <script src="{% static "js/smooth-scroll.js"%}"></script>
        <script src="{% static "js/script.js" %}"></script>

    </body>
</html>

series.html where is up error!

{% extends "base.html" %}
{% load staticfiles %}

{% block content %}
    <div class="container">
        <div class="row">
            <div class="col-sm-8 her">
                <span class="links" >
                    <a class="a-link" href="{{ serie.serial_of_this_series.get_absolute_url }}">{{ serie.serial_of_this_series.rus_name_of_seriall }} <img src="{% static "img/breadcrumbs-arrow.png" %}" class="arrow"  > </a>

                    <a class="a-link" href="{{ serie.season_of_this_series.get_absolute_url }}">{{ serie.season_of_this_series.name_of_the_season }}<img src="{% static "img/breadcrumbs-arrow.png" %}" class="arrow"  ></a>

                    <a class="a-link" href="{{ serie.get_absolute_url }}">{{ serie.rus_name }}<img src="{% static "img/breadcrumbs-arrow.png" %}" class="arrow"  ></a>
                </span>

                <div class="title-block" >
                    <h3 class="seria-header">
                        <img src="{{ serie.serial_of_this_series.preview_of_serial.url }}" class="thumb">
                        <span class="titles" >
                            <div class="title-ru">{{ serie.rus_name }}</div>
                            <div class="title-en">{{ serie.eng_name }}</div>
                        </span>
                    </h3>
                    {% if user.is_authenticated %}
                        <form class="watch_button" method="POST" action="{% url 'series:post_of_serie' %}" > {% csrf_token %}
                            <div class="buttons" >
                                <div class="second_section_of_buttons" >
                                    {% if check_button %}
                                        <div class="isawthat-btn checcked" title="Серия просмотрена. Убрать пометку?" ><img src="{% static "img/white-eye-icon.png" %}" class="iccon"/><span class="text_button" >Серия просмотрена</span></div>
                                    {% else %}
                                        <div class="isawthat-btn" title="Пометить серию как просмотренную" ><img src="{% static "img/pink-eye-icon.png" %}" class="iccon"/><span class="text_button" >Серия Не просмотрена</span></div>
                                </div>
                                {% endif %}
                            </div>
                            <p class="user hidden" >{{ userr }}</p>
                            <p class="watched_serial hidden" >{{ serie.serial_of_this_series }}</p>
                            <p class="watched_serie hidden" >{{ serie }}</p>
                            <p class="minutes_of_series hidden" >{{ serie }}</p>
                            <p class="serial_slug hidden" > {{ serie.serial_of_this_series.slug }} </p>
                            <p class="season_slug hidden" > {{ serie.season_of_this_series.slug }} </p>
                            <p class="series_slug hidden" > {{ serie.slug }} </p>
                        </form>
                    {% endif %}
                </div>
            </div>

            <div class="col-sm-3">

            </div>
        </div>

    </div>

{% endblock content %}
<form class="watch_button" method="POST" action="{% url 'series:post_of_serie' %}" >

这是你遇到错误的那一行兄弟,你看,这个表单只对登录用户显示,你没有像 def post_of_serie(request):

这样的视图

尝试将slug以url的形式传到这里,问题就解决了