It worked. Thank you very much
2014-05-31 4:33 GMT-03:00 Kelvin Wong <wongo888@gmail.com>:
At the very top of the models.py file add:# -*- coding: utf-8 -*-from __future__ import unicode_literalsI'm not sure this will work, but it might.K
On Friday, May 30, 2014 8:35:58 PM UTC-7, ebrockes wrote:I'll see how to solve this issue. Any clues?Problem solved by replacing on models.py:by
TIPO_CONJUGE = (
('CA', _('Casados')),
('UE', _('União estável')),
('OU', _('Outros')),
)
TIPO_CONJUGE = (
('CA', _('Casados')),
('UE', _('Uniao estavel')),
('OU', _('Outros')),
)
2014-05-31 0:11 GMT-03:00 Erick Brockes <ebro...@gmail.com>:Could you help me out on how to proceed?I've got the following response in the browser:Kevin, Thank you.If you don't mind, I'm kind of new in django.
{'tipo_conjuge': <django.forms.fields.TypedChoiceField object at 0xb4dcb7ec>}
2014-05-30 18:45 GMT-03:00 Kelvin Wong <wong...@gmail.com>:
In relacaoconjugetipouniao_form.htmlAdd this tag...then refresh...{{ form.fields }}Should give you more info about what fields are in the form and what widget they are using.
ie. 'tipo_conjuge': django.forms.fields.TypedChoiceField objectAlso check your html source in a browser. Sometimes CSS mistakes hide things.
K
On Friday, May 30, 2014 7:40:01 AM UTC-7, ebrockes wrote: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 %}To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@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/2c343d4f-48e4-4e5a-a02f-137edc1b0de2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e8e23e48-3b52-42bd-983d-cd47f92d63ac%40googlegroups.com.
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.
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%2B2aFtYHMPJp4xWPLH7jKWyCkWM8FTp4oFrk6Le4_CwYHw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment