Friday, May 30, 2014

Fwd: Django Template - problema

I have the following problem. The field "tipo_conjuge" is not showing as I wanted. Could somebody tell me what is the problem?

Best regards,
Erick


url. py

...
url(r'relacao/(?P<conjuge>\d+)/$', login_required(CreateTipoRelacaoView.as_view()), name='cadastrarRelacaoTipo'),
...


views.py

...
class CreateTipoRelacaoView(CreateView):
    model = RelacaoConjugeTipoUniao
    fields = ['tipo_conjuge','data_inicio','data_fim']

    def form_valid(self, form):
        relacao = get_object_or_404(RelacaoConjuge, id=self.kwargs['relacao'])
        form.instance.relacao = relacao
        return super(CreateTipoRelacaoView, self).form_valid(form)


models.py

class RelacaoConjugeTipoUniao(models.Model):

    TIPO_CONJUGE = (
        ('CA', _('Casados')),
        ('UE', _('União estável')),
        ('OU', _('Outros')),
    )

    tipo_conjuge = models.CharField(_('Tipo'), max_length=2, choices=TIPO_CONJUGE, blank=False, null=False)
    data_inicio = models.DateField(_('Data de início'))
    data_fim = models.DateField(_('Data de término'))
   ...


relacaoconjugetipouniao_form.html

{% extends 'pessoa/base_voltar.html' %}
{% block content %}
    <form id="formulario" action="" method="POST">{% csrf_token %}
        {{ form.non_field_errors }}
            <div class="fieldWrapper">
            {{ form.tipo_conjuge.errors }}
            <label for="tipo_conjuge">Tipo de União:</label><br/>
            {{ form.tipo_conjuge }}
        </div><br/>
        <div class="fieldWrapper">
            {{ form.data_inicio.errors }}
            <label for="data_inicio">Data de início:</label><br/>
            {{ form.data_inicio }}
        </div><br/>
        <div class="fieldWrapper">
            {{ form.data_fim.errors }}
            <label for="data_fim">Data de término:</label><br/>
            {{ form.data_fim }}
        </div><br/>
        <input type="submit" value="Salvar" class="button">
        <input type="reset" value="Cancelar" class="button">
    </form>
    <br/>
    <a href="#">Voltar</a>
{% endblock content %}

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CALUDr%2B0e1ZfcuLZRsHWcOR5L-LiS%3DqLPw-bWv6-SqCHqTrFBPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment