This blog post covers how to use the new PostgreSQL-specific ModelFields introduced in Django 1.8 – the ArrayField, HStoreField, and Range Fields.
这篇博客文章介绍了如何使用Django 1.8中引入的新的特定于PostgreSQLModelFields- ArrayField,HStoreField和Range Fields。
This post is dedicated to the awesome backers of this Kickstarter campaign put together by Marc Tamlyn, the true playa that made it happen.
这篇文章是献给由马克·塔林 ( Marc Tamlyn)共同发起的这次Kickstarter活动的优秀支持者的,这是实现这一目标的真正方法。
Playaz Club? (Playaz Club?)
Since I’m a huge geek and have no chance of ever getting into a real Playaz Club (and because back in the day 4 Tay was the bomb), I decided to build my own virtual online Playaz Club. What is that exactly? A private, invite-only social network targeted at a small group of like-minded individuals.
由于我是一个庞大的极客,并且没有进入真正的Playaz俱乐部的机会(并且因为在第四天Tay是炸弹),所以我决定建立自己的虚拟在线Playaz俱乐部。 那到底是什么 面向一群志趣相投的个人的私人,仅限邀请的社交网络。
For this post, we are going to focus on the user model and explore how Django’s new PostgreSQL features support the modeling. The new features we are referring to are PostgreSQL-only, so don’t bother trying this unless you have your database ENGINE
equal to django.db.backends.postgresql_psycopg2
. You will need version >= 2.5 of psycopg2
. Aight playa, let’s do this.
在本文中,我们将重点关注用户模型,并探索Django的新PostgreSQL功能如何支持建模。 我们所指的新功能仅适用于PostgreSQL,因此,除非您的数据库ENGINE
等于django.db.backends.postgresql_psycopg2
否则不要尝试这样做。 您将需要psycopg2
版本> = 2.5。 好的,我们来做吧。
Holla if you with me! 🙂
霍拉,如果你和我在一起! 🙂
建模Playa的销售代表 (Modeling a Playa’s Rep)
Every playa got a rep, and they want the whole world to know about their rep. So let’s create a user profile (aka a “rep”) that allows for each of our playaz to express their individuality.
每个Playa都有一个代表,他们希望全世界都知道他们的代表。 因此,让我们创建一个用户个人资料(又称“代表”),以允许我们的每个playaz表达自己的个性。
Here’s the basic model for a playaz rep:
这是playaz代表的基本模型:
|
Nothing specific to 1.8 above. Just a standard model to extend the base Django User, cause a playa still needs