Commit Graph

10307 Commits

Author SHA1 Message Date
Aymeric Augustin 16aae35ca8 Improved set_available_apps() in several ways.
- Tested consistency the current app_configs instead of INSTALLED_APPS.
- Considered applications added with _with_app as available.
- Added docstrings.
2013-12-22 11:39:18 +01:00
Aymeric Augustin 2239081ff1 Expurged INSTALLED_APPS from code and tests.
Except the app cache code and a few specific tests, of course.
2013-12-22 11:39:18 +01:00
Aymeric Augustin 9cdf1f6d54 Stop testing for inclusion in INSTALLED_APPS.
Removed some exception masking in the comments app that was harmful and
couldn't be preserved easily.
2013-12-22 11:39:18 +01:00
Aymeric Augustin 70c9654d45 Renamed registered_model to has_model.
This avoids possible confusion with register_model.

Thanks Marc Tamlyn for the suggestion.
2013-12-22 11:39:18 +01:00
Aymeric Augustin 65cd74be8e Stopped iterating on INSTALLED_APPS.
Used the app cache's get_app_configs() method instead.
2013-12-22 11:39:18 +01:00
Aymeric Augustin d4733b6df0 Not all Python modules have a __path__. 2013-12-22 11:39:18 +01:00
Aymeric Augustin 4582993302 Populated models only when necessary in get_app_config[s].
Took this opportunity to change get_app[s] to only consider applications
containing a model module as that seems slightly more backwards compatible.

Since callers that care about models pass only_with_models_module=True,
this has very few consequences. Only AppCommand needed a change.
2013-12-22 11:39:18 +01:00
Aymeric Augustin f25fa9d859 Deprecated load_app().
Adjusted several tests that used it to add apps to the app cache and
then attempted to remove them by manipulating attributes directly.

Also renamed invalid_models to invalid_models_tests to avoid clashing
application labels between the outer and the inner invalid_models
applications.
2013-12-22 11:39:17 +01:00
Aymeric Augustin 439b364e1e Added an _-prefix to pending lookups because it's transient. 2013-12-22 11:39:17 +01:00
Aymeric Augustin 86804ab063 Terminated AppCache._populate() with extreme prejudice.
It was called _populate() before I renamed it to populate(). Since it
has been superseded by populate_models() there's no reason to keep it.

Removed the can_postpone argument of load_app() as it was only used by
populate(). It's a private API and there's no replacement. Simplified
load_app() accordingly. Then new version behaves exactly like the old
one even though it's much shorter.
2013-12-22 11:39:17 +01:00
Aymeric Augustin 2b56d69102 Implemented two-stage app-cache population.
First stage imports app modules. It doesn't catch import errors. This
matches the previous behavior and keeps the code simple.

Second stage import models modules. It catches import errors and retries
them after walking through the entire list once. This matches the
previous behavior and seems useful.

populate_models() is intended to be equivalent to populate(). It isn't
wired yet. That is coming in the next commit.
2013-12-22 11:39:17 +01:00
Aymeric Augustin 9b3389b726 Removed the app_config.installed flag.
Since applications that aren't installed no longer have an application
configuration, it is now always True in practice.

Provided an abstraction to temporarily add or remove applications as
several tests messed with app_config.installed to achieve this effect.
For now this API is _-prefixed because it looks dangerous.
2013-12-22 11:39:17 +01:00
Aymeric Augustin 972babc3b4 Removed the only_installed argument of get_app_config[s].
It wasn't used anywhere and couldn't be implemented any more since
non-installed apps no longer have a configuration.
2013-12-22 11:39:17 +01:00
Aymeric Augustin 742ed9878e Refactored registration of models.
Got rid of AppConfig._stub. As a side effect, app_cache.app_configs now
only contains entries for applications that are in INSTALLED_APPS, which
is a good thing and will allow dramatic simplifications (which I will
perform in the next commit). That required adjusting all methods that
iterate on app_configs without checking the "installed" flag, hence the
large changes in get_model[s].

Introduced AppCache.all_models to store models:
- while the app cache is being populated and a suitable app config
  object to register models isn't available yet;
- for applications that aren't in INSTALLED_APPS since they don't have
  an app config any longer.

Replaced get_model(seed_cache=False) by registered_model() which can be
kept simple and safe to call at any time, and removed the seed_cache
argument to get_model[s]. There's no replacement for that private API.

Allowed non-master app caches to go through populate() as it is now
safe to do so. They were introduced in 1.7 so backwards compatibility
isn't a concern as long as the migrations framework keeps working.
2013-12-22 11:39:17 +01:00
Aymeric Augustin 73c9e65b75 Added a context manager to hold the import lock. 2013-12-22 11:39:17 +01:00
Alexey Voronov 7f2485b4d1 Fixed #21643 -- repeated execution of qs with F() + timedelta
Thanks Tim Graham for review.
2013-12-22 00:03:17 +02:00
Aymeric Augustin b80a8357d6 Revert "Changed admin/templates/admin/index.html to make <caption> translatable"
This reverts commit a25fe3b65e.

It didn't do anything. It merely added to every PO file:

msgid "%(name)s"
msgstr "%(name)s"

Thanks Ramiro Morales for the report at:
https://groups.google.com/d/msg/Django-I18N/vc2vQzv80UQ/EuaW38V7X7sJ

Conflicts:
	django/contrib/admin/templates/admin/index.html
