Hi Everyone,
I am trying to use daisyui components for django model form, however, django does not render the components at all. Below is my code.
my model form:
from django import forms
from .models import Visitor
state_choices = {'VIC':'VIC','NSW':'NSW','WA':'WA'}
class VisitorForm(forms.ModelForm):
class Meta:
model = Visitor
fields = ['name','whom_visiting','whom_representing','location']
widget = {
"name": forms.TextInput(attrs={'class':'input input-bordered w-full max-w-xs','placeholder':'Full Name',}),
"whom_representing": forms.TextInput(attrs={'class':'input input-bordered w-full max-w-xs','placeholder':'Whom Representing'}),
"whom_visiting": forms.TextInput(attrs={'class':'input input-bordered w-full max-w-xs','placeholder':'Whom Visiting'}),
"location": forms.Select(choices=state_choices),
}
my template:
{% block content %}
<form action="">
{% csrf_token %}
<div class="flex flex-col gap-4 items-center">
{{form}}
</div>
</form>
<br>
<div class="flex justify-center gap-4">
<a href="" class="btn">Check-In</a>
<a href="{% url "visitor_menu" %}" class="btn">Back</a>
</div>
{% endblock content %}
FYI, I use django-tailwind and include daisyui as pluggin (followed instructions in this link tailwind css - Can I add Daisy UI plugin to my django project? If yes , Please how do I do it? - Stack Overflow)
Thank you.