I am working on contact form in admin page, but having problem with showing
checkmark. The form should show checkmark box in front of each item. I
removed other fields, just showing data for location_in_home . any help?
[image: 2023-05-04_13-24-23.png]
*models.py*
class Location(models.Model):
class Contact(models.Model):
LOCATION_INHOME = (
('kitchen', 'Kitchen'),
('bathroom', 'Bathroom'),
('bedroom', 'Bedroom'),
('livingroom', 'Living Room'),
('basement', 'Basement'),
('garage', 'Garage'),
('office', 'Office'),
('hallway', 'Hallway'),
('stairway', 'Stairway'),
('recreationroom', 'Recreation Room'),
('closet', 'Closet'),
('other', 'Other'),
)
location_in_home = models.ManyToManyField(Location)
class ContactForm(ModelForm):
model = Contact
fields = '__all__'
class Meta:
model = Contact
fields = '__all__'
*forms.py*
from django import forms
from django.forms import ModelForm
from .models import Contact
class ContactForm(forms.ModelForm):
class Meta:
model = Contact
fields = [
'location_in_home',
]
widgets = {
'location_in_home': forms.CheckboxSelectMultiple(),
}
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/f13cc346-e406-40a2-94ea-d5510978df16n%40googlegroups.com.