why I'm getting this error?
I don't know how to get rid of this error. How can i clean the form field to enable the username to be validated?
Thanks in advance.
class InboxCompany(generic.UpdateView):
model = CandidateToJob
template_name = 'dashboard/inbox-company.html'
form_class = ComposeMessage
def get(self, *args, **kwargs):
recipient = self.get_object(queryset=CandidateToJob.objects.select_related('candidate'))
if recipient is not None:
user = User.objects.get(username=recipient.candidate.user.username)
self.initial = {'recipient': user}
return super(InboxCompany, self).get(*args, **kwargs)
forms.py
class ComposeMessage(ModelForm):
recipient = forms.CharField(
required=True,
widget=forms.TextInput(attrs={'class': 'form-control'})
)
body = forms.CharField(
required=True,
widget=forms.TextInput(attrs={'class': 'form-control'})
)
class Meta:
model = Message
I got it working finally.
Here is my answer:
The views.py
The forms.py
The models.py