У меня есть модель с кучей полей. Два поля имеют выбор. Они выглядят так:
SNAIL_MAIL_INVOICE_CHOICES = (
('Y', 'Yes'),
('N', 'No'),
)
SNAIL_MAIL_CHOICES = (
('Y', 'Yes'),
('N', 'No'),
)
snailMailOnly = models.CharField(max_length = 3, verbose_name = 'Snail Mail Only?', choices = SNAIL_MAIL_CHOICES, default='Y')
snailMailInvoice = models.CharField(max_length = 3, verbose_name = 'Snail Mail Invoice?', choices = SNAIL_MAIL_INVOICE_CHOICES, default='Y')
Когда я показываю эти два значения в шаблоне Django, я делаю это так:
<tr><td>Snail Mail Only?</td><td>{{contact.get_snailMailOnly_display}}</td></tr>
<tr><td>Snail Mail Invoice?</td><td>{{contact.get_snailMailInvoice_display}}</td></tr>
Проблема заключается в том, что, хотя в первом поле snailMailOnly
правильно отображаются варианты Yes
и No
, во втором поле snailMailInvoice
ТОЛЬКО отображаются Y
и N
.
Что я здесь не так делаю?
Спасибо
РЕДАКТИРОВАТЬ - добавить код модели контакта:
class System_Contact(models.Model):
IS_MAIN_CONTACT_CHOICES = (
('Y', 'Yes'),
('N', 'No'),
)
IS_SYSTEM_OWNER_CHOICES = (
('Y', 'Yes'),
('N', 'No'),
)
IS_RESSY_CONTACT_CHOICES = (
('Y', 'Yes'),
('N', 'No, this is a commercial contact'),
)
TRADE_CHOICES = (
('EL', 'Electrician'),
('LA', 'Landscaper'),
('PL', 'Plumber'),
('TR', 'Trencher'),
)
SNAIL_MAIL_CHOICES = (
('Y', 'Yes'),
('N', 'No'),
)
SNAIL_MAIL_INVOICE_CHOICES = (
('Y', 'Yes'),
('N', 'No'),
)
firstInitial = models.CharField(max_length = 10, verbose_name = 'First Initial', blank = True, null = True)
firstName = models.CharField(max_length = 60, verbose_name = 'First Name', blank = True, null = True)
lastName = models.CharField(max_length = 160, verbose_name = 'Last Name', blank = True, null = True)
phonetically = models.CharField(max_length = 100, verbose_name = 'Phonetically', blank = True, null = True)
companyName = models.CharField (max_length = 160, verbose_name = 'Company Name', blank = True, null = True) #Only used for Commercial Owners, no other field needed
homePhone = models.CharField(max_length = 60, verbose_name = 'Home Phone Number', blank = True, null = True)
officePhone = models.CharField(max_length = 60, verbose_name = 'Office Phone Number', blank = True, null = True)
cellPhone = models.CharField(max_length = 60, verbose_name = 'Cell Phone Number', blank = True, null = True)
faxNumber = models.CharField (max_length= 60, blank=True, null=True, verbose_name = 'Fax Number')
isMainContact = models.CharField (max_length = 3, verbose_name = 'Is the Main Contact?', choices = IS_MAIN_CONTACT_CHOICES, default='N')
isRessyContact = models.CharField (max_length = 3, verbose_name = 'Is this a Ressy Contact?', choices = IS_RESSY_CONTACT_CHOICES, default='Y')
isArchived = models.BooleanField(verbose_name = 'Archived?', default = False)
systemOwner = models.CharField (max_length = 3, verbose_name = 'Is a System Owner?', choices = IS_SYSTEM_OWNER_CHOICES, default='N') #this is just a flag to say they own a system
worksFor = models.CharField (max_length = 70, verbose_name = 'Works For', blank = True, null = True)
tradeType = models.ForeignKey(Contact_Trade, blank=True, null=True, verbose_name='Trade')
emailAddress = models.EmailField(verbose_name = 'Email Address', blank = True, null = True)
billingAddress = models.CharField(max_length = 150, verbose_name = 'Billing Address', blank=True, null=True )
billingCity = models.CharField(max_length = 90, verbose_name = 'Billing City', blank=True, null=True)
billingProvince = models.CharField(max_length = 30, verbose_name = 'Billing Province', blank=True, null=True)
billingPostalCode = models.CharField(max_length = 10, verbose_name = 'Billing Postal Code', blank=True, null=True)
snailMailOnly = models.CharField(max_length = 3, verbose_name = 'Snail Mail Only?', choices = SNAIL_MAIL_CHOICES, default='Y')
snailMailInvoice = models.CharField(max_length = 3, verbose_name = 'Snail Mail Invoice?', choices = SNAIL_MAIL_INVOICE_CHOICES, default='Y')