This commits lifts the restriction that the outermost atomic block must
be declared with savepoint=False. This restriction was overly cautious.
The logic that makes it safe not to create savepoints for inner blocks
also applies to the outermost block when autocommit is disabled and a
transaction is already active.
This makes it possible to use the ORM after set_autocommit(False).
Previously it didn't work because ORM write operations are protected
with atomic(savepoint=False).
The old names were downright confusing. Some seemed to mean the opposite
of what the class actually did.
The new names follow a consistent nomenclature:
(Forward|Reverse)(ManyToOne|OneToOne|ManyToMany)Descriptor.
I mentioned combinations that do not exist in the docstring in order to
help people who would search for them in the code base.
At 2800 lines it was the largest module in the django package. This
commit brings it down to a more manageable 1620 lines.
Very small changes were performed to uniformize import style.
Too much field exclusions in form's construct_instance() in _post_clean()
could lead to some unexpected missing ForeignKey values.
Fixes a regression from 45e049937. Refs #13776.
Moved data loss check when assigning to a reverse one-to-one relation on
an unsaved instance to Model.save(). This is exactly the same change as
e4b813c but for reverse relations.
urlparse() fails with an AttributeError ("'__proxy__' object has no
attribute 'decode'") if reverse_lazy is used to look up the URL
(this is exactly the same problem that caused ticket #18776). The
solution is to use force_str() on the path before handing it to
urlparse().
The change partly goes back to the old behavior for forwards migrations
which should reduce the amount of memory consumption (#24745). However,
by the way the current state computation is done (there is no
`state_backwards` on a migration class) this change cannot be applied to
backwards migrations. Hence rolling back migrations still requires the
precomputation and storage of the intermediate migration states.
This improvement also implies that Django does not handle mixed
migration plans anymore. Mixed plans consist of a list of migrations
where some are being applied and others are being unapplied.
Thanks Andrew Godwin, Josh Smeaton and Tim Graham for the review as well
as everybody involved on the ticket that kept me looking into the issue.
The ``item_enclosures`` hook returns a list of ``Enclosure`` objects which is
then used by the feed builder. If the feed is a RSS feed, an exception is
raised as RSS feeds don't allow multiple enclosures per feed item.
The ``item_enclosures`` hook defaults to an empty list or, if the
``item_enclosure_url`` hook is defined, to a list with a single ``Enclosure``
built from the ``item_enclosure_url``, ``item_enclosure_length``, and
``item_enclosure_mime_type`` hooks.