NoReverseMatch at / Reverse为'django.contrib.auth.views.login',找不到参数'()'和关键字参数'{}'。尝试过0种模式:[]

时间:2017-03-27 16:36:46

标签: python django

我可以访问网站的管理区域,但我无法访问主页和其他前端页面。弹出以下错误...

Request Method: GET
Request URL:    http://localhost:8000/
Django Version: 1.10.6
Exception Type: NoReverseMatch
Exception Value:    
Reverse for 'django.contrib.auth.views.login' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Exception Location: C:\Python34\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 392
Python Executable:  C:\Python34\python.exe
Python Version: 3.4.4
Python Path:    
['C:\\Users\\AAKANKSHA\\Desktop\\Bus_reservation\\src',
 'C:\\WINDOWS\\SYSTEM32\\python34.zip',
 'C:\\Python34\\DLLs',
 'C:\\Python34\\lib',
 'C:\\Python34',
 'C:\\Python34\\lib\\site-packages']

模板渲染期间出错

    In template C:\Users\DEEP\Desktop\Bus_reservation\src\templates\bus_resrv_system.html, error at line 49

Reverse for 'django.contrib.auth.views.login' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
39  
40      <a name="about"></a>
41      <div class="content-section-a">
42  
43          <div class="container">
44              <div class="row">
45                  <div class="col-lg-5 col-sm-6">
46                      <hr class="section-heading-spacer">
47                      <div class="clearfix"></div>
48                      <h2 class="section-heading">Online ticket booking system:<br>No 'Line' on Online</h2>
49                      <p class="lead">Bus Reservation System is designed to automate the online ticket purchasing through an easy online bus booking system.With the bus ticket reservation system you can manage reservations, clients data and passengers lists.</p>
50                  </div>
51                  <div class="col-lg-5 col-lg-offset-2 col-sm-6">
52                      <img class="img-responsive" src="{% static 'images/booking_page/abtus2.jpg' %}" alt="">
53                  </div>
54              </div>
55  
56          </div>
57          <!-- /.container -->
58  
59      </div>

这是TRACEBACK

Environment:


Request Method: GET
Request URL: http://localhost:8000/

