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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#-*- coding: utf-8 -*-
from django.db import models
from django.contrib import admin
class Location(models.Model):
latitude = models.FloatField(u"经度")
longitude = models.FloatField(u"纬度")
city = models.CharField(u"城市", max_length=20, null=True, blank=True)
nation = models.CharField(u"国家", max_length=20, null=True, blank=True)
class Meta:
verbose_name_plural = u"地理位置"
def __unicode__(self):
return u"< Location : %s >" % self.id
class Hospital(models.Model):
name = models.CharField(u"名称", max_length=100)
city = models.ForeignKey("City", related_name="hospitals", verbose_name = u"城市", null=True, blank=True)
unit = models.ForeignKey("indicator.Unit", related_name="hospitals", verbose_name = u"单位", null=True, blank=True)
class Meta:
verbose_name_plural = u"医院"
def __unicode__(self):
return "< Hospital: %s >" % self.name
class City(models.Model):
name = models.CharField(u"名称", max_length=100)
nation = models.ForeignKey("Nation", related_name="cities", verbose_name = "国家", null=True, blank=True)
class Meta:
verbose_name_plural = u"城市"
def __unicode__(self):
return "< City: %s >" % self.name
class Nation(models.Model):
name = models.CharField(u"名称", max_length=100)
img = models.ImageField(u"国旗图标", upload_to="uploads/flags/", null=True, blank=True)
class Meta:
verbose_name_plural = u"国家"
def __unicode__(self):
return "< Nation: %s >" % self.name
admin.site.register([
Location,
Hospital,
City,
Nation,
])
|