当我尝试覆盖 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)