Django的Postgres新功能带来的乐趣

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。

postgres and django

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代表的基本模型:

1
1
2
2
3
3
4
4
5
5
6
6
7
7

Nothing specific to 1.8 above. Just a standard model to extend the base Django User, cause a playa still needs

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值