SOLVED.
It turns out a better approach was to call objects in the template like:
<form role="form" method="post" action="{{ action }}">
{% csrf_token %}
<div class="form-group">
<label for="id_job">Select Job Position</label>
<select class="form-control" id="id_job" name="job">
<option value="">Choose</option>
{% for job in user.company.job_set.all %}
<option value="{{ job.title }}">{{ job.title }}</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="id_status">Status</label>
{{ form.status }}
{{ form.status.errors }}
</div>
<button type="submit" class="btn btn-sm btn-success">Confirm</button>
</form>
class SendCandForm(forms.Form):
job = forms.CharField(label="Vaga", required=True,
widget=forms.TextInput(attrs={'class': 'form-control'}))
STATUS_CHOICES = (
('0', 'Novo'),
('1', 'Não aprovado'),
('2', 'Pré Selecionado'),
('3', 'Contratado')
)
status = forms.ChoiceField(required=True,
widget=forms.RadioSelect(attrs={'class': ''}), choices=STATUS_CHOICES)
def save():
job = self.cleaned_data['job']
status = self.cleaned_data['status']
ctj = CandidateToJob(
job = job,
status = status,
candidate = candidate,
)
ctj.save()
return ctj
Em domingo, 5 de abril de 2015 22:11:03 UTC-3, Ronaldo Bahia escreveu:
>
>
> One more thing. The Job form field is showing the jobs from all companies.
> But I ned to filter only the jobs published by the user which is logged in.
>
> I've tried but couldn't make it happen.
>
> Can you tell how to do it?
>
> Thanks
>
> #forms.pyclass SendCandForm(forms.Form):
>
> job = Company.objects.select_related('job').values_list('job__title',
> flat=True)
> jobs_choices = [('', 'Escolher')] + [(id, id) for id in job]
>
> job = forms.ChoiceField(choices=jobs_choices, label="Vaga",
> required=True, widget=forms.Select(attrs={'class': 'form-control'}))
>
> STATUS_CHOICES = (
> ('0', 'Novo'),
> ('1', 'Não aprovado'),
> ('2', 'Pré Selecionado'),
> ('3', 'Contratado')
> )
> status = forms.ChoiceField(required=True,
> widget=forms.RadioSelect(attrs={'class': ''}), choices=STATUS_CHOICES)
>
> def save():
> job = self.cleaned_data['job']
> status = self.cleaned_data['status']
> ctj = CandidateToJob(
> job = job,
> status = status,
> candidate = candidate,
> )
> ctj.save()
>
> return ctj
>
>
>
> 2015-04-04 8:49 GMT-03:00 Ronaldo Bahia <[email protected]>:
>
>> SOLVED
>>
>> http://stackoverflow.com/questions/29413107/django-modelform-object-has-no-attribute-cleaned-data-for-m2m-through/29446017#29446017
>>
>> Thanks Vijay for helping me
>>
>> Regards,
>> Ronaldo
>>
>>
>>
>> Em quinta-feira, 2 de abril de 2015 09:36:29 UTC-3, Ronaldo Bahia
>> escreveu:
>>>
>>>
>>> Hi every one.
>>>
>>> Can you help me in this?
>>>
>>> http://stackoverflow.com/questions/29413107/django-
>>> modelform-object-has-no-attribute-cleaned-data-for-m2m-through
>>>
>>> Thanks in advance
>>> Ronaldo
>>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/django-users/Ve_RLvkK4Gs/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/d1188860-711c-47c0-b0ae-20b66ab94711%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/django-users/d1188860-711c-47c0-b0ae-20b66ab94711%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/0cac97b4-8b18-496e-a172-b15b75fefa74%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.