Django: How to use 1 form of 2 forms in one view?
I have app like this:
When I want to login, the data from username and password go to first form "Search friend or event" and I get a bad template. How to mark form to the suitable view?
First form:
def search_friend(request):
if request.method == 'GET':
search = request.GET.get('search')
results = User.objects.filter(username=search)
return render(request, 'friends/search_friend.html',
{'results': results})
<div class="middlenavbar">
<form action="{% url 'search-friend' %}" method="GET">
<input id="middlesearchinput" type="search" placeholder="Search friend or event">
<button id="magniferbutton" type="submit"><i class="icon-search"></i></button>
</div>
Second form:
login is from LoginView
<div>
<form action="{% url 'login' %}" method="POST" >
{% csrf_token %}
{{ form|crispy }}
<div>
<button type="submit">Login</button>
</div>
</form>
<small >
Need An Account? <a href="{% url 'register' %}">Sign Up Now</a>
</small>
</div>