Here is my base.html
<div class="container">
<div class="center">
<form action='simple_test'>
<button id="simple_test" class="button-3d"> 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"),
]
misspelled pointed by @0svoid
path("simple_test", views.simple_test),
#print("simple_test", views.simple_test),
I tried to apply this solution to my codes and they still do not work right for my project. Not sure what I am missing.
2
Answers
Try adding / after your URL and in second URL you have print instead of path make these changes it should work.
”’
”’
Instead of
path
you have putprint
, so you haven’t actually added the URL to yoururlpatterns
list! Try this:The forward slash is only mandatory if you set
APPEND_SLASH = True
in yoursettings.py
file.