usuario
, a phones and a class manager, which are one to one, like this:
class Usuario(models.Model):
login = models.CharField(max_length=50, unique=True)
senha = models.CharField(max_length=50)
telefone = models.ForeignKey(TelefonesUsuario)
class TelefonesUsuario(models.Model):
telefone = models.CharField(max_length=11)
class Gerente(models.Model):
departamento = models.CharField(max_length=10)
usuario = models.OneToOneField(Usuario)
If I want to register a new customer, how do I? (abstracting layout)
I have tried this so far:
No forms:
from django import forms
from app.models import Usuario
class FormUsuario(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput())
class Meta:
model = Usuario
Na view:
def teste(request):
form = FormUsuario()
return render_to_response("teste.html", {'form': form}, context_instance=RequestContext(request))
And no .html:
<form action="" method="post">
{% csrf_token %}
{{ form.login }}
{{ form.senha }}
{# {{ form.telefone }} -> exception #}
{{ form.departamento }} {# -> não aparece na página #}
</form>
Can anyone give me a hint of how I'm following?