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()
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

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