How to insert value by one post method in 2 table with Django

0 votes
Hey guys can you help me with django rest api.

Actually I have to insert value by one post method in 2 table, the id of first table should be save to other table, And the 2 nd table data is coming from excel.

So need to use library to read excel data and loop through it one by one and save all data in 2table while having one primary key of 1st table.
Nov 12, 2020 in Python by anonymous
• 8,880 points
71 views

1 answer to this question.

0 votes

try 
import-export 
 library of Django or if you are using the Postgres database then they have also explicit support to directly upload CSV in DB.

From there you can manage you can choose to depend upon your simplicity.

Once you take out the values from excel then you may directly do it by using for loop method.

answered Nov 12, 2020 by Gitika
• 65,870 points

Related Questions In Python

0 votes
1 answer

How to look up a dictionary value with a variable in Django template?

Hii @kartik, Write a custom template filter: from django.template.defaulttags ...READ MORE

answered Aug 3, 2020 in Python by Niroj
• 82,680 points
3,043 views
0 votes
1 answer

How to query as GROUP BY in django?

Hii, Django does not support free group by ...READ MORE

answered Apr 23, 2020 in Python by Niroj
• 82,680 points
1,472 views
0 votes
1 answer

How to output text from database with line breaks in a django template?

Hello @kartik, Use linebreaks or linebreaksbr filter: {{ text|linebreaks }} Or surround the text ...READ MORE

answered Jun 24, 2020 in Python by Niroj
• 82,680 points
2,328 views
0 votes
1 answer

How to disable a method in a ViewSet, django-rest-framework

Hello @kartik, You could keep using viewsets.ModelViewSet and define http_method_names on your ...READ MORE

answered Jun 25, 2020 in Python by Niroj
• 82,680 points
3,148 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,977 views
0 votes
0 answers
+4 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,810 points
1,512 views
0 votes
1 answer

I want to download a file from the website by web scraping. Can anyone explain how to do this in jupyter lab (python) with an example?

Hey, Web scraping is a technique to automatically ...READ MORE

answered Apr 7, 2020 in Python by Gitika
• 65,870 points
643 views
+1 vote
10 answers

How to fix this? ValueError: invalid literal for int() with base 10 error in Python

Just for the record: >>> int('55063.000000') Traceback (most recent ...READ MORE

answered Aug 17, 2020 in Python by pakainfo
• 200 points
251,878 views