codeing utf-8 from django db import models from django contrib auth mo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- codeing: utf-8 -*-
from django.db import models
from django.contrib.auth.models import User
GENDER_CHOICES = (
('M', 'Мужской'),
('F', 'Женский'),
)
DRUGS_CHOICES = (
('N', 'Никогда не употреблял'),
('Y', 'Употребляю сейчас'),
('A', 'Употреблял раньше'),
)
EDUCATION_CHOICES = (
('0', 'Среднее'),
('1', 'Среднее специальное'),
('2', 'Высшее'),
)
User.add_to_class('gender', models.CharField(max_length=1, choices=GENDER_CHOICES))
User.add_to_class('drugs', models.CharField(max_length=1, choices=DRUGS_CHOICES))
User.add_to_class('birthday', models.DateField())
User.add_to_class('country', models.IntegerField())
User.add_to_class('city', models.IntegerField())
User.add_to_class('education', models.CharField(max_length=1, choices=EDUCATION_CHOICES))
User.add_to_class('occupation', models.TextField())
User.add_to_class('how_did_you_hear_about_us', models.TextField())
User.add_to_class('how_you_can_help', models.TextField())
User.add_to_class('about_me', models.TextField())
User._meta.admin.fields += (
('Additional', {'fields': ('gender','drugs','birthday','country','city','education','occupation','how_did_you_hear_about_us','how_you_can_help','about_me',)}),
)
User._meta.admin.list_display = User._meta.admin.list_display + ('gender','drugs','birthday','country','city','education','occupation','how_did_you_hear_about_us','how_you_can_help','about_me', )
class Country(models.Model):
country = models.CharField(max_length=100)
class City(models.Model):
country = models.ForeignKey(Country)
city = models.CharField(max_length=100)
# Create your models here.