Skip to content

Instantly share code, notes, and snippets.

@selimhamidou
Last active October 2, 2020 20:55
Show Gist options
  • Save selimhamidou/3a49949b9c24d046117b8a264c84da06 to your computer and use it in GitHub Desktop.
Save selimhamidou/3a49949b9c24d046117b8a264c84da06 to your computer and use it in GitHub Desktop.
Mes logs :
non
[02/Oct/2020 20:49:50] "GET /options/ HTTP/1.1" 200 202
[02/Oct/2020 20:49:56] "POST / HTTP/1.1" 200 1431
La page 'homeview se charge quand j'appuie sur 'ok'
J'essaie de comprendre pourquoi request.method n'est jamais egal à 'POST'.
Tu sais pourquoi?
Merci beaucoup,
Sélim
<form method='POST' action="{% url 'homeview' %}">
{% csrf_token %}
<input type="submit" value="OK">
</form>
from django.contrib import admin
from django.urls import path, include
from appli import views
from django.conf.urls import url
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.home_view, name='homeview'),
path('options/', views.options, name='options'),
def options(request):
if request.method=='GET':
print('non')
else:
print('ok')
return render(request, 'appli/options.html', {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment