Naoko
I ma facing the problem of updating primary key automatically in django
with postgresql database
Could you please suggest what need to be done.
Do we need to create a sequence for the table to achieve this.
Hoping for your reply
On Sunday, May 29, 2011 at 8:32:45 PM UTC+5:30, Nao
I was missing this from schema:
ALTER SEQUENCE tablename_colname_seq OWNED BY tablename.colname;
Now everything is happy. Thank you!
On 5/28/11 8:32 AM, "Naoko Reeves" wrote:
> Malcolm, Thank you for your advice!
> I changed my model as follows:
> poll_key = models.AutoField(primary_key=Tr
Malcolm, Thank you for your advice!
I changed my model as follows:
poll_key = models.AutoField(primary_key=True, db_column='poll_key')
However, the result remain the same as shown below. If you could point me
out to right direction again, I would appreciate. Thank you very much for
your time.
You need to tell django what the db column name for your pollkey field is. Look
at the dbname field option in the docs.
Sent from my iPhone, please excuse any typos
On 28 May 2011, at 05:13, Naoko Reeves wrote:
> I see if column is set to AutoField then Django won't send INSERT poll_key
> as
I see if column is set to AutoField then Django won't send INSERT poll_key
as null.
Now my problem is that it doesn't return newly assigned primary key value
for me if primary key name is _key instead of _id
It looks as if sequence name is not understood correctly.
Could you tell me if
1) I need to
Casey,
Thank you for your help! As Casey suggested by changing the column
definition of model to:
poll_key = models.AutoField(primary_key=True)
Now create INSERT statement as follows:
INSERT INTO "poll" ("poll_question", "poll_pub_date") VALUES ('Question!',
'2011-05-27 00:00:00')
With PostgreS
Doesn't autofield with primary_key=True handle this for you (instead of
making it an IntegerField):
https://docs.djangoproject.com/en/1.3/ref/models/fields/#autofield
Hope this helps!
Casey
On 05/27/2011 07:22 PM, Naoko Reeves wrote:
Hi, I have a Django newbie question.
My goal is to auto inc
Hi, I have a Django newbie question.
My goal is to auto increment primary key with non Django standard column
name.
We are converting from existing database and primary key schema is
"tablename_key" and not "id".
I googled it and end up reaching to this ticket:
https://code.djangoproject.com/ticket
8 matches
Mail list logo