2013-12-20 15:19:03 +01:00
Aymeric Augustin eabc3b6c8d Set stacklevel for the override_settings warning.
Refs #19031.
2013-12-20 11:09:06 +01:00
Alex Gaynor 1b9cbef198 Small flake8 fixes -- number of blank lines between top level definitions 2013-12-19 20:43:34 -08:00
Alex Hill 832ab0dbaa Fixed #21639 -- Implemented RenderContext.__getitem__
It's now consistent with RenderContext.get.
2013-12-20 01:02:50 +01:00
Ondrej Sika 4ac5def4a2 Simplied some code in django.conf.__init__. 2013-12-18 18:23:25 -05:00
Bouke Haarsma a39d672ec7 Fixed #21386 -- Removed admindocs dependence on sites framework
* Removed ADMIN_FOR setting and warn warning
* Group view functions by namespace instead of site
* Added a test verifying namespaces are listed

Thanks to Claude Paroz for reviewing and ideas for improvement.
2013-12-18 19:44:04 +01:00
Baptiste Mispelon f1b3ab9c21 Fixed #11629 -- Deprecated callable arguments to queryset methods.
Callable arguments were an untested and undocumented feature.
2013-12-18 18:40:00 +01:00
Denis Moskalets d4e578d0f6 Fixed #21552 -- Allowed the use of None for the iexact lookup.
Thanks Anubhav Joshi for the documentation.
2013-12-18 09:34:53 -05:00
Loic Bistuer 2fd7fc134c Refs #17413 -- Added isinstance backward compatibility on ErrorList. 2013-12-18 08:59:53 -05:00
Aymeric Augustin 9bfdad5472 Style cleanup forgotten in second previous commit. 2013-12-17 22:24:25 +01:00
Aymeric Augustin 7eea9bf303 Normalized Model._meta.installed.
Used the information from the app cache instead of creating a duplicate
based on INSTALLED_APPS.

Model._meta.installed is no longer writable. It was a rather sketchy way
to alter private internals anyway.
2013-12-17 21:55:16 +01:00
Aymeric Augustin 0242c56fd8 Deborgified the app cache.
Improved Andrew's hack to create temporary app caches to handle
migrations. Now the main app cache has a "master" flag set to True
(which is a non-default keyword argument, thus unlikely to be used by
mistake). Other app cache instances have "master" set to False.

The only sanctioned way to access the app cache is by importing
django.core.apps.app_cache.

If you were instanciating an app cache and relying on the Borg pattern,
you'll have to refactor your code.
2013-12-17 21:53:18 +01:00
Aymeric Augustin 6e895f9e06 Removed superfluous models.py files.
Added comments in the three empty models.py files that are still needed.

Adjusted the test runner to add applications corresponding to test
labels to INSTALLED_APPS even when they don't have a models module.
2013-12-17 11:16:48 +01:00
Aymeric Augustin 4a56a93cc4 Moved the new app cache inside core. 2013-12-17 10:17:46 +01:00
Aymeric Augustin b3d5efe23f Restored deprecated aliases for functions in django.db.models.
Thanks Marc Tamlyn for the suggestion.
2013-12-17 10:17:46 +01:00
Aymeric Augustin f831da2fed Inlined trivial method that was used only once. 2013-12-17 10:17:46 +01:00
Aymeric Augustin b3e182faba Fixed incorrect decrementation of nesting_level.
Thanks Florian for catching this mistake.
2013-12-17 10:17:45 +01:00
Aymeric Augustin 30bdad1c47 Refactored old test runner to handle apps without a models module. 2013-12-17 10:17:45 +01:00
Aymeric Augustin 5ba743e262 Made it possible to create apps without a models module.
This commit reverts f44c4a5d0f and 39bbd165.

django.test.simple will be updated in a separate commit as it requires
invasive changes.
2013-12-17 10:17:45 +01:00
Aymeric Augustin 69039becde Deprecated get_app(). 2013-12-17 10:17:45 +01:00
Aymeric Augustin 2732edc5f2 Deprecated get_apps(). 2013-12-17 10:17:45 +01:00
Aymeric Augustin d44de9b933 Removed the _-prefix for populate().
Several parts of Django call get_apps() with a comment along this lines
of "this has the side effect of calling _populate()". I fail to see how
this is better than just calling populate()!
2013-12-17 10:17:45 +01:00
Aymeric Augustin ebda5800ae Simplified register_models.
Since it's never called with more than one model at a time the current
signature is needlessly complicated.
2013-12-17 10:17:45 +01:00
Aymeric Augustin e85932b54e Simplified handling of available_apps slightly.
It feels more natural for self.available_apps to contain app names (like
INSTALLED_APPS) than app labels, and this is easy to implement now.
2013-12-17 10:17:45 +01:00
Aymeric Augustin 259cd3cd41 Deprecated get_app_package, get_app_path and get_app_paths. 2013-12-17 10:17:45 +01:00
Aymeric Augustin da36d03fe6 Added get_app_configs() to iterate on app_config instances.
Refactored get_apps() to rely on that method.

This commit is fully backwards-compatible.
2013-12-17 10:17:44 +01:00
Aymeric Augustin a4cb140004 Added get_app_config() to look up app configs by label.
Refactored get_app() to rely on that method.

get_app() starts by calling _populate(), which goes through
INSTALLED_APPS and, for each app, imports the app module and attempts to
import the models module. At this point, no further imports are
necessary to return the models module for a  given app. Therefore, the
implementation of get_app() can be simplified and the safeguards for
race conditions can be removed.

Besides, the emptyOK parameter isn't used anywhere in Django. It was
introduced in d6c95e93 but not actually used nor documented, and it has
just been carried around since then. Since it's an obscure private API,
it's acceptable to stop supporting it without a deprecation path. This
branch aims at providing first-class support for applications without a
models module eventually.

For backwards-compatibility, get_app() still raises ImproperlyConfigured
when an app isn't found, even though LookupError is technically more
correct. I haven't gone as far as to preserve the exact error messages.
I've adjusted a few tests instead.
2013-12-17 10:17:44 +01:00
Aymeric Augustin c5eac3a2f6 Fleshed out AppConfig objects.
Marginally improved creation of AppConfig stubs for non-installed apps.
2013-12-17 10:17:44 +01:00
Aymeric Augustin b55282b98b Moved list of models inside AppConfig instances.
This commit is a refactoring with no change of functionality, according
to the following invariants:

- An app_label that was in app_configs and app_models stays in
  app_config and has its 'installed' attribute set to True.

- An app_label that was in app_models but not in app_configs is added to
  app_configs and has its 'installed' attribute set to True.

As a consequence, all the code that iterated on app_configs is modified
to check for the 'installed' attribute. Code that iterated on app_models
is rewritten in terms of app_configs.

Many tests that stored and restored the state of the app cache were
updated.

In the long term, we should reconsider the usefulness of allowing
importing models from non-installed applications. This doesn't sound
particularly useful, can be a trap in some circumstances, and causes
significant complexity in sensitive areas of Django.
2013-12-17 10:17:44 +01:00
Aymeric Augustin 2c9e84af4a Removed unused attribute app_errors of the app cache.
get_app_errors() always returned an empty dictionary; this behavior is
preserved in django.db.models.loading until that module is deprecated.
2013-12-17 10:17:44 +01:00
Aymeric Augustin 0e9d3472d7 Stored AppConfig objects instead of models modules in the app cache.
This is a step towards allowing applications without a models module.
2013-12-17 10:17:44 +01:00
Aymeric Augustin 8662654d6d Removed module-level functions for the app cache.
Since the original ones in django.db.models.loading were kept only for
backwards compatibility, there's no need to recreate them. However, many
internals of Django still relied on them.

They were also imported in django.db.models. They never appear in the
documentation, except a quick mention of get_models and get_app in the
1.2 release notes to document an edge case in GIS. I don't think that
makes them a public API.

This commit doesn't change the overall amount of global state but
clarifies that it's tied to the app_cache object instead of hiding it
behind half a dozen functions.
2013-12-17 10:17:44 +01:00
Aymeric Augustin 334551339d Removed ModelDict.
Its only difference with OrderedDict is that it didn't deepcopy its
keys. However it wasn't used anywhere with models modules as keys, only
as values. So this commit doesn't result in any change in functionality.
2013-12-17 10:17:44 +01:00
Aymeric Augustin 9217b89da3 Removed BaseAppCache.app_store.
It was only storing redundant information. This is part of the effort to
allow applications without a models module.
2013-12-17 10:17:44 +01:00
Aymeric Augustin 860c2c8bc5 Moved django.db.models.loading to django.apps.cache.
This commit doesn't contain any code changes; it's purely a refactoring.
2013-12-17 10:17:43 +01:00
Artur Barseghyan fe1389e911 Removed duplicated `TimeField` in __all__. 2013-12-16 17:52:37 -05:00
Loic Bistuer 3ce9829b61 Fixed #17413 -- Serialization of form errors along with all metadata. 2013-12-16 16:33:28 -05:00
Baptiste Mispelon e2f142030b Fixed #21564 -- Use local request object when possible in generic views.
Thanks to trac user adepue for the report and original patch.
2013-12-16 16:58:08 +01:00
Baptiste Mispelon 3eb58f0dd1 Removed unnecessary function-level import. 2013-12-16 15:30:51 +01:00
Vajrasky Kok db41778e8c Removed unnecessary call to force_text in utils.html.clean_html.
Refs #21574
2013-12-16 15:22:54 +01:00
Peter Harley cdd6617da6 Fixed #21619 -- Made SingleObjectMixin.get_object catch a more precise exception.
Thanks to Keryn Knight for the report.
2013-12-15 21:49:52 +01:00
Aymeric Augustin 3beffea4b0 Fixed #21621 -- Removed kqueue autoreloader. 2013-12-15 14:43:52 +01:00
Claude Paroz 164a3a388c Revert "Allowed running GIS form tests that don't require spatial database"
This reverts commit 07fe0bf3f4.
This was not working properly on system without geos library
installed.
2013-12-14 21:03:09 +01:00
Bartolomé Sánchez 8f994f1bcc Fixed #21250 -- Made HTTP auth user header configurable in tests
Currently, if the authentication mechanism uses a custom HTTP header
and not REMOTE_USER, it is not easy to test. This commit modifies
remote user tests in order to make them more generic.
2013-12-14 13:02:56 -05:00
Loic Bistuer 6685713869 Fixed E127 pep8 warnings. 2013-12-14 11:59:15 -05:00
Jakub Gocławski 07fe0bf3f4 Allowed running GIS form tests that don't require spatial database 2013-12-14 13:57:58 +01:00
Jakub Gocławski 2ddf1fc50f Fixed #21606 -- Fixed default_lat and default_lon override in OSMWidget 2013-12-14 13:53:37 +01:00
Baptiste Mispelon 2c837233f5 Fixed #21574 -- Handle bytes consistently in utils.text.normalize_newlines.
All input is now coerced to text before being normalized.
This changes nothing under Python 2 but it allows bytes
to be passed to the function without a TypeError under Python3
(bytes are assumed to be utf-8 encoded text).

