Issue #102 resolved

Do not implicitly use wildcard (*) for model inclusion/exclusion

Julien Phalip
created an issue

In AppListElementMixin._visible_models there are these two lines:



included.extend([elem+"" for elem in self.include_list]) ... excluded.extend([elem+"" for elem in self.exclude_list]) }}}

The wildcard is implicitly appended to the model specs provided by the user. This poses a problem when, for example, two model names start with the same characters. For example:



{ 'title': 'Blog',
  'include_list': (


In the example above, ArticleTranslation will match the first regular expression (e.g. 'blog.models.Article*'), therefore it's impossible to control the order in which the models appear, as ArticleTranslation may appear before Article.

So, I suggest replacing those two lines with:



included.extend(self.include_list) ... excluded.extend(self.exclude_list) }}}

This would be backwards-incompatible, but the upgrade path would be easy (i.e. append '*' in your specs where needed), and it would be more explicit and would offer more control.

What do you think? If you think that's a good idea, then I'd be happy to provide a patch.


Comments (3)

  1. Mikhail Korobov

    I believe 'include_list' and 'exclude_list' are there exactly for backward compatibility with older versions of django-admin-tools. They are undocumented. Use 'models' and 'exclude' instead of 'include_list' and 'exclude_list' - they don't implicitly add wildcard.

  2. Mikhail Korobov

    They should also raise DeprecationWarnings with the suggestion to use 'models' and 'exclude' (but these warnings may not be shown because python 2.7 silences DeprecationWarnings by default).

  3. Julien Phalip reporter

    Yes you're right. I didn't realize that 'models' and 'exclude' gave you full control over the regular expressions. Thanks for the tip, and sorry for the noise.

  4. Log in to comment