Django is a web framework that includes an Object-Relational Mapping (ORM) system that enables developers to interact with databases using Python objects instead of writing SQL queries.
Here are some commonly used database functions in Django:
- create(): The create() method creates a new object in the database and saves it.
- save(): The save() method updates an existing object or creates a new one in the database.
- filter(): The filter() method returns a QuerySet containing objects that match the specified criteria.
- get(): The get() method returns a single object that matches the specified criteria.
- update(): The update() method updates one or more objects that match the specified criteria.
- delete(): The delete() method deletes one or more objects that match the specified criteria.
- annotate(): The annotate() method allows you to add extra fields to a QuerySet.
- count(): The count() method returns the number of objects that match the specified criteria.
- exists(): The exists() method returns True if any objects match the specified criteria, and False otherwise.
- distinct(): The distinct() method returns a QuerySet containing unique objects.
These functions can be used with various database backends supported by Django, including PostgreSQL, MySQL, SQLite, and Oracle.