NoReverseMatch at / Reverse for 'dashboard' with no arguments not found. 1 pattern(s) tried: ['(?P[^/]+)\/$']












0















I get this error



NoReverseMatch at /
Reverse for 'dashboard' with no arguments not found. 1 pattern(s) tried: ['(?P<username>[^/]+)\/$'].


After a users clicks the login button its expected that the url should redirected to 'domain/username.html', after it has been authenticated and move to the dashboard.html page.



login1.html



{% load custom_filters %}
<a href="" class="btn-back-sign-up" id="dismiss" id="sign-up">
<i class="fa fa-chevron-left"> &nbsp;SIGNUP</i>
</a><br><br>
<p class="text-join">Join our community that have more than 10,000<br> subscribers and learn new things everyday.</p>
<div class='back' id='login_form'>
<form id='login-form' method='post' {% url 'accounts:dashboard' %} ><br>
{% csrf_token %}
{% for field in form %}
{% if field.errors %}
{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}
{% endif %}
<div class="form-group">
{{ field.label_tag }}
{{ field|add_class:'form-control'}}
</div>
{% endfor %}
<div class="form-group">
<input type="text" class="form-control input-upper" id="username" placeholder="Username" name="username" required id="id_username"><br>
<input type="password" class="form-control input-upper" id="password" placeholder="Password" name="password1" required id="id_password"><br>
<button type="submit" value='Login' id="top-login-btn" class="btn btn-primary btn-block btn-signup-form-1">LOGIN</button>
<p class="text-center">or</p>
<button type="button" class="btn btn-primary btn-block btn-sign-linkedin-1">Login up with LinkedIn</button>
<p class="text-already">Don't have an account?
<a href="" data-toggle="modal" class="btn-back-sign-up" data-target="#modal-signup" id="dismiss" id="sign-up">Sign Up</a>
</p>

</div>
</form>
</div>
<p class="text-already"><a href="{% url 'password_reset' %}">Forgot Password?</a></p><br>


views



@login_required
def dashboard(request, username):
"""Dashboard page for user"""

if request.user.username != username:
return redirect(
'accounts:dashboard',
args=(request.user.username,)
)
return render(request, 'accounts/dashboard.html', {
'notifications': request.user.notifications.order_by('-date_added'),
'sub_token': url_crypt.encode_token((request.user.subscription.plan,))
})


urls.py



name = 'accounts'
urlpatterns = [
path(r'accounts/register', views.register, name='register'),
path(
r'accounts/account-activation-sent/', views.account_activation_sent,
name='account_activation_sent'
),
path(
r'accounts/activate/<uidb64>/<token>/', views.activate,
name='activate'
),
path(r'purchase/<token>/', views.purchase, name='purchase'),
path(r'<str:username>/deactivate/', views.deactivate, name='deactivate'),
path(r'deactivated/', views.deactivated, name='deactivated'),
path(r'<str:username>/', views.dashboard, name='dashboard'),
path(r'accounts/login/', views.user_login, name='login'),
path(r'accounts/expired', views.expired, name='expired-account'),
re_path(
r'^(?P<username>w+)/logout/$', auth_views.LogoutView.as_view(),
name='logout'
),
]









