Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert a row of data to a table using Django's ORM

How do I insert data in Django to a SQL table using the Django ORM?

like image 1000
John Doe Avatar asked Feb 28 '13 06:02

John Doe


People also ask

What is Django's ORM?

The Django web framework includes a default object-relational mapping layer (ORM) that can be used to interact with application data from various relational databases such as SQLite, PostgreSQL and MySQL. The Django ORM is an implementation of the object-relational mapping (ORM) concept.

Which operators can be used to access the fields in the object by Django ORM?

You use a period (.) to access the fields in the Django ORM object.

What are the components of Django ORM?

MVC Pattern in Django Structure. For every website on the Internet, there are 3 main components or code partitions; Input Logic, Business Logic, and UI Logic.


1 Answers

If you need to insert a row of data, see the "Saving objects" documentation for the save method on the model.

FYI, you can perform a bulk insert. See the bulk_create method's documentation.

like image 114
alecxe Avatar answered Nov 05 '22 15:11

alecxe