minha página de inscrição não está aparecendo os campos de seleção, meu código é o seguinte:
forms.py
class InscricaoForm(forms.Form):
VINCULO = [
(u'b', u'Bolsista'),
(u'e', u'Estagiário'),
(u't', u'Terceiro'),
(u's', u'Servidor'),
]
SALAS = [
(u'1', u'SysAdmin'),
(u'2', u'Help Desk'),
]
vinculo = forms.ChoiceField(choices=(VINCULO), label='Vinculo')
registro = forms.IntegerField(label=_('Registro'))
nome = forms.CharField(label=_('Nome'))
email_inpe = forms.EmailField(label=_('Email @ Inpe'))
email = forms.EmailField(label=_('Email'))
data_admissao = forms.DateField(label=_('Data de Admissao'))
sala = forms.CharField(widget=forms.Select(choices=SALAS),label=_('Salas'))
ramal = forms.CharField(label=_('Ramal'))
class Bolsista_EstagiarioForm(InscricaoForm):
data_fim_contrato = forms.DateField(label=_('Data de Fim de Contrato'))
class TerceiroForm(InscricaoForm):
empresa = forms.CharField(label=_('Empresa'))
class ServidorForm(InscricaoForm):
tipo = forms.CharField(label=_('Tipo de Servidor'))
class InscricaoForm(forms.ModelForm):
class Meta:
model = Inscricao
fields = '__all__'
models.py
VINCULO = (
(u'b', u'Bolsista'),
(u'e', u'Estagiário'),
(u't', u'Terceiro'),
(u's', u'Servidor'),
)
SALAS = (
(u'1', u'SysAdmin'),
(u'2', u'Help Desk'),
)
EMPRESAS = (
(u'1', u'Cray'),
(u'2', u'Outros'),
)
SERVIDOR = (
(u'1', u'Técnico'),
(u'2', u'Tecnologista'),
)
class Inscricao(models.Model):
# criando relacionamento 1:1 com o user do django
usuario = models.OneToOneField(User)
vinculo = models.CharField(max_length=100, choices=VINCULO)
registro = models.IntegerField()
email_inpe = models.EmailField(blank=True)
data_admissao = models.DateField()
sala = models.CharField(max_length=100, choices=SALAS)
ramal = models.CharField(max_length=30)
criado_em = models.DateTimeField('criado em', auto_now_add=True)
class Meta:
abstract = True
class Bolsista_Estagiario(Inscricao):
data_fim_contrato = models.DateField()
class Meta:
verbose_name_plural = "Bolsistas e Estagiários"
class Terceiro(Inscricao):
empresa = models.CharField(max_length=30, choices=EMPRESAS)
class Meta:
verbose_name_plural = "Terceiros"
class Servidor(Inscricao):
tipo = models.CharField(max_length=30, choices=SERVIDOR)
class Meta:
verbose_name_plural = "Servidores"
views.py
def inscricao(request):
form_class = InscricaoForm
# new logic!
if request.method == 'POST':
form = form_class(data=request.POST)
if form.is_valid():
vinculo= request.POST.get(
'vinculo'
, '')
registro= request.POST.get(
'registro'
, '')
nome = request.POST.get(
'nome'
, '')
email_inpe= request.POST.get(
'email_inpe'
, '')
email= request.POST.get(
'email'
, '')
data_admissao= request.POST.get(
'data_admissao'
, '')
form_content = request.POST.get('content', '')
# Email the profile with the
# contact information
template = get_template('contact_template.txt')
content = template.render({'vinculo': vinculo,'registro': registro,
'nome': nome,'email_inpe': email_inpe,
'email': email,'data_admissao': data_admissao,'form_content': form_content})
email = EmailMessage(
"Novo usuário cadastrado",
content,
"Portal Cptec" +'',
['[email protected]'],
headers = {'Reply-To': '[email protected]' }
)
email.send()
messages.success(request, 'Profile details updated.')
admin.py
class InscricaoAdmin(UserAdmin):
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('username', 'email', 'first_name', 'last_name', 'password1', 'password2'),
}),
)
admin.site.register(Bolsista_Estagiario)
admin.site.register(Servidor)
admin.site.register(Terceiro)
#admin.site.register(Inscricao)
admin.site.unregister(User)
admin.site.register(User, InscricaoAdmin)