Here is my Base.html
<div >
<div >
<form action='simple_test'>
<button id="simple_test" > Generate</button>
</form>
</div>
</div>
Here is my View.py
from django.http import HttpResponse
from django.shortcuts import render
from datetime import datetime
from django.template import loader
from django.core.files import File
from .unun import some_func
import random
import os
def index(request):
strinput = {}
glued, oldgued = some_func()
strinput['IntPassHMTL'] = 433
strinput['StrPassHMTL'] = glued
strinput['BeforeGlued'] = oldgued
return render(request,'index.html', strinput )
def simple_test(request):
strinput = {}
# glued, oldgued = some_func()
strinput['IntPassHMTL'] = 433
strinput['StrPassHMTL'] = "glued"
strinput['BeforeGlued'] = "oldgued"
print("Words?")
return HttpResponse("This is a fake 404!")
Here is my urls.py
urlpatterns = [
path('admin/', admin.site.urls),
print("simple_test", views.simple_test),
path('', views.index, name="index"),
]
I tried to apply these solutions to my codes and they still do not work right for me. Not sure what I am missing.
CodePudding user response:
Try adding / after your URL it should work.
'''
urlpatterns = [
path('admin/', admin.site.urls),
print("simple_test/", views.simple_test),
path('', views.index, name="index"),
]
'''
CodePudding user response:
Instead of path
you have put print
, so you haven't actually added the URL to your urlpatterns
list! Try this:
urlpatterns = [
path('admin/', admin.site.urls),
path("simple_test/", views.simple_test),
path('', views.index, name="index"),
]
The forward slash is only mandatory if you set APPEND_SLASH = True
in your settings.py
file.