Thanks to trac user vajrasky for the report.
2013-12-12 16:09:12 +01:00
Baptiste Mispelon b9c7234e2a Fixed PEP257 violations (single-quoted docstrings) in utils.text. 2013-12-12 16:08:59 +01:00
Ludwik Trammer 9922ed46e2 Fixed #21473 -- Limited language preservation to logout
Current language is no longer saved to session by LocaleMiddleware
on  every response (the behavior introduced in #14825).
Instead language stored in session is reintroduced into new session
after logout.

Forward port of c558a43fd6 to master.
2013-12-12 10:24:43 +01:00
Aymeric Augustin 9c5f59f489 Brought comments in sync with the code in BaseAppCache. 2013-12-11 23:16:06 +01:00
Dominic Rodger 5cd6477fd6 Fixed #21462 -- Made `assertNumQueries` print executed queries on failure. 2013-12-11 15:24:17 -05:00
Simon Charette 75924cfa6d Fixed #21563 -- Single related object descriptors should work with `hasattr`.
Thanks to Aymeric Augustin for the review and Trac alias monkut for the report.
2013-12-11 12:49:28 -05:00
Claude Paroz c7c647419c Fixed #21510 -- Readded search reset link in changelist search bar
Thanks moritz.pfeiffer at alp-phone.ch for the report and
Tim Graham for the initial patch.
2013-12-11 15:30:20 +01:00
Andrew Godwin 5db028affb Fix altering of SERIAL columns and InnoDB being picky about FK changes 2013-12-11 14:19:05 +00:00
Andrew Godwin cee4fe7307 Better default name for migrations we can't give nice names to 2013-12-11 13:23:07 +00:00
Andrew Godwin 248fdb1110 Change FKs when what they point to changes 2013-12-11 13:16:29 +00:00
Andrew Godwin f3582a0594 Fix sqlmigrate's output for parameters 2013-12-11 13:12:23 +00:00
Aymeric Augustin 072e25eee7 Moved imports to the top of the defaultfilters module. 2013-12-10 21:32:58 +01:00
Loic Bistuer a2814846ca Fixed E124 pep8 warnings. 2013-12-10 15:12:48 -05:00
Florian Apolloner c78bd9eff2 Merge pull request #2048 from loic/ValidationError.message_dict
Trigger AttributeError in ValidationError.message_dict when error_dict is missing.
2013-12-08 05:06:39 -08:00
maurycyp e2e2482391 Renamed first argument of class method to cls 2013-12-07 20:13:53 -05:00
Claude Paroz 5c61b8519d Fixed #18531 -- Deprecated Geo Sitemaps
I've chosen a quick deprecation path, as Geo Sitemaps themselves
are deprecated from some time now.
2013-12-07 21:46:03 +01:00
Vajrasky Kok a7cf48a2b7 Fixed #21573 -- Improved performance of utils.text.normalize_newlines. 2013-12-07 17:19:29 +01:00
Loic Bistuer 2e3c7d8820 Trigger AttributeError in ValidationError.message_dict when error_dict is missing.
The goal of this change is twofold; firstly, matching the behavior of Django 1.6
and secondly, an AttributeError is more informative than an obscure ValueError
about mismatching sequence lengths.

Refs #20867.
2013-12-07 23:01:28 +07:00
Claude Paroz 65faa84de3 Removed unneeded string normalization in contrib.admin
With Python 2.7 and up, named parameter keys are not limited to
bytestrings any longer. This mainly reverts 3bd384aa62.
2013-12-07 15:58:27 +01:00
Loic Bistuer a8f4553aae Fixed #21555 -- Made ValidationError pickable.
Thanks trac username zanuxzan for the report and original patch.
2013-12-07 18:58:37 +07:00
Claude Paroz 41ebc4838d Fixed #21551 -- Reenabled loading fixtures from subdirectory
This was a regression in Django 1.6 that was only partially
restored in 839940f27f.
Thanks Jonas Haag for the report.
2013-12-07 10:47:34 +01:00
Claude Paroz 8a9c8bb907 Fixed #21568 -- Added missing ModelMultipleChoiceField to_python method
Thanks dibrovsd at gmail.com for the report and Simon Charette
for the review.
2013-12-07 10:14:22 +01:00
Baptiste Mispelon a020dd0a99 Fixed #21530 -- Prevent AttributeError in default URLconf detection code.
Thanks to @dmyerscoug for the report and original patch
and to @alasdairnicol for the added tests.
2013-12-07 03:21:58 +01:00
Alex Gaynor ffc0e0ca37 Corrected a flake8 issue -- this line is imported for the purpose of re-exposing the name 2013-12-06 13:22:53 -06:00
Roger Hu bbc73e6a12 Fixed #21566 -- Fixed AttributeError when using bulk_create with ForeignObject. 2013-12-06 20:20:16 +01:00
pegler 38e24d680d Fixed #21554 -- Incorrect SQL generated when using multiple inheritance. 2013-12-06 14:12:38 -05:00
Ramiro Morales 362dd68fb2 Added new 'srtext' spatialite 4.x SpatialRefSys column to its model.
This is for general consistency in the GeoDjango DB backends.
Thanks Claude for the fix.

Refs #19678.
2013-12-06 12:35:18 -03:00
Baptiste Mispelon 621c25c419 Added missing deconstruct() methods. 2013-12-06 15:23:34 +01:00
Baptiste Mispelon 72479a2957 Made the migration detector use meta.local_fields instead of meta.fields.
Refs #21010.

Thanks to Loïc for the patch.
2013-12-06 15:23:21 +01:00
Baptiste Mispelon 19e4374971 Fixed ModelState breaking when unique_together has unhashable elements. 2013-12-06 15:22:52 +01:00
Baptiste Mispelon 54d9e3ccf6 Fixed error in ManyToManyField.deconstruct(). 2013-12-06 15:22:52 +01:00
Baptiste Mispelon f463789f62 Added app_label to the error message when field reconstructing fails. 2013-12-06 15:22:47 +01:00
Andrew Godwin a06fd092ef Merge pull request #2037 from bmispelon/invalidbaseserror
Fixed TypeError when rendering ModelState with multiple bases.
2013-12-06 05:48:21 -08:00
Ramiro Morales 9a73e7f40c Fixed #19678 -- GeoDjango test failure with spatialite >= 3.0.
Thanks Julien for the report and Claude for the fix.
2013-12-06 08:51:45 -03:00
Claude Paroz 482ca0cecc Renamed syncdb to migrate in spatialite backend 2013-12-06 10:00:09 +01:00
maurycyp 4d0c72eb68 Removed unreachable `else` in `try` block. 2013-12-06 01:10:52 -05:00
Baptiste Mispelon aba75b0d71 Fixed TypeError when rendering ModelState with multiple bases. 2013-12-06 00:55:31 +01:00
Ramiro Morales e36c165b14 Corrected setting name in gis test error message. 2013-12-05 18:22:37 -03:00
Andrew Godwin e9c6d04224 Better error reporting when from_app_cache fails 2013-12-05 14:20:30 +00:00
Andrew Godwin 4ca39684ee Fix poor variable name (flake8 warning) 2013-12-05 14:11:46 +00:00
maurycyp ae734b75c1 Removed 'return' in __init__ 2013-12-05 07:09:36 -05:00
Andrew Godwin 3b8e46cbc7 Migration VCS conflict detection and --merge for makemigrations 2013-12-04 16:01:49 +00:00
Andrew Godwin ce05b8a69e Don't make a second migration if there was a force-null-default addcol. 2013-12-04 13:56:22 +00:00
Andrew Godwin df800b1609 Add clone() method to Field to get clean copies of it. 2013-12-04 13:55:45 +00:00
Andrew Godwin ab587fa51a Add --dry-run option to makemigrations 2013-12-04 13:55:20 +00:00
Andrew Godwin 1d20e6df95 Migrate prompts if you need makemigrations, runserver prompts for migrate 2013-12-04 13:34:01 +00:00
Bouke Haarsma 91c38ce4b2 Fixed 21406 -- Made blocktrans 'trimmed' option preserve line numbers.
Thanks Bouke Haarsma for report, fix and initial patch.
2013-12-04 08:36:20 -03:00
Aymeric Augustin 4d738fcc3b Fixed #21546 -- Strengthened kqueue detection.
Thanks Loic Bistuer.
2013-12-04 10:11:42 +01:00
Ramiro Morales 12615dab78 Fixed #13476 -- Added support for color in console output under Windows.
Detect and use the services of the ANSICON third-party tool if it's
available.
2013-12-02 23:18:04 -03:00
Loic Bistuer 9ccde8cfaf Fixed #21545 -- autoreload kqueue events weren't cleared which caused an infinite loop. 2013-12-03 00:12:04 +07:00
Krzysztof Jurewicz b8be3055f1 Fixed #21543 -- Removed base_dir attribute in StaticFilesHandler.
This code seems to be an artifact of AdminMediaHandler removed in [5c53e30607].
2013-12-01 18:03:59 -05:00
Tim Graham fddb0131d3 Fixed #21535 -- Fixed password hash iteration upgrade.
Thanks jared_mess for the report.
2013-11-30 14:18:37 -05:00
Claude Paroz 2080bce695 Fixed #21358 -- Allowed runserver on non-English locales
Thanks svartalf for the report.
2013-11-30 19:17:36 +01:00
Tim Graham f3e7ab366c Removed gender-based pronouns per [c0a2daad78]. 2013-11-30 08:37:15 -05:00
Alex Hill ec73ce5d8a Fixed comment typos. 2013-11-30 07:59:32 -05:00
Claude Paroz 6310d658b7 Closed file after reading pot file
Faulty line was introduced in 50a8ab7cd1.
2013-11-30 11:31:17 +01:00
Claude Paroz 50a8ab7cd1 Enabled makemessages to support several translation directories
Thanks Rémy Hubscher, Ramiro Morales, Unai Zalakain and
Tim Graham for the reviews.
Also fixes #16084.
2013-11-30 11:00:23 +01:00
Alex Gaynor 9af7e18f35 Fixed an unescisarily gendered pronoun in a docstring 2013-11-29 16:57:36 -06:00
Loic Bistuer f563c339ca Fixed #20867 -- Added the Form.add_error() method.
Refs #20199 #16986.

Thanks @akaariai, @bmispelon, @mjtamlyn, @timgraham for the reviews.
2013-11-30 01:00:53 +07:00
Vajrasky Kok 7e2d61a972 Fixed #21380 -- Added a way to set different permission for static directories.
Previously when collecting static files, the directories would receive permissions
from the global umask. Now the default permission comes from FILE_UPLOAD_DIRECTORY_PERMISSIONS
and there's an option to specify the permissions by subclassing any of the
static files storage classes and setting the directory_permissions_mode parameter.
2013-11-29 08:01:30 -05:00
Simon Charette 42ac138009 Fixed a deprecation warning introduced by 96dd48c83f. 2013-11-28 21:42:24 -05:00
Loic Bistuer 91fce675a4 Use 'update_fields' in RelatedManager.clear() when bulk=False.
Thanks Simon Charette for the suggestion.

Refs #21169.
2013-11-29 03:01:08 +07:00
Claude Paroz 34b8a38558 Fixed #21496 -- Fixed crash when GeometryField uses TextInput
Thanks Rhett Garber for the report and initial patch.
2013-11-28 18:29:02 +01:00
Christopher Medrela 7477a4ffde Fixed E125 pep8 warnings 2013-11-28 08:50:11 -05:00
Alex Gaynor a5b94d9d4e A handle of flake8 fixes 2013-11-27 16:42:39 -06:00
Loic Bistuer f450bc9f44 Added a bulk option to RelatedManager remove() and clear() methods
Refs #21169
2013-11-27 19:45:22 +02:00
Anssi Kääriäinen 52015b963d Used simpler queries for m2m clearing when possible.
Refs #21169
2013-11-27 19:45:05 +02:00
Loic Bistuer 17c3997f68 Fixed #21169 -- Reworked RelatedManager methods use default filtering
The `remove()` and `clear()` methods of the related managers created by
`ForeignKey`, `GenericForeignKey`, and `ManyToManyField` suffered from a
number of issues. Some operations ran multiple data modifying queries without
wrapping them in a transaction, and some operations didn't respect default
filtering when it was present (i.e. when the default manager on the related
model implemented a custom `get_queryset()`).

Fixing the issues introduced some backward incompatible changes:

- The implementation of `remove()` for `ForeignKey` related managers changed
  from a series of `Model.save()` calls to a single `QuerySet.update()` call.
  The change means that `pre_save` and `post_save` signals aren't called anymore.

- The `remove()` and `clear()` methods for `GenericForeignKey` related
  managers now perform bulk delete so `Model.delete()` isn't called anymore.

- The `remove()` and `clear()` methods for `ManyToManyField` related
  managers perform nested queries when filtering is involved, which may
  or may not be an issue depending on the database and the data itself.

Refs. #3871, #21174.

Thanks Anssi Kääriäinen and Tim Graham for the reviews.
2013-11-27 19:44:18 +02:00
Andrew Godwin 67b51b9895 Include deferred SQL in sqlmigrate output 2013-11-27 16:29:37 +00:00
Andrew Godwin 5e63977c0e Fixed #21438: makemigrations now detects ManyToManyFields 2013-11-27 15:28:33 +00:00
Andrew Godwin eece3c224e PostGIS schema editor support 2013-11-27 13:32:12 +00:00
Andrew Godwin 4fcfc31865 Add gis deconstruct() method (this does not make schema work) 2013-11-27 12:56:33 +00:00
Andrew Godwin 96dd48c83f Change initial migration writing to work as docs suggest.
Application template now includes an empty migrations module, and
the autodetector will only make initial migrations for apps with
empty modules.
2013-11-27 12:34:31 +00:00
Andrew Godwin db4527e3c0 Fix squashed migration loading ordering issue 2013-11-27 12:29:22 +00:00
Claude Paroz 384816fccb Fixed #21448 -- Fixed test client logout with cookie-based sessions
Thanks Gunnar Scherf for the report and the suggested patch.
2013-11-26 20:41:51 +01:00
Richard Xia 5725236c3e Fixed #21355 -- try importing _imaging from PIL namespace first. 2013-11-26 18:51:39 +02:00
Baptiste Mispelon 9d6c48aeb0 Use str.isupper() to test if a string is uppercased. 2013-11-26 14:08:05 +01:00
Jay Leadbetter c74504c2dd Fixed #20522 - Allowed use of partially validated object in ModelAdmin.add_view formset validation.
Updated ModelAdmin to use form.instance when passing parent model to
child inlines for add_view. There is effectively no change in the
change_view since the previously passed 'obj' is the same as form.instance.

Thanks to meshy for report, and EvilDMP and timo for review.
2013-11-25 20:01:16 -05:00
Loic Bistuer 1c7a83ee8e Fixed #21489 -- Make formsets directly importable from django.forms. 2013-11-25 19:16:19 -05:00
Krzysztof Jurewicz 7a0a3a64a8 Fixed #21509 -- Removed dead exception catching code.
Since Python 2.5, KeyboardInterrupt and SystemExit are not subclasses of
Exception, so explicitly reraising them before the “except Exception” clause
is not necessary anymore.
2013-11-25 16:31:03 +01:00
Alex Gaynor 83ab04c6d6 flake8 fixes 2013-11-24 21:07:21 -06:00
Simon Charette eb38257e51 Fixed #21391 -- Allow model signals to lazily reference their senders. 2013-11-24 17:51:22 -05:00
Joel Bohman 19e5cd77f0 Fixed #21497 -- Forced conversion to bytes for very long index names 2013-11-24 13:15:50 -05:00
Baptiste Mispelon e681b2861d Fixed #21500 -- Removed imports of deprecated utils.importlib 2013-11-24 16:45:01 +01:00
Florian Apolloner d47f794f8f Properly closed cache connections at the end of the request.
This only affects the new cache api and not the deprecated get_cache.

Refs #21012
2013-11-24 16:23:28 +01:00
Baptiste Mispelon 17912522ce Fixed #21504 -- Don't shadow database errors when testing for postgis version.
Thanks to trac user paultag for the report.
2013-11-24 14:34:43 +01:00
Florian Apolloner cf7ddc5765 Follow up to e112654fc8
Actually comitted the code now :þ
2013-11-23 18:55:28 +01:00
Claude Paroz 42fef29446 Fixed #21486 -- Prevented settings config in signal connection
This was particularly problematic in the chain get_wsgi_application
-> db.connections import -> signal connection -> settings configuration.
Thanks Jon Dufresne for the report.
2013-11-23 18:47:47 +01:00
Alex Gaynor 0ec712dd11 A handful of flake8 fixes 2013-11-23 08:26:11 -08:00
Denis Cornehl 1e97058417 Fixes #21412 -- Better error message for messages.add_message
Problem were users calling messages.debug/info/* with a wrong argument
and getting the error "You cannot add messages without installing
MessageMiddleware"

Thanks to trac-user merb for the report.
2013-11-23 17:11:22 +01:00
Aymeric Augustin a480f8320a Simplified iteration in HTTP response objects.
Fixed #20187 -- Allowed repeated iteration of HttpResponse.

All this became possible when support for old-style streaming responses was
finally removed.
2013-11-23 17:03:43 +01:00
Ramiro Morales 62b393c5ae Fixed #21488 -- Multiple locales treatment in i18n commands.
Removed multiple locales separated by commas variation (that wasn't
working as documented) in favor of simply allowing use of the
``--locale``/``-l`` options more than once for ``makemessages`` and
``compilemessages``.

Thanks Romain Beylerian for the report and Claude, Simon for their help.

8750296918 from stable/1.6.x.
2013-11-23 11:53:47 -03:00
Curtis Maloney ffc37e2343 Fixed #21012 -- New API to access cache backends.
Thanks Curtis Malony and Florian Apolloner.

Squashed commit of the following:

commit 3380495e93
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Sat Nov 23 14:18:07 2013 +0100

    Looked up the template_fragments cache at runtime.

commit 905a74f52b
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Sat Nov 23 14:19:48 2013 +0100

    Removed all uses of create_cache.

    Refactored the cache tests significantly.

    Made it safe to override the CACHES setting.

commit 35e289fe92
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Sat Nov 23 12:23:57 2013 +0100

    Removed create_cache function.

commit 8e274f747a
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Sat Nov 23 12:04:52 2013 +0100

    Updated docs to describe a simplified cache backend API.

commit ee7eb0f73e
Author: Curtis Maloney <curtis@tinbrain.net>
Date:   Sat Oct 19 09:49:24 2013 +1100

    Fixed #21012 -- Thread-local caches, like databases.
2013-11-23 15:06:59 +01:00
Baptiste Mispelon 3ca0815c0b Fixed #21445 -- Clean up misuse of null in quickElement.
Thanks to trac user parsch for the report.
2013-11-23 14:40:01 +01:00
Bouke Haarsma 18185724e6 Fixed #21443 -- Cannot show debug info on PY3's importlib
Thanks productions@zaziork.co.uk for the review.
2013-11-22 20:36:33 +01:00
Bouke Haarsma 48ce09f2f6 Fixed missing admindocs' site_header 2013-11-22 13:30:50 +01:00
Pablo Martín 3ac823fc5b Fixed #21460 -- Reenabled proper template precedence in find_template
Refs #20806. Thanks Unai Zalakain for the review.
2013-11-22 11:09:51 +01:00
Claude Paroz d6cc37d601 Updated admindocs to use class-based views
Thanks Bouke Haarsma for the review.
2013-11-21 22:50:59 +01:00
Claude Paroz 1718b5256c Fixed #21405 -- Prevented queryset overwrite in BaseModelAdmin
Thanks guido@20tab.com for the report and Tim Graham for the
analyze.
2013-11-21 22:18:52 +01:00
Anssi Kääriäinen f39fd3cd20 Removed isinstance(RelatedObject) checks from admin.utils 2013-11-21 14:52:01 +02:00
Anssi Kääriäinen 752d3d70da Fixed #21431 -- GenRel->FK list_filter regression in admin
Report, analysis and tests from stephenmcd.
2013-11-21 14:52:00 +02:00
Loic Bistuer 8e670a0e50 Refs #8261 -- Fixed regression introduced by fd219fa.
ModelAdmin displayed the "View on site" link even if the Model didn't
define the `get_absolute_url()` method.
2013-11-21 16:26:49 +07:00
Claude Paroz fafb6cf049 Fixed #21472 -- Fixed inline formsets display when parent pk is 0
Thanks agale031176@gmail.com for the report.
2013-11-20 21:36:20 +01:00
Baptiste Mispelon 8f5a688d00 Fixed #21458 -- Made check_for_language more resistant to malformed input.
Thanks to Sergey Sorokin for the report and to Bouke Haarsma for the review.
2013-11-20 17:51:53 +01:00
Baptiste Mispelon 331d79a77d Fixed #21469 -- Allow set objects in Meta.unique_together.
Thanks to Tim for the review.
2013-11-20 17:26:26 +01:00
xuxiang 4cfe6ba6a3 Use `classmethod` as a decorator. 2013-11-19 23:08:21 -05:00
Alex Gaynor 73b3c257e3 Changed shortcuts from being a package to just being a module 2013-11-19 15:34:20 -08:00
Vajrasky Kok 68b540c977 Fixed #21361 -- allowed access self.value() from SimpleListFilter lookup
Reviewed by Chris Medrela.
2013-11-19 09:14:22 +02:00
Unai Zalakain 4fdd51b732 Fixed #15179 -- middlewares not applied for test client login()
Requests made with django.test.Client.login() and logout() respect
defaults defined in django.test.Client instantiation and are processed
through middleware.

Thanks to Loic for the reviews.
2013-11-19 09:04:20 +02:00
Claude Paroz 97ac22ebfc Fixed #21457 -- Allowed fixture file name to contain dots
Thanks Keryn Knight for the report.
2013-11-18 20:32:13 +01:00
Claude Paroz a0f3eeccf3 Fixed #21397 -- Re-added flexibility to TypedChoiceField coercion
Thanks Elec for the report and Simon Charette for the review.
2013-11-18 18:24:56 +01:00
Curtis Maloney b2d2d7e60f Optimise admin images 2013-11-18 13:33:28 +11:00
Anssi Kääriäinen 326539f6a4 Fixed a regression caused by fix for #21428
On Python 3 sorting Fields mixed with GenericForeignKeys doesn't work
as GenericForeignKey isn't a subclass of django.db.models.fields.Field.

Refs #21428.
2013-11-16 20:54:36 +02:00
Anssi Kääriäinen 0e079e4331 Fixed #21428 -- editable GenericRelation regression
The GenericRelation refactoring removed GenericRelations from
model._meta.many_to_many. This had the side effect of disallowing
editable GenericRelations in ModelForms. Editable GenericRelations
aren't officially supported, but if we don't fix this we don't offer any
upgrade path for those who used the ability to set editable=True
in GenericRelation subclass.

Thanks to Trac alias joshcartme for the report and stephencmd and Loic
for working on this issue.
2013-11-16 20:07:35 +02:00
Claude Paroz b642d540d4 Moved import at proper place in contrib.sites 2013-11-16 11:13:04 +01:00
Baptiste Mispelon ceecc962ad Fixed #21447 -- Restored code erroneously removed in 20472aa827.
Also added some tests for HttpRequest.__repr__.
Note that the added tests don't actually catch the accidental code
removal (see ticket) but they do cover a codepath that wasn't tested
before.

Thanks to Tom Christie for the report and the original patch.
2013-11-16 01:09:35 +01:00
glts 7e0ebd74c1 Fixed #21415 -- Replaced escape sequence by literal non-breaking space
Unfortunately, escape sequences (\x.. or \u....) do not fit well
with the gettext toolchain. Falling back to using literal char,
even if visibility is not ideal.
2013-11-15 15:32:46 +01:00
Claude Paroz 115fd140ab Configure settings sooner in makemessages
As get_text_list is using translations, setup settings before
calling it.
2013-11-15 15:30:22 +01:00
Alex Gaynor 10a09b8e60 Fixed the use of the -ise suffix, where -ize is prefered 2013-11-15 05:23:14 -08:00
Loic Bistuer 32e75803be Fixed typo and slightly improved error message when db is missing time zone definitions.
Refs #21432.
2013-11-15 10:55:29 +07:00
Loic Bistuer 17ed99f3a3 Fixed #21432 -- DateTimeQuery now copies tzinfo when cloning.
Thanks Enrique Martínez for the report and @bmispelon for the tests.
2013-11-14 21:36:55 +01:00
Matt Robenolt 3560ef043e Propagate get_user_model exception from get_user
Fixes #21439
2013-11-14 12:02:26 -08:00
Loic Bistuer cb83448891 Fixed #21410 -- prefetch_related() for ForeignKeys with related_name='+'
Regression introduced by commit 9777442.

Thanks to trac username troygrosfield for the report and test case.
2013-11-13 07:35:34 +02:00
Vajrasky Kok 8ed96464e9 Fixed typo in lru_cache.py; refs #21351. 2013-11-12 18:45:35 +01:00
Alex Gaynor bc742ca110 Flake8 fixes -- including not runnign flake8 over a backported file 2013-11-11 14:05:14 -08:00
Claude Paroz 0be7f57a90 Merge pull request #1907 from Bouke/tickets/21388
Fixed #21388 -- Corrected language code for Frisian
2013-11-11 09:33:55 -08:00
Baptiste Mispelon 5fda9c9810 Fixed #21423 -- Fixed typo in widgets.py. 2013-11-11 18:03:01 +01:00
Sjoerd Langkemper d87127655f Fixed #21421 -- Added level_tag attribute on messages.
Exposing the level name (e.g. "info") makes it possible to prepend
something to the class name. For example, Twitter Bootstrap has
an alert-info class. This class can now be added to the message
using `class="alert-{{ message.level_tag }}".
Because the level_tag was on the end of the `tags` property, it
could not be used in this fashion when extra_tags were given.
2013-11-11 17:58:02 +01:00
Aymeric Augustin f67cce0434 Fixed #21420 once more. 2013-11-11 15:48:48 +01:00
Bouke Haarsma 4142d15102 Fixed #21388 -- Corrected language code for Frisian 2013-11-11 13:34:01 +01:00
Claude Paroz dffcc5e979 Fixed #20990 -- Ensured unicode paths in compilemessages
Thanks Gregoire Astruc for the report and furins for the review.
2013-11-11 11:51:38 +01:00
Bouke Haarsma 2397daab4a Fixed #9523 -- Restart runserver after compiling apps translations
Django also uses locales provided by apps, which also might change. Also when
i18n is disabled, there is no need for watching translation files.
2013-11-11 11:43:09 +01:00
Aymeric Augustin dbbd10e75f Fixed #21420 -- Autoreloader on BSD with Python 3.
Thanks Bouke Haarsma for the report.
2013-11-11 10:46:24 +01:00
Aymeric Augustin 6010b5360f Fix syntax error under Python 3.2. 2013-11-11 10:43:17 +01:00
Bouke Haarsma 9b7455e918 Fixed #21351 -- Replaced memoize with Python's lru_cache.
Replaced the custom, untested memoize with a similar decorator from Python's
3.2 stdlib. Although some minor performance degradation (see ticket), it is
expected that in the long run lru_cache will outperform memoize once it is
implemented in C.

Thanks to EvilDMP for the report and Baptiste Mispelon for the idea of
replacing memoize with lru_cache.
2013-11-11 08:53:09 +01:00
Claude Paroz e7383f16b4 Fixed #14800 -- Suppressed WSGIRequestHandler message filtering
Filtering out static file requests in runserver has been judged
arbitrary and can hide some debugging-related activity.
Thanks Roy Smith for the report and Aymeric Augustin for the
review.
2013-11-09 16:23:14 +01:00
Tim Graham 98de90d3d8 Fixed spelling of compatibility. 2013-11-09 10:17:17 -05:00