#NoReverseMatch at /createannouncement/
1 messages · Page 1 of 1 (latest)
Please do not ping individual users, unless they specifically requested it.
We're all volunteers here, and have limited time to answer questions.
but i need help
So do other users, and they do just fine asking a question and patiently waiting for a response.
ok
You don't put urls into {% url %} it defeats the purpose
i got it
im getting error on logout/ its says page not working
how to resolve this
Make it work
You gave zero information, what you expect from us? If you say it doesn't work I say make it work. If you say you tried I say try again. If you share code and error traceback - then maybe we'll have something to work with
base.html
<a class="nav-link" href="{% url 'logout' %}">LogOut</a>
</li>
path("logged_out/", LogoutView.as_view(next_page="/login/"), name="logout"),
logged_out.html
{% block title %}Logged Out{% endblock %}
{% block content %}
<h1>Logged Out</h1>
<p>
You have been successfully logged out.
you can <a href="{% url 'login' %}">log-in again</a>.
</p>
{% endblock %}
up
Ok, templates look ok, what is the error?
http://127.0.0.1:8000/logged_out/
405 method not allowed (what the hell is "page isn't working"? Lol)
You are trying to logout with GET method most likely, that is not allowed
then?
You need to make a POST request, usually by making logout button a <form> submit
oh
which file i needs to add
<li class="nav-item">
<a class="nav-link" href="{% url 'logout' %}">LogOut</a>
</li>
instead of this
or make a form on logout page itself, but it's more work
You can just use an inline form and styleze button as a link
you can make your code much more readable here on discord via
```py
code here
```
or for django templates use
```django
template here
```
thanks
</li>
<form action='{% url "logout"%}' method="POST">
{% csrf_token %}
<input
type="submit"
value="Logout"
class="my-style-for-logout-button"
/>
</form>
<form action='{% url "logout"%}' method="POST">
can u help me i got som error
Show your urls please
Ah, wait
So which of the errors? That's different matters
from . import views
from django.urls import path
from django.conf import settings
from django.conf.urls.static import static
from .views import contact_view, contact_success_view, login_view, register_view
from django.contrib.auth import logout
urlpatterns = [
path("", views.AllPostsView.as_view(), name="home"),
path("create_post/", views.create_post, name="create_post"),
path("login/", login_view, name="login"),
path("logout/", logout, name="logout"),
path("register/", register_view, name="register"),
path("<slug:slug>/", views.DjangoDetail.as_view(), name="django_detail"),
]
Hm, strange you are using a built-in logout view?
It shouldn't give this error
how to fix
??
<form action="{% url 'logout' %}" method="POST">
{% csrf_token %}
<input
type="submit"
value="Logout"
class="my-style-for-logout-button"
/>
</form>
Not sure for now, you didn't touch Django code?
ok
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/logout/
Django Version: 5.0.1
Python Version: 3.12.2
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'Blog_app']
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.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback (most recent call last):
File "C:\Users\mvams\krish\Lib\site-packages\django\core\handlers\exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mvams\krish\Lib\site-packages\django\core\handlers\base.py", line 204, in _get_response
self.check_response(response, callback)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mvams\krish\Lib\site-packages\django\core\handlers\base.py", line 332, in check_response
raise ValueError(
^
Exception Type: ValueError at /logout/
Exception Value: The view django.contrib.auth.logout didn't return an HttpResponse object. It returned None instead.