'Crisp keeps on throwing error 'BoundWidget' object has no attribute 'field'

Using crisp tags for creating a user registration form in Django application. Here are codes in few my files to help:

Settings.py

INSTALLED_APPS = [
'blog.apps.BlogConfig',
'users.apps.UsersConfig',
'crispy_forms',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

HTML File

{% extends "blog/base.html" %}
{% load crispy_forms_tags %}
{% block content %}

{% csrf_token %}
{{form.first_name|crispy}}
  {{form.last_name|crispy}}
{{form.username|crispy}}
{{form.email}}
{{form.password1|crispy}}
{{form.password2|crispy}}

other statements are CSS and HTML which i feel are not the concerned part for this question. However I will like to add that I do have done some styling for the Input tags (the form input fields).

Form.py

from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm

class UserRegisterForm(UserCreationForm):
    first_name = forms.CharField()
    last_name = forms.CharField()
    email = forms.EmailField()
    username = forms.TextInput(attrs={'placeholder': 'Username'})


    class Meta:
        model = User
        fields = ['first_name','last_name', 'username', 'email', 'password1', 'password2']

I have added the screenshot of errors thrown when webpage is requested: The webpage and error

The other part of the question or the reason I am using crisp is I need to authenticate input information and want to display warnings accordingly in short i want to customize the wrong input warnings for the registration form a referral to that kind of article is appreciated as i am unable to find one.



Solution 1:[1]

I had the same issue ,try this , it worked for me: in the html file use:

{{form.first_name| as_crispy_field }}

Solution 2:[2]

In HTML file, just put either this{{form|crispy}} or {{form.fieldname|as_crispy_field}}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 bkk
Solution 2 Hardik Patil