Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django insert data into database foreign key view.py

for i in range(1,10):
        obj = Count.objects.filter(userId=request.user.id, channelId=cid)
        if not obj:
            news_obj = News_Channel.objects.get(id=i)
            o = Count.objects.create(id=Count.objects.all().count() + 1,userId=request.user.id, channelId=news_obj,rate=0)
            o.save()
        i += 1
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #django #insert #data #database #foreign #key
ADD COMMENT
Topic
Name
4+3 =