我在嘗試重寫Django ModelForm字段時遇到了問題。重寫Django ModelForm字段時出錯
我的models.py是這樣的:
from django.db import models
class CadastroParticipantes(models.Model):
nome = models.CharField(max_length=50)
sobrenome = models.CharField(max_length=100)
cpf = models.CharField(max_length=14)
email = models.EmailField(max_length=100)
num_cartas_solicitadas = models.IntegerField(default=0)
def __unicode__(self):
return self.email
而且我forms.py是這樣的:
from django.forms import ModelForm
from models import *
class FormCadastroParticipante(ModelForm):
class Meta:
model = CadastroParticipantes
fields = ('nome', 'sobrenome', 'cpf', 'email')
exclude=('num_cartas_solicitadas')
widgets = { 'nome' : attrs={'title': 'Seu primeiro nome.'}}
當我運行的服務器,並嘗試訪問我得到這個消息:
**
SyntaxError at/
invalid syntax (forms.py, line 9)
**
有人可以幫助我嗎?
在此先感謝所有! (Y)
謝謝你!它非常完美! :) –