English 中文(简体)
• 如何界定Django模式领域,其邮政管理处职能为违约价值
原标题:How to define a Django model field with a PostgreSQL function as default value

是否有可能书写一个Django模型,其外地将邮资功能用作违约值? 此处仅举一例,用近似值(现值)作为缺省值:

% psql
mydb=# CREATE TABLE test (
    label text default   , 
    txid BIGINT DEFAULT txid_current()
);
CREATE TABLE
mydb=# d test
           Table "public.test"
 Column |  Type  |       Modifiers        
--------+--------+------------------------
 label  | text   | default   ::text
 txid   | bigint | default txid_current()

mydb=# INSERT INTO test (label) VALUES ( mylabel );
INSERT 0 1
mydb=# select * from test;
  label  |  txid  
---------+--------
 mylabel | 192050
(1 row)

该表的“Django”模式可能看起来像

class Test(models.Model):
    label = TextField( Label , default=  )
    txid = BigIntegerField( txid , default=???)

是否有办法规定数据库功能为违约值,还是我需要把邮政总局的违约作为继银之后的一个单独步骤?

最佳回答
问题回答

你们必须做这件事。 Django没有这种支持。 它是数据库独立性的一个特征。





相关问题
摘录数据

我如何将Excel板的数据输入我的Django应用? I m将PosgreSQL数据库作为数据库。

Postgres dump of only parts of tables for a dev snapshot

On production our database is a few hundred gigabytes in size. For development and testing, we need to create snapshots of this database that are functionally equivalent, but which are only 10 or 20 ...

How to join attributes in sql select statement?

I want to join few attributes in select statement as one for example select id, (name + + surname + + age) as info from users this doesn t work, how to do it? I m using postgreSQL.

What text encoding to use?

I need to setup my PostgreSQL DB s text encoding to handle non-American English characters that you d find showing up in languages such as German, Spanish, and French. What character encoding should ...

SQL LIKE condition to check for integer?

I am using a set of SQL LIKE conditions to go through the alphabet and list all items beginning with the appropriate letter, e.g. to get all books where the title starts with the letter "A": SELECT * ...

热门标签