Chrome Extension

Create or save object data in Django

//ONE LINE SYNTAX TO SAVE DATA 
person = Person.objects.create(first_name="John", last_name="Deo")


//YOU CAN ALSO USE BELOW CODE TO SAVE DATA
person = Person(first_name="John", last_name="Deo")
person.save()
Code faster with devsheet chrome extension and increase productivity as a programmer
search code from your favorite search engine instantly.
Install Now

Creating or saving object data in Django is very simple and it can be achieved using the provided code snippet. In the code snippet, we are using a 'Person' model which has fields named 'first_name' and 'last_name'. The above code will insert data into the table where 'John' will be inserted in the 'first_name' column and 'Deo' will be inserted into the 'last_name' column.

Was this helpful?
0 Comments
Open Code Manager We are hiring