root urls
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^', include('profs.urls')),
]
app urls
app_name = 'profs'
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^contact/', views.contact, name='contact'),
url(r'^check_login/', views.check_login, name='check_login'),
url(r'^(?P<url_name_para>[a-zA-Z]+)/$', views.show, name='show'),
url(r'^(?P<url_name_para>[a-zA-Z]+)/edit_news/$', views.edit_news, name='edit_news'),
]
view
def check_login(request):
if request.method == 'POST':
if request.POST.get('username') != '' and request.POST.get('password') != '' and request.POST.get('password') != 'free':
prof = get_object_or_404(Professional, url_name=request.POST.get('username'))
if prof.subscription == request.POST.get('password'):
return redirect('edit_news', url_name_para = request.POST.get('username'))
#return render(request, 'profs/edit_news.html', {'prof': prof})
else:
return render(request, 'profs/test.html', {'val': 1})
else:
return render(request, 'profs/test.html', {'val': 2})
else:
return render(request, 'profs/test.html', {'val': 3})
I try to redirect but I get
NoReverseMatch at /check_login/
Reverse for 'edit_news' with arguments '()' and keyword arguments '{'url_name_param': 'dtsik'}' not found. 0 pattern(s) tried: []
I read to other posts here that i have to remove "$" from empty url, when I do these
url(r'^', views.index, name='index'),
no error thrown but also no redirect to 'edit_news' , stay in same page an adds '/check_login/' in address bar