Django Version: 1.10.6
Python Version: 3.4.4
Installed Applications:
['bus.apps.BusConfig',
 'bookTicket.apps.BookticketConfig',
 'account.apps.AccountConfig',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']


Template error:
In template C:\Users\AAKANKSHA\Desktop\Bus_reservation\src\templates\bus_resrv_system.html, error at line 49
   Reverse for 'django.contrib.auth.views.login' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []   39 : 
   40 :     <a name="about"></a>
   41 :     <div class="content-section-a">
   42 : 
   43 :         <div class="container">
   44 :             <div class="row">
   45 :                 <div class="col-lg-5 col-sm-6">
   46 :                     <hr class="section-heading-spacer">
   47 :                     <div class="clearfix"></div>
   48 :                     <h2 class="section-heading">Online ticket booking system:<br>No 'Line' on Online</h2>
   49 :                     <p class="lead">Bus Reservation System is designed to automate the online ticket purchasing through an easy online bus booking system.With the  bus ticket reservation system you can mana ge reservations, clients data and passengers lists.</p>
   50 :                 </div>
   51 :                 <div class="col-lg-5 col-lg-offset-2 col-sm-6">
   52 :                     <img class="img-responsive" src="{% static 'images/booking_page/abtus2.jpg' %}" alt="">
   53 :                 </div>
   54 :             </div>
   55 : 
   56 :         </div>
   57 :         <!-- /.container -->
   58 : 
   59 :     </div>


Traceback:

File "C:\Python34\lib\site-packages\django\core\handlers\exception.py" in inner
  42.             response = get_response(request)

File "C:\Python34\lib\site-packages\django\core\handlers\base.py" in _legacy_get_response
  249.             response = self._get_response(request)

File "C:\Python34\lib\site-packages\django\core\handlers\base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "C:\Python34\lib\site-packages\django\core\handlers\base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "C:\Users\deep\Desktop\Bus_reservation\src\bus\views.py" in index
  10.     render_to_response(template_name, context=None, content_type=None, status=None, using=None)

File "C:\Python34\lib\site-packages\django\shortcuts.py" in render_to_response
  21.     content = loader.render_to_string(template_name, context, using=using)

File "C:\Python34\lib\site-packages\django\template\loader.py" in render_to_string
  68.     return template.render(context, request)

File "C:\Python34\lib\site-packages\django\template\backends\django.py" in render
  66.             return self.template.render(context)

File "C:\Python34\lib\site-packages\django\template\base.py" in render
  208.                     return self._render(context)

File "C:\Python34\lib\site-packages\django\template\base.py" in _render
  199.         return self.nodelist.render(context)

File "C:\Python34\lib\site-packages\django\template\base.py" in render
  994.                 bit = node.render_annotated(context)

File "C:\Python34\lib\site-packages\django\template\base.py" in render_annotated
  961.             return self.render(context)

File "C:\Python34\lib\site-packages\django\template\loader_tags.py" in render
  174.         return compiled_parent._render(context)

File "C:\Python34\lib\site-packages\django\template\base.py" in _render
  199.         return self.nodelist.render(context)

File "C:\Python34\lib\site-packages\django\template\base.py" in render
  994.                 bit = node.render_annotated(context)

File "C:\Python34\lib\site-packages\django\template\base.py" in render_annotated
  961.             return self.render(context)

File "C:\Python34\lib\site-packages\django\template\loader_tags.py" in render
  70.                 result = block.nodelist.render(context)

File "C:\Python34\lib\site-packages\django\template\base.py" in render
  994.                 bit = node.render_annotated(context)

File "C:\Python34\lib\site-packages\django\template\base.py" in render_annotated
  961.             return self.render(context)

File "C:\Python34\lib\site-packages\django\template\loader_tags.py" in render
  210.                 return template.render(context)

File "C:\Python34\lib\site-packages\django\template\base.py" in render
  210.                 return self._render(context)

File "C:\Python34\lib\site-packages\django\template\base.py" in _render
  199.         return self.nodelist.render(context)

File "C:\Python34\lib\site-packages\django\template\base.py" in render
  994.                 bit = node.render_annotated(context)

File "C:\Python34\lib\site-packages\django\template\base.py" in render_annotated
  961.             return self.render(context)

File "C:\Python34\lib\site-packages\django\template\defaulttags.py" in render
  315.                 return nodelist.render(context)

File "C:\Python34\lib\site-packages\django\template\base.py" in render
  994.                 bit = node.render_annotated(context)

File "C:\Python34\lib\site-packages\django\template\base.py" in render_annotated
  961.             return self.render(context)

File "C:\Python34\lib\site-packages\django\template\defaulttags.py" in render
  439.             url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)

File "C:\Python34\lib\site-packages\django\urls\base.py" in reverse
  91.     return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))

File "C:\Python34\lib\site-packages\django\urls\resolvers.py" in _reverse_with_prefix
  392.             (lookup_view_s, args, kwargs, len(patterns), patterns)

Exception Type: NoReverseMatch at /
Exception Value: Reverse for 'django.contrib.auth.views.login' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

这是我的resolvers.py(错误)

 m = getattr(lookup_view, '__module__', None)
    n = getattr(lookup_view, '__name__', None)
    if m is not None and n is not None:
        lookup_view_s = "%s.%s" % (m, n)
    else:
        lookup_view_s = lookup_view

    patterns = [pattern for (possibility, pattern, defaults) in possibilities]
    raise NoReverseMatch(
        "Reverse for '%s' with arguments '%s' and keyword "
        "arguments '%s' not found. %d pattern(s) tried: %s" %
        (lookup_view_s, args, kwargs, len(patterns), patterns)
    )

这是我的bus_resrv_system.html

{% extends "base.html" %}

