Я получаю эту ошибку
NoReverseMatch at /
Reverse for 'dashboard' with no arguments not found. 1 pattern(s) tried: ['(?P<username>[^/]+)\\/$'].
После того, как пользователь нажмет кнопку входа в систему, ожидается, что URL-адрес будет перенаправлен на домен / username.html, после того как он будет аутентифицирован и перейдет на страницу dashboard.html.
login1.html
{% load custom_filters %}
<a href="" class="btn-back-sign-up" id="dismiss" id="sign-up">
<i class="fa fa-chevron-left"> 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>
вид
@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'
),
]