share|improve this question





























    0















    I get this error



    NoReverseMatch at /
    Reverse for 'dashboard' with no arguments not found. 1 pattern(s) tried: ['(?P<username>[^/]+)\/$'].


    After a users clicks the login button its expected that the url should redirected to 'domain/username.html', after it has been authenticated and move to the dashboard.html page.



    login1.html



    {% load custom_filters %}
    <a href="" class="btn-back-sign-up" id="dismiss" id="sign-up">
    <i class="fa fa-chevron-left"> &nbsp;SIGNUP</i>
    </a><br><br>
    <p class="text-join">Join our community that have more than 10,000<br> subscribers and learn new things everyday.</p>
    <div class='back' id='login_form'>
    <form id='login-form' method='post' {% url 'accounts:dashboard' %} ><br>
    {% csrf_token %}
    {% for field in form %}
    {% if field.errors %}
    {% if form.errors %}
    <p>Your username and password didn't match. Please try again.</p>
    {% endif %}
    {% endif %}
    <div class="form-group">
    {{ field.label_tag }}
    {{ field|add_class:'form-control'}}
    </div>
    {% endfor %}
    <div class="form-group">
    <input type="text" class="form-control input-upper" id="username" placeholder="Username" name="username" required id="id_username"><br>
    <input type="password" class="form-control input-upper" id="password" placeholder="Password" name="password1" required id="id_password"><br>
    <button type="submit" value='Login' id="top-login-btn" class="btn btn-primary btn-block btn-signup-form-1">LOGIN</button>
    <p class="text-center">or</p>
    <button type="button" class="btn btn-primary btn-block btn-sign-linkedin-1">Login up with LinkedIn</button>
    <p class="text-already">Don't have an account?
    <a href="" data-toggle="modal" class="btn-back-sign-up" data-target="#modal-signup" id="dismiss" id="sign-up">Sign Up</a>
    </p>

    </div>
    </form>
    </div>
    <p class="text-already"><a href="{% url 'password_reset' %}">Forgot Password?</a></p><br>


    views



    @login_required
    def dashboard(request, username):
    """Dashboard page for user"""

    if request.user.username != username:
    return redirect(
    'accounts:dashboard',
    args=(request.user.username,)
    )
    return render(request, 'accounts/dashboard.html', {
    'notifications': request.user.notifications.order_by('-date_added'),
    'sub_token': url_crypt.encode_token((request.user.subscription.plan,))
    })


    urls.py



    name = 'accounts'
    urlpatterns = [
    path(r'accounts/register', views.register, name='register'),
    path(
    r'accounts/account-activation-sent/', views.account_activation_sent,
    name='account_activation_sent'
    ),
    path(
    r'accounts/activate/<uidb64>/<token>/', views.activate,
    name='activate'
    ),
    path(r'purchase/<token>/', views.purchase, name='purchase'),
    path(r'<str:username>/deactivate/', views.deactivate, name='deactivate'),
    path(r'deactivated/', views.deactivated, name='deactivated'),
    path(r'<str:username>/', views.dashboard, name='dashboard'),
    path(r'accounts/login/', views.user_login, name='login'),
    path(r'accounts/expired', views.expired, name='expired-account'),
    re_path(
    r'^(?P<username>w+)/logout/$', auth_views.LogoutView.as_view(),
    name='logout'
    ),
    ]









    share|improve this question



























      0












      0








      0








      I get this error



      NoReverseMatch at /
      Reverse for 'dashboard' with no arguments not found. 1 pattern(s) tried: ['(?P<username>[^/]+)\/$'].


      After a users clicks the login button its expected that the url should redirected to 'domain/username.html', after it has been authenticated and move to the dashboard.html page.



      login1.html



      {% load custom_filters %}
      <a href="" class="btn-back-sign-up" id="dismiss" id="sign-up">
      <i class="fa fa-chevron-left"> &nbsp;SIGNUP</i>
      </a><br><br>
      <p class="text-join">Join our community that have more than 10,000<br> subscribers and learn new things everyday.</p>
      <div class='back' id='login_form'>
      <form id='login-form' method='post' {% url 'accounts:dashboard' %} ><br>
      {% csrf_token %}
      {% for field in form %}
      {% if field.errors %}
      {% if form.errors %}
      <p>Your username and password didn't match. Please try again.</p>
      {% endif %}
      {% endif %}
      <div class="form-group">
      {{ field.label_tag }}
      {{ field|add_class:'form-control'}}
      </div>
      {% endfor %}
      <div class="form-group">
      <input type="text" class="form-control input-upper" id="username" placeholder="Username" name="username" required id="id_username"><br>
      <input type="password" class="form-control input-upper" id="password" placeholder="Password" name="password1" required id="id_password"><br>
      <button type="submit" value='Login' id="top-login-btn" class="btn btn-primary btn-block btn-signup-form-1">LOGIN</button>
      <p class="text-center">or</p>
      <button type="button" class="btn btn-primary btn-block btn-sign-linkedin-1">Login up with LinkedIn</button>
      <p class="text-already">Don't have an account?
      <a href="" data-toggle="modal" class="btn-back-sign-up" data-target="#modal-signup" id="dismiss" id="sign-up">Sign Up</a>
      </p>

      </div>
      </form>
      </div>
      <p class="text-already"><a href="{% url 'password_reset' %}">Forgot Password?</a></p><br>


      views



      @login_required
      def dashboard(request, username):
      """Dashboard page for user"""

      if request.user.username != username:
      return redirect(
      'accounts:dashboard',
      args=(request.user.username,)
      )
      return render(request, 'accounts/dashboard.html', {
      'notifications': request.user.notifications.order_by('-date_added'),
      'sub_token': url_crypt.encode_token((request.user.subscription.plan,))
      })


      urls.py



      name = 'accounts'
      urlpatterns = [
      path(r'accounts/register', views.register, name='register'),
      path(
      r'accounts/account-activation-sent/', views.account_activation_sent,
      name='account_activation_sent'
      ),
      path(
      r'accounts/activate/<uidb64>/<token>/', views.activate,
      name='activate'
      ),
      path(r'purchase/<token>/', views.purchase, name='purchase'),
      path(r'<str:username>/deactivate/', views.deactivate, name='deactivate'),
      path(r'deactivated/', views.deactivated, name='deactivated'),
      path(r'<str:username>/', views.dashboard, name='dashboard'),
      path(r'accounts/login/', views.user_login, name='login'),
      path(r'accounts/expired', views.expired, name='expired-account'),
      re_path(
      r'^(?P<username>w+)/logout/$', auth_views.LogoutView.as_view(),
      name='logout'
      ),
      ]









      share|improve this question
















      I get this error



      NoReverseMatch at /
      Reverse for 'dashboard' with no arguments not found. 1 pattern(s) tried: ['(?P<username>[^/]+)\/$'].


      After a users clicks the login button its expected that the url should redirected to 'domain/username.html', after it has been authenticated and move to the dashboard.html page.



      login1.html



      {% load custom_filters %}
      <a href="" class="btn-back-sign-up" id="dismiss" id="sign-up">
      <i class="fa fa-chevron-left"> &nbsp;SIGNUP</i>
      </a><br><br>
      <p class="text-join">Join our community that have more than 10,000<br> subscribers and learn new things everyday.</p>
      <div class='back' id='login_form'>
      <form id='login-form' method='post' {% url 'accounts:dashboard' %} ><br>
      {% csrf_token %}
      {% for field in form %}
      {% if field.errors %}
      {% if form.errors %}
      <p>Your username and password didn't match. Please try again.</p>
      {% endif %}
      {% endif %}
      <div class="form-group">
      {{ field.label_tag }}
      {{ field|add_class:'form-control'}}
      </div>
      {% endfor %}
      <div class="form-group">
      <input type="text" class="form-control input-upper" id="username" placeholder="Username" name="username" required id="id_username"><br>
      <input type="password" class="form-control input-upper" id="password" placeholder="Password" name="password1" required id="id_password"><br>
      <button type="submit" value='Login' id="top-login-btn" class="btn btn-primary btn-block btn-signup-form-1">LOGIN</button>
      <p class="text-center">or</p>
      <button type="button" class="btn btn-primary btn-block btn-sign-linkedin-1">Login up with LinkedIn</button>
      <p class="text-already">Don't have an account?
      <a href="" data-toggle="modal" class="btn-back-sign-up" data-target="#modal-signup" id="dismiss" id="sign-up">Sign Up</a>
      </p>

      </div>
      </form>
      </div>
      <p class="text-already"><a href="{% url 'password_reset' %}">Forgot Password?</a></p><br>


      views



      @login_required
      def dashboard(request, username):
      """Dashboard page for user"""

      if request.user.username != username:
      return redirect(
      'accounts:dashboard',
      args=(request.user.username,)
      )
      return render(request, 'accounts/dashboard.html', {
      'notifications': request.user.notifications.order_by('-date_added'),
      'sub_token': url_crypt.encode_token((request.user.subscription.plan,))
      })


      urls.py



      name = 'accounts'
      urlpatterns = [
      path(r'accounts/register', views.register, name='register'),
      path(
      r'accounts/account-activation-sent/', views.account_activation_sent,
      name='account_activation_sent'
      ),
      path(
      r'accounts/activate/<uidb64>/<token>/', views.activate,
      name='activate'
      ),
      path(r'purchase/<token>/', views.purchase, name='purchase'),
      path(r'<str:username>/deactivate/', views.deactivate, name='deactivate'),
      path(r'deactivated/', views.deactivated, name='deactivated'),
      path(r'<str:username>/', views.dashboard, name='dashboard'),
      path(r'accounts/login/', views.user_login, name='login'),
      path(r'accounts/expired', views.expired, name='expired-account'),
      re_path(
      r'^(?P<username>w+)/logout/$', auth_views.LogoutView.as_view(),
      name='logout'
      ),
      ]






      django django-forms django-authentication






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 10:18









      Alasdair

      181k26306309




      181k26306309










      asked Nov 14 '18 at 10:12









      David ToluDavid Tolu

      65




      65
























          1 Answer
          1






          active

          oldest

          votes


















          0














          from urls:



          path(r'<str:username>/', views.dashboard, name='dashboard'),


          means, you need to call the dashboard url with an username argument in template. You can fix it by in urls:



          path(r'', views.dashboard, name='dashboard'),


          and keep the template as it is.






          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53297690%2fnoreversematch-at-reverse-for-dashboard-with-no-arguments-not-found-1-patte%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            from urls:



            path(r'<str:username>/', views.dashboard, name='dashboard'),


            means, you need to call the dashboard url with an username argument in template. You can fix it by in urls:



            path(r'', views.dashboard, name='dashboard'),


            and keep the template as it is.






            share|improve this answer






























              0














              from urls:



              path(r'<str:username>/', views.dashboard, name='dashboard'),


              means, you need to call the dashboard url with an username argument in template. You can fix it by in urls:



              path(r'', views.dashboard, name='dashboard'),


              and keep the template as it is.






              share|improve this answer




























                0












                0








                0







                from urls:



                path(r'<str:username>/', views.dashboard, name='dashboard'),


                means, you need to call the dashboard url with an username argument in template. You can fix it by in urls:



                path(r'', views.dashboard, name='dashboard'),


                and keep the template as it is.






                share|improve this answer















                from urls:



                path(r'<str:username>/', views.dashboard, name='dashboard'),


                means, you need to call the dashboard url with an username argument in template. You can fix it by in urls:



                path(r'', views.dashboard, name='dashboard'),


                and keep the template as it is.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 14 '18 at 10:21

























                answered Nov 14 '18 at 10:18









                ruddraruddra

                13.8k32748




                13.8k32748






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53297690%2fnoreversematch-at-reverse-for-dashboard-with-no-arguments-not-found-1-patte%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Xamarin.iOS Cant Deploy on Iphone

                    Glorious Revolution

                    Dulmage-Mendelsohn matrix decomposition in Python