no django reverse match

38 views
Skip to first unread message

ashutosh...@gmail.com

unread,
Jul 9, 2016, 10:21:06 AM7/9/16
to Django users
this is my  login view ...


def login(request):
# c = {}
# c.update(csrf(request))
return render(request, 'envato.rathemes.com/infinity/topbar/login.html')


def auth_view(request):
username = request.POST.get('username', '')
password = request.POST.get('password', '')
user = auth.authenticate(username=username, password=password)
if user is not None:
auth.login(request, user)
return redirect('message_board:list')
else:
return HttpResponse('notauthenticate....please login with correct detail', status=403)

Im trying to go on new app and the urls for new app is this --


urlpatterns = [
url(r'^message_board/$', views.message, name='message'),
url(r'^message_board/post_new$', views.post_new, name='post_new'),
#url(r'^message_board/post_detail$', views.post_detail, name='post_detail')
url(r'^message_board/post_detail/(?P<pk>\d+)/$', views.post_detail, name='post_detail'),
]

and message board view is this -----


def message(request):
posts = Post.objects.order_by('-created_date')
return render(request, 'post_list.html', {'xyz': posts})


@login_required
def post_new(request):
if request.method == "POST":
form = PostForm(request.POST)
if form.is_valid():
post = form.save(commit=False)
post.author = request.user
post.published_date = timezone.now()
post.save()
return redirect('message_board:list')
else:
form = PostForm()
return render(request, 'post_edit.html', {'form': form})




please help me please......

ludovic coues

unread,
Jul 9, 2016, 3:38:12 PM7/9/16
to django...@googlegroups.com
After reading your message, I don't know what the app should do, and
what happen currently.
I don't know if there is an error or not. Some part are missing like
the imports, app_name in urls.py or the url for message_board:list.


As a sidenote, I will suggest you to look the authentication views [1]
and the generic forms view [2]. These should make your life easier :)

[1] https://docs.djangoproject.com/en/1.9/topics/auth/default/#all-authentication-views
[2] https://docs.djangoproject.com/en/1.9/topics/class-based-views/generic-editing/#model-forms
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/832b97b8-0d25-4718-86ee-7ae87599f163%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Coues Ludovic
+336 148 743 42
Reply all
Reply to author
Forward
0 new messages