我正在开发一个包含多个模型的应用程序。在我的 model.py 中的第二个模型中,它由 2-3 列组成。char 字段,但在我的模板中,当我使用此{{ form.billing_add }}时,它不会在浏览器中显示任何文本输入
我的 model.py 文件是
从 django.db 导入模型 从 django.contrib.auth.models 导入用户
class Customer(models.Model):
user =models.OneToOneField(User)
birthday =models.DateField()
website =models.CharField(max_length=50)
store =models.CharField(max_length=50)
welcomemail =models.CharField(max_length=50)
def __unicode__(self):
return self.user
class Customer_check_attributes(models.Model):
customer = models.ForeignKey(Customer)
billing_add =models.CharField(max_length=50)
shipping_add =models.CharField(max_length=50)
payment_method =models.CharField(max_length=50)
shipping_method =models.CharField(max_length=50)
reward_points =models.CharField(max_length=50)
我的 form.py 文件为
from django import forms
from django.contrib.auth.models import User
from django.forms import ModelForm
from customer_reg.models import Customer,Customer_check_attributes
class Registration_Form(ModelForm):
first_name = forms.CharField(label=(u'First Name'))
last_name = forms.CharField(label=(u'Last Name'))
username = forms.CharField(label=(u'User Name'))
email = forms.EmailField(label=(u'Email Address'))
password = forms.CharField(label=(u'Password'), widget=forms.PasswordInput(render_value=False))
class Meta:
model=Customer
exclude=('user',)