{% load staticfiles %}
{% block site_wrapper %}
 <!-- Navigation -->
 {% include 'tags/navigation.html' %}
 <!--end navigation-->

    <!-- Container -->
     {% block content %}
    <div class="intro-header">
        <div class="container">

            <div class="row">
                <div class="col-lg-12">
                    <div class="intro-message">

                        <h1>Bus Reservation System</h1>
                        <h3>Where the journey begins!!!</h3>
                        <hr class="intro-divider">
                        <ul class="list-inline intro-social-buttons">
                            <li>
                                <a href="{% url 'bus:searchBus' %}" class="btn btn-default btn-lg"><i class="fa fa-bus fa-fw"></i> <span class="network-name">Book a ticket</span></a>
                            </li>

                        </ul>

                    </div>
                </div>
            </div>

        </div>
        <!-- /.container -->

    </div>
    <!-- /.intro-header -->
 {% endblock %}
    <!-- Page Content -->

    <a name="about"></a>
    <div class="content-section-a">

        <div class="container">
            <div class="row">
                <div class="col-lg-5 col-sm-6">
                    <hr class="section-heading-spacer">
                    <div class="clearfix"></div>
                    <h2 class="section-heading">Online ticket booking system:<br>No 'Line' on Online</h2>
                    <p class="lead">Bus Reservation System is designed to automate the online ticket purchasing through an easy online bus booking system.With the bus ticket reservation system you can manage reservations, clients data and passengers lists.</p>
                </div>
                <div class="col-lg-5 col-lg-offset-2 col-sm-6">
                    <img class="img-responsive" src="{% static 'images/booking_page/abtus2.jpg' %}" alt="">
                </div>
            </div>

        </div>
        <!-- /.container -->

    </div>
    <!-- /.content-section-a -->

    <div class="content-section-b">

        <div class="container">

            <div class="row">
                <div class="col-lg-5 col-lg-offset-1 col-sm-push-6  col-sm-6">
                    <hr class="section-heading-spacer">
                    <div class="clearfix"></div>
                    <h2 class="section-heading">It's Simple!!!<br><small>Search for buses-Book your ticket-Board your bus</small> </h2>
                    <p class="lead">Making your life easier with bus fare comparisions,searching buses and making your journey the safe and sound.</p>
                </div>
                <div class="col-lg-5 col-sm-pull-6  col-sm-6">
                    <img class="img-responsive" width="80%" hieght="40%" src="{% static 'images/booking_page/abtus.png' %}" alt="">
                </div>
            </div>

        </div>
        <!-- /.container -->

    </div>
    <!-- /.content-section-b -->

    <div class="content-section-a">

        <div class="container">

            <div class="row">
                <div class="col-lg-5 col-sm-6">
                    <hr class="section-heading-spacer">
                    <div class="clearfix"></div>
                    <h2 class="section-heading">Contact us :</h2>
                    <p class="lead">
                         <strong>Phone Contacts :</strong><br/>
                            Mumbai : +91-022-345-345<br/>
                            Pune : +91-022-345-346<br/>
                            <strong>E-mail Contacts :</strong><br/>
                            E-mail : support [AT] busreservation.in
                    </p>
                </div>
                <div class="col-lg-5 col-lg-offset-2 col-sm-6">
                    <img class="img-responsive" src="{% static 'images/booking_page/contus.JPG' %}" alt="">
                </div>
            </div>

        </div>
        <!-- /.container -->

    </div>
    <!-- /.content-section-a -->

    <a  name="contact"></a>
    <div class="banner">

        <div class="container">

            <div class="row">
                <div class="col-lg-6">
                    <h2>Connect to Bus Reservation:</h2>
                </div>
                <div class="col-lg-6">
                    <ul class="list-inline banner-social-buttons">
                        <li>
                            <a href="#" class="btn btn-default btn-lg"><i class="fa fa-twitter fa-fw"></i> <span class="network-name">Twitter</span></a>
                        </li>
                        <li>
                            <a href="#" class="btn btn-default btn-lg"><i class="fa fa-facebook fa-fw"></i> <span class="network-name">Facebook</span></a>
                        </li>
                        <li>
                            <a href="#" class="btn btn-default btn-lg"><i class="fa fa-linkedin fa-fw"></i> <span class="network-name">Linkedin</span></a>
                        </li>
                    </ul>
                </div>
            </div>

        </div>
        <!-- /.container -->

    </div>
    <!-- /.banner -->

    <!-- Footer -->
    {%include 'tags/footer.html' %}
    <!-- End of footer -->

{% endblock %}

0 个答案:

没有答案