RT。尝试通过django的ORM创建主键,但是失败。在postgresql中创建一个表如下:
Column | Type | Modifiers
----------
-----------------
+--------
public_name | character varying(30) | not null
ctime | date | not null
Indexes:
"news_publication_pkey" PRIMARY KEY, btree (ctime, public_name)
使用python manage.py inspectdb得到的却是:
class NewsPublication(models.Model):
public_name = models.CharField(max_length=30)
ctime = models.DateField()
class Meta:
db_table = u'news_publication'
是否意味django的orm无法创建复合字段的主键呢?
django 1.5 已经实现了这个
https://docs.djangoproject.com/en/1.5...
不会呀,索引完全是由数据库软件管理的,虽然在Django Model对象中没有体现,但在数据库查询时会有相应的提速。