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


{% 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 %}
        {{ allowance_form|as_crispy_field }}
        <button type="submit">Save Changes</button>

{% endblock content %}


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)
            return redirect('profiles',user_id=user_id)

        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.