Hi i want to add manually form in django templates i have my model like that
class ProjectType(models.Model):
name = models.CharField(_("Project type name"), max_length=150)
def __str__(self):
return self.name
my forms.py
class RequestedProjectUserForm(forms.ModelForm):
class Meta:
model = RequestedProject
fields = '__all__'
exclude = ['client', 'amount', 'progress',
'notes', 'deadline', 'refused_cause', 'project_situation']
widgets = {
'type_selected': forms.CheckboxSelectMultiple()
}
def __init__(self, *args, **kwargs):
super(RequestedProjectUserForm, self).__init__(*args, **kwargs)
self.fields['project_name'].widget.attrs.update(
{'class': 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500'})
self.fields['type_selected'].widget.attrs.update({'class': 'sr-only peer'})```
in template
i have this
{% for error in form.type_selected.errors %}
<p><small class="text-sm text-red-700 dark:text-red-500">{{ error }}</small></p>
{% endfor %}
{% for type_selected in form.type_selected %}
<label for="{{ type_selected.id_for_label }}"
class="inline-flex relative items-center mb-4 cursor-pointer">
<input type="checkbox" name="type_selected" id="{{ type_selected.id_for_label }}"
class="sr-only peer" {% if type_selected.value %} checked {% endif %}
value="{{type_selected.value}}">
<div
class="w-11 h-6 bg-gray-200 rounded-full peer peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5 after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600">
</div>
<span
class="ml-3 text-sm font-medium text-gray-900 dark:text-gray-300">{{type_selected.choice_label}}</span>
</label>
{% endfor %}
when i want to save the forms i got error “” is not a valid value.
haw can i add the value in template