hi i have a problem when i try to render my form without information .
so my code is :
models.py
class Obra(models.Model):
cod_obra= models.CharField("código da
obra",max_length=15,primary_key=True)
nome_da_empreitada= models.CharField(max_length=100)
data_de_incio = models.DateField("data de início")
data_de_fim = models.DateField()
local = models.CharField(max_length=20)
morada = models.CharField(max_length=200)
codigo_postal = models.CharField("código postal",max_length=10)
adjudicacao= models.DecimalField
("ajudicação",max_digits=12,decimal_places=3)
trabalho_a_mais= models.DecimalField
(max_digits=8,decimal_places=2,default=0.00)
trabalho_a_menos= models.DecimalField
(max_digits=8,decimal_places=2,default=0.00)
data_de_entrada=models.DateField("data de inserção",default=date.today
())
#ForeignKey
cliente= models.ForeignKey(Cliente)
def __unicode__(self):
return '%s %s'%(self.cod_obra,self.nome_da_empreitada)
class Meta:
verbose_name= u'Obra'
forms.py
from django.forms import ModelForm
class ObraForm(ModelForm):
class meta:
model=Obra
views.py
def nova_obra(request):
if request.GET.has_key('ajax'):
n_obra= ObraForm(instance=Obra())
return render_to_response('nova_obra.html',locals())
return HttpResponse("ERROR ver o HttpResponse")
nova_obra.html :
<form method="post" action=".">
{{n_obra.as_p}}
</form>
<p><input id="save_obra"type="submit" value="Gravar Obra" /></p>
when a render the page i don't get any form... only the input
button .... can someone tell me why ? plz when i make this in the view
print n_obra.as_p i get this : <bound method ObraForm?.as_p of
<si_andrade.andrade_e_almeida.forms.ObraForm? object at 0x1020bd810>>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=.