New Record vs Updating Existing

15 views
Skip to first unread message

Frank Semaganga

unread,
Oct 14, 2016, 7:18:01 AM10/14/16
to Django users
Hello Team,

I am having challenge with my views/dB.

I am receiving http data and successfully save to the models but the problem is sometimes the data get into new dB row and sometimes is updating the existing dB row.

I want it to insert new row every time data is received.


What could have been a problem!! any experience!!

Jani Tiainen

unread,
Oct 14, 2016, 7:48:58 AM10/14/16
to django...@googlegroups.com

Hi,

When you save your data, you can say .save(force_insert).

Django usually makes decision based on primary key value, if it's None Django tries to insert, otherwise Django tries update and then insert if update fails.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1560dd92-5263-4985-84cc-e0fccc46bcd1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Jani Tiainen
Reply all
Reply to author
Forward
0 new messages