I am building a BlogApp and while trying to styling the forms i got this error. :-
|as_crispy_field got passed an invalid or inexistent field
edit.html
{% load crispy_forms_tags %}
{% block content %}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
<table>
{{ allowance_form|as_crispy_field }}
</table>
<button type="submit">Save Changes</button>
</form>
</div>
{% endblock content %}
views.py
def edit_allowance(request,user_id):
if request.method == 'POST':
allowance_form = ProfilePhotoAllowForm(request.POST, request.FILES, instance=request.user.profile)
if allowance_form.is_valid():
custom_form = allowance_form.save(False)
custom_form.save()
return redirect('profiles',user_id=user_id)
else:
allowance_form = ProfilePhotoAllowForm(instance=request.user.profile)
context = {'allowance_form':allowance_form}
return render(request, 'edit.html', context)
Whenever i run the page it keep showing me this |as_crispy_field got passed an invalid or inexistent field
Error.
I don't know what's wrong in this Code. I checked all answered on StackOverFlow BUT they didn't help me in this.
Any help would be appreciated.
Thank You in Advance.
question from:
https://stackoverflow.com/questions/65907981/as-crispy-field-got-passed-an-invalid-or-inexistent-field-in-charfield 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…