複数のモデルで構成されるアプリを開発しています。model.py の 2 番目のモデルでは、2 ~ 3 列で構成されています。charフィールドの
私の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',)