db.models.ManyToManyField.symmetrical

ManyToManyField.symmetrical Only used in the definition of ManyToManyFields on self. Consider the following model: from django.db import models class Person(models.Model): friends = models.ManyToManyField("self") When Django processes this model, it identifies that it has a ManyToManyField on itself, and as a result, it doesn’t add a person_set attribute to the Person class. Instead, the ManyToManyField is assumed to be symmetrical – that is, if I am your friend, then you are my friend

db.models.ManyToManyField.swappable

ManyToManyField.swappable Controls the migration framework’s reaction if this ManyToManyField is pointing at a swappable model. If it is True - the default - then if the ManyToManyField is pointing at a model which matches the current value of settings.AUTH_USER_MODEL (or another swappable model setting) the relationship will be stored in the migration using a reference to the setting, not to the model directly. You only want to override this to be False if you are sure your model should alw

db.models.ManyToManyField.related_query_name

ManyToManyField.related_query_name Same as ForeignKey.related_query_name.

db.models.ManyToManyField.related_name

ManyToManyField.related_name Same as ForeignKey.related_name.

db.models.ManyToManyField.limit_choices_to

ManyToManyField.limit_choices_to Same as ForeignKey.limit_choices_to. limit_choices_to has no effect when used on a ManyToManyField with a custom intermediate table specified using the through parameter.

db.models.ManyToManyField.db_table

ManyToManyField.db_table The name of the table to create for storing the many-to-many data. If this is not provided, Django will assume a default name based upon the names of: the table for the model defining the relationship and the name of the field itself.

db.models.ManyToManyField.db_constraint

ManyToManyField.db_constraint Controls whether or not constraints should be created in the database for the foreign keys in the intermediary table. The default is True, and that’s almost certainly what you want; setting this to False can be very bad for data integrity. That said, here are some scenarios where you might want to do this: You have legacy data that is not valid. You’re sharding your database. It is an error to pass both db_constraint and through.

db.models.ManyToManyField

class ManyToManyField(othermodel, **options) [source] A many-to-many relationship. Requires a positional argument: the class to which the model is related, which works exactly the same as it does for ForeignKey, including recursive and lazy relationships. Related objects can be added, removed, or created with the field’s RelatedManager.

db.models.Manager.raw()

Manager.raw(raw_query, params=None, translations=None) This method takes a raw SQL query, executes it, and returns a django.db.models.query.RawQuerySet instance. This RawQuerySet instance can be iterated over just like a normal QuerySet to provide object instances. This is best illustrated with an example. Suppose you have the following model: class Person(models.Model): first_name = models.CharField(...) last_name = models.CharField(...) birth_date = models.DateField(...) You c

db.models.Manager

class Manager [source] A Manager is the interface through which database query operations are provided to Django models. At least one Manager exists for every model in a Django application. The way Manager classes work is documented in Making queries; this document specifically touches on model options that customize Manager behavior.