1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Moved choices inside of test models per coding style.

This commit is contained in:
Manan 2018-12-10 19:58:49 +05:30 committed by Tim Graham
parent f0082b9a77
commit 3a4558b84f
4 changed files with 27 additions and 34 deletions

View File

@ -632,19 +632,16 @@ class Reservation(models.Model):
price = models.IntegerField() price = models.IntegerField()
DRIVER_CHOICES = (
('bill', 'Bill G'),
('steve', 'Steve J'),
)
RESTAURANT_CHOICES = (
('indian', 'A Taste of India'),
('thai', 'Thai Pography'),
('pizza', 'Pizza Mama'),
)
class FoodDelivery(models.Model): class FoodDelivery(models.Model):
DRIVER_CHOICES = (
('bill', 'Bill G'),
('steve', 'Steve J'),
)
RESTAURANT_CHOICES = (
('indian', 'A Taste of India'),
('thai', 'Thai Pography'),
('pizza', 'Pizza Mama'),
)
reference = models.CharField(max_length=100) reference = models.CharField(max_length=100)
driver = models.CharField(max_length=100, choices=DRIVER_CHOICES, blank=True) driver = models.CharField(max_length=100, choices=DRIVER_CHOICES, blank=True)
restaurant = models.CharField(max_length=100, choices=RESTAURANT_CHOICES, blank=True) restaurant = models.CharField(max_length=100, choices=RESTAURANT_CHOICES, blank=True)

View File

@ -11,13 +11,12 @@ field. This method returns the "human-readable" value of the field.
from django.db import models from django.db import models
GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
)
class Person(models.Model): class Person(models.Model):
GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
)
name = models.CharField(max_length=20) name = models.CharField(max_length=20)
gender = models.CharField(max_length=1, choices=GENDER_CHOICES) gender = models.CharField(max_length=1, choices=GENDER_CHOICES)

View File

@ -11,18 +11,6 @@ from django.db import models
temp_storage_dir = tempfile.mkdtemp() temp_storage_dir = tempfile.mkdtemp()
temp_storage = FileSystemStorage(temp_storage_dir) temp_storage = FileSystemStorage(temp_storage_dir)
ARTICLE_STATUS = (
(1, 'Draft'),
(2, 'Pending'),
(3, 'Live'),
)
ARTICLE_STATUS_CHAR = (
('d', 'Draft'),
('p', 'Pending'),
('l', 'Live'),
)
class Person(models.Model): class Person(models.Model):
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
@ -51,6 +39,11 @@ class Writer(models.Model):
class Article(models.Model): class Article(models.Model):
ARTICLE_STATUS = (
(1, 'Draft'),
(2, 'Pending'),
(3, 'Live'),
)
headline = models.CharField(max_length=50) headline = models.CharField(max_length=50)
slug = models.SlugField() slug = models.SlugField()
pub_date = models.DateField() pub_date = models.DateField()
@ -239,6 +232,11 @@ class Triple(models.Model):
class ArticleStatus(models.Model): class ArticleStatus(models.Model):
ARTICLE_STATUS_CHAR = (
('d', 'Draft'),
('p', 'Pending'),
('l', 'Live'),
)
status = models.CharField(max_length=2, choices=ARTICLE_STATUS_CHAR, blank=True, null=True) status = models.CharField(max_length=2, choices=ARTICLE_STATUS_CHAR, blank=True, null=True)

View File

@ -1,17 +1,16 @@
from django.db import models from django.db import models
GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
)
class Account(models.Model): class Account(models.Model):
num = models.IntegerField() num = models.IntegerField()
class Person(models.Model): class Person(models.Model):
GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
)
name = models.CharField(max_length=20) name = models.CharField(max_length=20)
gender = models.CharField(max_length=1, choices=GENDER_CHOICES) gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
pid = models.IntegerField(null=True, default=None) pid = models.IntegerField(null=True, default=None)