I have following problem:
I would like to call a function vyroci_mesicV
from a module vyroci
in my view.py
.
When I simply try print(vyroci.vyroci_mesicV())
in the terminal in VS Code I got the desired output. However, when I run py manage.py runserver
and run the local host I got and error message AttributeError: 'function' object has no attribute 'vyroci_mesicV'
Here is the code of views.py if needed:
def vyroci(request):
error_msg = None
vysledek = None
if request.method == "POST":
if (request.POST["operator"] == "Vysehrad"):
vysledek = vyroci.vyroci_mesicV()
else:
error_msg = "something wrong :("
return render(request, "vyroci/vyroci.html", dict(error_msg=error_msg, vysledek=vysledek))
return render(request, "vyroci/vyroci.html", dict(error_msg=error_msg, vysledek=vysledek))
and here the vyroci.html if needed:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>XXX</title>
</head>
<body>
<form method="POST">
{% csrf_token %}
<span style="color: red;">{{error_msg}}</span>
<br>
<select name="operator">
<option value="Vysehrad" {% if request.POST.operator == "Vysehrad" %} selected {% endif %}>Vyšehrad</option>
</select>
<input type="submit"><br>
{{vysledek}}
</form>
</body>
</html>