Issue
class Appointment(models.Model):
CATEGORY = (
('Plumbing', 'Plumbing'),
('Electrical', 'Electrical'),
('Cleaning', 'Cleaning'),
)
STATUS = (
('Pending', 'Pending'),
('Delivered', 'Delivered'),
)
user = models.ForeignKey(Client, null=True, on_delete=models.SET_NULL)
worker = models.ForeignKey(Worker, null=True, on_delete=models.SET_NULL)
category = models.CharField(max_length=200, null=True, choices=CATEGORY)
task_date = models.DateField(_("Task Date"), blank=True, null=True)
task_location = models.CharField(max_length=200, null=True)
date_created = models.DateTimeField(auto_now_add=True, null=True)
status = models.CharField(max_length=200, null=True, choices=STATUS)
task_description = models.CharField(max_length=1000, null=True)
def __str__(self):
return str(self.user)
forms.py file
class AppointmentForm(ModelForm):
class Meta:
model = Appointment
fields = '__all__'
exclude = ['user','worker','status']
widgets = {'task_date': forms.DateInput(format='%d/%m/%Y')}
Solution
I dont see yours imports, but try to import widgets from django.forms and use "widgets.DateInput" instead of "forms.DateInput" in AppointmentForm like this:
from django.forms import widgets
class AppointmentForm(ModelForm):
class Meta:
model = Appointment
fields = '__all__'
exclude = ['user','worker','status']
widgets = {'task_date': widgets.DateInput(attrs={'type': 'date'})
Answered By - henry_fool
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.