Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

astroid.exceptions.AstroidImportError: Failed to import module #241

Closed
adongy opened this issue Jul 18, 2019 · 4 comments
Closed

astroid.exceptions.AstroidImportError: Failed to import module #241

adongy opened this issue Jul 18, 2019 · 4 comments

Comments

@adongy
Copy link

adongy commented Jul 18, 2019

Hi,

I believe this is related to #232 but not sure.

pylint_django==2.0.11

pylint --version
pylint 2.3.1
astroid 2.2.5
Python 3.7.3 (default, Mar 27 2019, 09:23:15)
[Clang 10.0.1 (clang-1001.0.46.3)]

I'm trying to lint:

app/
  models/
    __init__.py

(simplified, the real code has multiple files inside models/)

with __init__.py:

from django.db import models

class A(models.Model):
    content_type = models.ForeignKey(
        to="contenttypes.ContentType", on_delete=models.CASCADE
    )

I get the following stacktrace:

Traceback (most recent call last):
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/astroid/__init__.py", line 91, in _inference_tip_cached
    return iter(_cache[func, node])
KeyError: (<function infer_key_classes at 0x1071a97b8>, <Call l.5 at 0x107b2eeb8>)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/adongy/work/pylintbug/env/bin/pylint", line 10, in <module>
    sys.exit(run_pylint())
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint/__init__.py", line 20, in run_pylint
    Run(sys.argv[1:])
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint/lint.py", line 1628, in __init__
    linter.check(args)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint/lint.py", line 943, in check
    self._do_check(files_or_modules)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint/lint.py", line 1075, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint/lint.py", line 1158, in check_astroid_module
    walker.walk(ast_node)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint/utils.py", line 1303, in walk
    self.walk(child)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint/utils.py", line 1300, in walk
    cb(astroid)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 57, in augment_func
    augmentation(chain, node)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 148, in do_suppress
    chain()
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 56, in chain
    old_method(node)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 57, in augment_func
    augmentation(chain, node)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 148, in do_suppress
    chain()
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 56, in chain
    old_method(node)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 57, in augment_func
    augmentation(chain, node)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 148, in do_suppress
    chain()
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 56, in chain
    old_method(node)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 57, in augment_func
    augmentation(chain, node)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 148, in do_suppress
    chain()
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 56, in chain
    old_method(node)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint/checkers/classes.py", line 729, in visit_classdef
    self._check_bases_classes(node)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint/checkers/classes.py", line 1444, in _check_bases_classes
    unimplemented_abstract_methods(node, is_abstract).items(),
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint/checkers/utils.py", line 782, in unimplemented_abstract_methods
    infered = safe_infer(obj)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint/checkers/utils.py", line 1066, in safe_infer
    value = next(inferit)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/astroid/decorators.py", line 131, in raise_if_nothing_inferred
    yield next(generator)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/astroid/decorators.py", line 95, in wrapped
    res = next(generator)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/astroid/bases.py", line 137, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/astroid/node_classes.py", line 348, in infer
    return self._explicit_inference(self, context, **kwargs)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/astroid/__init__.py", line 93, in _inference_tip_cached
    result = func(*args, **kwargs)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/pylint_django/transforms/foreignkey.py", line 96, in infer_key_classes
    MANAGER.ast_from_module_name(module_name)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/astroid/manager.py", line 178, in ast_from_module_name
    raise e
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/astroid/manager.py", line 129, in ast_from_module_name
    found_spec = self.file_from_module_name(modname, context_file)
  File "/Users/adongy/work/pylintbug/env/lib/python3.7/site-packages/astroid/manager.py", line 222, in file_from_module_name
    raise value
astroid.exceptions.AstroidImportError: Failed to import module contenttypes.models with error:
No module named contenttypes.models.

I believe it's trying to treat the app name as an importable module name but that seems incorrect ? (eg contenttypes is django.contrib.contenttypes)

Thanks,

@atodorov
Copy link
Contributor

atodorov commented Aug 6, 2019

I will close this as known issue as described in #242. The problem in this particular case is that the AST parser is looking for contenttypes.models.ContentType which of course doesn't exist. I don't see a reason why you would not reference this model by class instead of string.

See also #243 for proposal how to start making the overall situation better.

@atodorov atodorov closed this as completed Aug 6, 2019
danihodovic added a commit to danihodovic/wagtail that referenced this issue Aug 25, 2019
It's not possible to use wagtail in a project with pylint and the
pylint-django plugin.

Pylint-django does not work with foreign keys that are referenced by
their string names. See: https://github.com/PyCQA/pylint-django#known-issues

If we simply replace the string name with the foreign-key class, linting
on wagtail projects is fixed.

Also see:
pylint-dev/pylint#2995
pylint-dev/pylint-django#241
danihodovic added a commit to danihodovic/wagtail that referenced this issue Aug 25, 2019
It's not possible to use wagtail in a project with pylint and the
pylint-django plugin.

Pylint-django does not work with foreign keys that are referenced by
their string names. See: https://github.com/PyCQA/pylint-django#known-issues

If we simply replace the string name with the foreign-key class, linting
on wagtail projects is fixed.

Also see:
pylint-dev/pylint#2995
pylint-dev/pylint-django#241
gasman pushed a commit to wagtail/wagtail that referenced this issue Sep 3, 2019
It's not possible to use wagtail in a project with pylint and the
pylint-django plugin.

Pylint-django does not work with foreign keys that are referenced by
their string names. See: https://github.com/PyCQA/pylint-django#known-issues

If we simply replace the string name with the foreign-key class, linting
on wagtail projects is fixed.

Also see:
pylint-dev/pylint#2995
pylint-dev/pylint-django#241
gasman pushed a commit to wagtail/wagtail that referenced this issue Sep 4, 2019
It's not possible to use wagtail in a project with pylint and the
pylint-django plugin.

Pylint-django does not work with foreign keys that are referenced by
their string names. See: https://github.com/PyCQA/pylint-django#known-issues

If we simply replace the string name with the foreign-key class, linting
on wagtail projects is fixed.

Also see:
pylint-dev/pylint#2995
pylint-dev/pylint-django#241

Conflicts:
	CONTRIBUTORS.rst
@fkromer
Copy link

fkromer commented Apr 3, 2020

@atodorov How can I fix this issue when it pops up w.r.t. models.OneToOne instead of models.ForeignKey?

@fkromer
Copy link

fkromer commented Apr 6, 2020

@atodorov models.ForeignKey and models.OneToOne behave equally w.r.t. lazy relationship reference https://docs.djangoproject.com/en/3.0/ref/models/fields/#foreignkey . When using only one Django app there is the workaround of using the model syntax instead of the APP-NAME.model syntax. However in case you use several Django apps you have to use the APP-NAME.model syntax. In this case the issue cannot be solved and there is no workaround I know about. I'd suggest to reopen the issue or open a new one. For more details refer to https://stackoverflow.com/a/60996194/5308983 .

huynhsontung added a commit to wethegit/wagtail that referenced this issue Apr 22, 2020
* Adds Collections section to editor's guide

* Add form media to users/edit.html (wagtail#5390)

* Adds screen-reader-only text to the close button for modals (wagtail#5274, wagtail#5377)

* Adds clearer text to the close button for modals
* Use existing wagtailConfig.STRINGS to store the new translatable string for JS, rather than introducing a new library.
* Update list of string constants for translation in the tests file
* Remove aria-hidden on modal dialog close button

* Ensure the 'add child page' button displays when focused (wagtail#5274, wagtail#5382)

* Fix elasticsearch search backend tests broken by wagtail#5208

* Remove buggy tab order customisations in CMS admin (wagtail#5383, wagtail#5351)

* Fix spelling (wagtail#5393)

* Add labels to permission checkboxes for screen reader users (wagtail#5329, wagtail#5395)

- adds a fieldset around checkboxes with the same name
- add correct labels for object permissions table
- Ensure that image and document permissions labels display correctly, and ensure that labels for the dropdowns for document and image collections are not display:none
- Hide labels from sighted users in group edit / group add pages

* Optimization of UserPagePermissionsProxy.revisions_for_moderation (wagtail#5311)

revisions_for_moderation() was iterating over Page instances only
to use their path attribute. The optimization uses values_list()
over the GroupPagePermission queryset to retrieve only the page
paths without having to create the model instances in memory. This
saves roughly 50% of the runtime.

* Re-add loading of Wagtail icon font for userbar. Fix wagtail#5397 (wagtail#5398)

* Refactor submenu JS to remove jquery dep and move to wagtail-client (wagtail#5254)

* Add more contextual information for screen readers in the explorer menu’s links (wagtail#5335, wagtail#5386)

* Add dedicated accessibility section to v2.6 release notes (wagtail#5402)

* Add process_child_object method to Page.copy

* Add "exclude_fields" parameter to Page.copy

Also, make the excluded fields take effect on child relations as well

* Provide the original and copied pages to process_child_object()

* Add tests for Page.copy() process_child_object and exclude_fields

* Release notes for wagtail#5183

* Implement Page.with_content_json and add to docs (fixes wagtail#5199)

* Tests for wagtail#5203

* Release notes for wagtail#5203

* Improve screen-reader labels for action links in page listing (wagtail#5274, wagtail#5380)

* Move focus to the pages explorer menu when open (wagtail#5336, wagtail#5394)

* Ensure that when you open the explorer the focus moves to the first link of the menu, and add a label for the explorer navigation
* Add dialog role to pages explorer popup, and ensure that there is an option to close the dialog window when tabbing by making the close button visually hidden rather than display none

* Added CI config to generate nightly builds from master (wagtail#5320)

* Added CI config to generate nightly builds from master

* Fix typo

* Don't write __init__.py directly

We need to import the original in the script

* Update wagtail.utils.version

This is based off a copy from Django master made just now and adds
support for 'dev' versions.

* Try pip install --user

* Add screen-reader labels across multiple parts of the UI (wagtail#5274, wagtail#5339, wagtail#5372)

* Rename _utilities.hidden.legacy.scss to _utilities.visuallyhidden.scss (wagtail#5404)

We will always need visuallyhidden styles for screen readers.

* Update CONTRIBUTORS.rst

* added construction_hook_name to settings_menu (wagtail#5384)

* Clarify new three month release policy

* Adjust link label

* Update third_party_tutorials.rst

Add a detailed article about using GraphQL in Wagtail

* Nightly: Upload builds to 'dist' subfolder

* Nightly: Upload builds to 'dist' subfolder

* Nightly: Keep latest.json public when updating

* Nightly: Add script for testing nightly builds

* Document the workaround for broken wagtailimages.Filter references in custom image migrations

* Added missing is_stored_locally() to AbstractDocument

* Datetime picker dispatches 'change' event

* Also add change event to timepicker and datepicker

* Search query normalisation no longer removes punctuation wagtail#5416

* Don't make assumptions about the username field

The USERNAME_FIELD exists to allow customisation. Therefore we should make an assumption that `.username` exists on the model. Instead, we need to pull the required value from the USERNAME_FIELD and add in a fallback default.

* Optimize admin.navigation.get_explorable_root_page

Testing the queryset in the if clause was causing the whole queryset
to be retrieved and populated from DB, all to check whether it was empty
or not.

The optimization is to rely on the strict behavior of
first_common_ancestor, which raises an exception if the queryset is
empty.

* Fetch new translations from Transifex

* Generate new strings for translation

* Version bump to start work on 2.7

* Add 2.7 section to changelog and release notes

* Fix update docs typo

Only two Ss in accessor. Also make quotes consistent.

* Remove features deprecated in 2.7

* Rotate deprecation warnings for 2.7

* Pin Squash docker image to a specific version (wagtail#5441)

Recent builds have been breaking due to the following error: `/post_build.sh: line 2: npm: command not found`. I’m not entirely sure this is the fix, but it looks like this `latest` tag is now resolving to `3.7.4-buster` (https://hub.docker.com/_/python). Debian Buster got released 2 weeks ago. It feels safer to have a pinned dependency, and Stretch is probably what it was resolving to before.

* Add a `construct_page_listing_buttons` hook

This hook mimics the functiolity provided by `construct_page_action_menu`
in that it constructs the final list of buttons to be shown in the wagtail
admin interface.  This means that within this function button's can be
removed, added or re-ordered.

See wagtail#4925

* Updated feature detection notes

* Fix broken pipenv/docutils dependency on CircleCI

* Break long file titles on multi file upload listing

* Fix docs title to break for long filenames

* Release note for wagtail#5431

* Add https support for scribd oembed provider (wagtail#739)

Currently scribd defaults to https for their sharing links - http still works but if you copy&paste quickly you may think it's broken

* Fix the required styles on title fields (wagtail#5440)

* Change StreamField group labels color so labels are visible. Fix wagtail#5455 (wagtail#5462)

* use lighter grey for streamfield group label for accessible contrast

* Fix jcrop holder image having no alt tag

* Pass down process_child_object when copying recursively

* Delay dirty form check data snapshot to avoid race conditions. Fix wagtail#4978 (wagtail#5469)

User interaction with the form within the 10s delay also won’t trigger the confirmation message. There will still be race condition issues if form widgets like rich text take 10+ seconds to initialise – but that doesn’t seem likely.

* Add release notes for 2.5.2

* Fetch new translations from Transifex

* Fill in release date for 2.5.2

* Fill in release date for 2.6

* Make image fallback work for images with big/small aspect ratios. Fix wagtail#5472 (wagtail#5474)

* Add support for phone links in rich text

This is mainly copy paste of Liam Brenner work (wagtail#3776) but with
a few fixes to make it work with Draftail. Since mailto:-links
is supported i think it is reasonable to support tel:-links as
well

* Apply escaping to JS translation strings. Fixes wagtail#5477

* Add release notes for 2.6.1

* Prevent exception when attempting to delete a model with a protected 1-to-1 relation

Modeladmin handles notification to the user if a model instance has protected ForeignKey
relationships. However, if the protected relation is a OneToOneField it raises an exception:

  File ".../wagtail/wagtail/contrib/modeladmin/views.py", line 742, in post
    for obj in qs.all():
AttributeError: 'MyRelatedModel' object has no attribute 'all'

because qs in this case is the related instance rather than a queryset of related instances
(as is the case for a ForeignKey).

This commit handles the OneToOneField case as well.

* Move and refactor upgrade notification JS

* Clarify CHANGELOG instructions in "Committing code" docs (wagtail#5483)

* Fill in release date for 2.6.1

* Add labels to snippet bulk edit checkboxes for screen reader users. Fix wagtail#5328 (wagtail#5463)

* Resolve DeprecationWarning (wagtail#5485)

Resolves "DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working" - see wagtail#5484

* Use xenial for all travis builds

* Test against Python 3.8 dev build

* Add (failing) test for middleware responses during preview

Responses returned by middleware (e.g. authentication failure) while creating the dummy request for a page preview. However, the current (broken) behaviour is to ignore the response, and attempt to serve the preview using the resulting request - which is likely to have incompletely-applied middleware, leading to hard-to-debug issues (usually involving a missing request.site).

* Introduce make_preview_request method to supersede dummy_request

Django-1.10-style middleware inherently doesn't support applying middleware to the request independently of running the view function, as the design of dummy_request requires. The current implementation of dummy_request unwittingly works around this by running the entire request/response cycle on the page's live URL (regardless of whether the page actually exists there at that moment), throwing away the response, and returning the request object to be used a second time (at which point it will be hopefully be populated with middleware-supplied attributes such as request.user and request.site - unless something caused the middleware to abort).

The new make_preview_request method wraps the call to serve_preview inside the middleware processing, so there is no longer a bogus 'background' request and no response has to be thrown away (meaning that any response returned by middleware will be correctly returned).

Fixes wagtail#3546

* Update dummy_request tests to use make_preview_request

* Deprecation note for dummy_request

* Release note for wagtail#5427

* Don't use page admin title when editing rich text (wagtail#5491)

When editing a rich text field and entering a link to a page whose Page
type overrides get_admin_display_title, the custom admin display title
is used both when browsing to select the page to link to and also when
viewing the rich text editor.

The first behavior is consistent with how custom admin display titles
are used throughout the admin, but the second behavior is not. The
Wagtail user should be able to use the rich text field as a reasonable
preview of what the rendered content will look like for the end user. To
do this, the "real" page title should be used, not the admin one.

This commit alters the data that gets passed to the rich text editor so
that its title is the real page title and not the admin one.

Fixes issue 5131.

* Properly check permissions when viewing revisions (wagtail#5490)

Currently any user with any page permission can view any page revision.
This commit fixes that, and ensures that the user has publish or edit
permission on the page before showing a page revision. If not, the user
is presented with a 403.

This maintains the current behavior if the user has no page permissions,
which is to redirect to the admin home page.

New tests have been added to cover these changes.

Fixes issue 5426.

* Fix pageurl and slugurl handling of situations where request.site is null (wagtail#5501)

* Add caption field to TableBlock

* Create caption field added to table block widget

Caption allows for users users with screen readers to be
able to understand the contents of a table.

* Fixed bugs in javascript and typos

* Updated documentation and change log

* Fixed table caption bug and requested pr edits

* Fixed table caption bug and request pr edits

* Removed changes in changelog.txt

* Fixed bug and requested PR edits

* Output form media on add/edit/chooser image forms with custom models

* Add tests for custom image on multiple image uploader
* Output form media on image add/edit views
* Output form media for 'add image' form within image chooser modal
Note: this won't work reliably if the media is hosted on a CDN, because script tags inserted as part of a jQuery DOM insertion (as modals are) are loaded asynchronously and not guaranteed to complete loading before inline scripts are run. It's better than not having the includes there at all though...

* Upgrade minimum 6.x release for Elasticsearch to 6.4.0

Fix doc and test on ES6 python client compat

This commit changes the statement that version < 6.3.1 of the
elasticsearch python client should be used to instead state
that 6.4.0 is fine.

It also update the tests to reflect the statement.

Initially the `update_all_types` argument has been used to work
around an issue described in:
wagtail#2968

This argument was removed in elasticsearch-py 6.3.1 and making
use of it was raising an error.

With 6.4.0 nothing is raising anymore.

* Add ability to create anchor link tab within rich text link

- add tests

- Update changelog & release notes

* Update Changelog

* Upgrade django-taggit to 1.x

django-taggit 1.x drops Python 2.x support and thus the dependency on django.utils.six; this is a prerequisite for supporting Django 3.0.
The signature of TaggableManager.value_from_object has changed to return a list of Tags (previously it was a QuerySet of TaggedItems) and so search indexing and comparison need to be updated accordingly. There is a corresponding fix to ClusterTaggableManager in django-modelcluster 5.0.

* Fix failing tests due to different HTML escaping in Django 3.0

- Fix password reset tests
- Fix test for invalid-slug message
- Update changelog/release notes

* Fixes layout for the FileField

* Allow users to change their first and last name

* Move locale-related functions from wagtail.admin.utils to wagtail.admin.locale

* Move model-related functions from wagtail.admin.utils to wagtail.admin.models

* Move authentication-related functions from wagtail.admin.utils to wagtail.admin.auth

* Move authentication-related functions from wagtail.admin.decorators to wagtail.admin.auth

* Move email functions from wagtail.admin.utils to wagtail.admin.mail

* Move get_site_for_user to wagtail.admin.navigation

* Update docs with new locations of wagtail.admin.utils definitions

* Fix MovedDefinitionHandler deprecation warnings to point to the import location

* Update wagtail.admin.utils and wagtail.admin.decorators imports to new locations. Fixes wagtail#5507

* Make try/catch AttributeError less all-encompassing

* Update references to wagtailadmin in comment

* Fix mention of non-existing PageLinkHandler.get_identifier

Refs wagtail#5184

* fix(docs/customization): Add models import to fix example (wagtail#5520)

* Remove Unidecode from postgres_search. Fix wagtail#5001 (wagtail#5514)

* Updated contributors & changelog

* Add telephone number links to release notes

* Replace streamfield CSS with react-streamfield CSS

* Update list / struct / stream block markup to match react-streamfield CSS

* Fix streamfield tests for updated markup

* Updates broken JS tests.

* Updates to react-streamfield 0.9.5.

* Release note for StreamField design update (wagtail#5476)

* Update release schedule info and move dates table to the wiki

Document release schedule in readme

* update docs for TabbedInterface (wagtail#5374)

* Allow content to define the tab width on xs screens to stop cutting off text (wagtail#5392)

* Break listing titles by word so action buttons are visible on smaller screens (wagtail#5429)

* Changed Snippet Chooser AJAX delay from 50ms to 200ms, to remove laggy typing. (wagtail#5439)

50ms is the equivalent of about 200 words per minute, so typing slower than that
meant that the javascript would send an AJAX request between every single
keystroke. This change makes the javascript wait for 200ms between keystrokes,
which lets you finish typing the word you're looking for before it sends an AJAX
request.

* Update CONTRIBUTORS.rst

Correction to contributor's name per request by email

* Add wagtail nightly to readme

* Add note about CurrentSiteMiddleware incompatibility

As per wagtail#2840 (comment)

* fix: Language chosen in user preferences persists on subsequent requests (wagtail#4310)

* Add SECURITY.md (wagtail#5536)

Adds security.md to be consistent with github's interface

* Fix compatibility with pylint-django (wagtail#5538)

It's not possible to use wagtail in a project with pylint and the
pylint-django plugin.

Pylint-django does not work with foreign keys that are referenced by
their string names. See: https://github.com/PyCQA/pylint-django#known-issues

If we simply replace the string name with the foreign-key class, linting
on wagtail projects is fixed.

Also see:
pylint-dev/pylint#2995
pylint-dev/pylint-django#241

* Add setting to disable email management

This commit adds WAGTAIL_EMAIL_MANAGEMENT_ENABLED setting that defaults
to True, but when disabled, hides the 'Change email' button in account
management view, and disables the associated route. This is useful when
using external authentication method like LDAP or OpenID Connect where
email management is handled elsewhere.

Wagtail already includes WAGTAIL_PASSWORD_MANAGEMENT_ENABLED setting.
This is almost exact copy of that implementation.

* Replaced SafeText with SafeString.

* Replaced use of force_text with force_str.

* Updated the block id initialization (wagtail#5552)

The current block id generation only sets the id as the block is serialized for storage in the database, which means that the id is unavailable in the block until it is pulled back from the database. In my debugging this caused the id to be set to new values up to 3 times when saving a brand new page (each time with a new id).
This updated logic applies the new id to the actual block which makes it available right away and prevents the id from being regenerated.

* Stopped inheriting from object.

* Fixed broken email header when hosting static files remotely (wagtail#5543)

Fixes wagtail#5525

* Split up wagtail.admin.tests.test_pages_views

* Fix Postgres search indexing on Postgres 9.4 and Django >=2.2.1

Fixes wagtail#5547
As of Django 2.2.1, Value expressions within a SearchVector must specify an output_field: https://code.djangoproject.com/ticket/30446

* Release note for wagtail#5559

* Fix soundcloud embed regex

* Update core team list in CONTRIBUTORS.rst

* Fill in release date for 2.6.2

* Fetch new translations from Transifex

* Add translator credits

* Add core team alumni section to contributors

* Marks preview models for translation

* Fix class selector mapping (wagtail#5571)

The markup is wrong which results in code not working properly.

* add WAGTAILDOCS_SERVE_METHOD setting to allow serving files from underlying storage

* Documentation tweaks for WAGTAILDOCS_SERVE_METHOD

As suggested by @chosak - wagtail#5296 (comment) , wagtail#5296 (comment)

* Additional tests for document.url and serve view behaviour

* Release note for wagtail#5296

* Update configuration.rst (wagtail#5576)

* Add ability to hide 'Submit for Moderation' in action menu using setting WAGTAIL_MODERATION_ENABLED. When set to false, SubmitForModerationMenuItem method is_shown returns false (wagtail#5574)

* allow image page sizes to be configurable (wagtail#5568)

* Updating FieldDoesNotExist imports to all be django.core.exceptions. (wagtail#5581)

* Test Django master against django-modelcluster master

* Eliminate dependency on default User model from style guide

Fixes wagtail#5442. Building a User object for david@torchbox.com may cause problems if a custom user model is in use, and is redundant anyhow because there's no longer a registered gravatar for that email - we should just hard-code the default blank avatar instead.

* Update more FieldDoesNotExist imports as per wagtail#5581

* Add role="table" to TableBlock output

As per https://twitter.com/SaraSoueidan/status/1177622630763028480, certain browsers apply heuristics to decide whether `<table>` elements exist for layout or data purposes, and adjust the behaviour of their accessibility features accordingly. Given that TableBlock intentionally doesn't allow markup within cells, we can be reasonably sure that any tables created with it are genuine data tables, and should therefore indicate that using `role="table"`.

* Make DraftailRichTextArea be considered as visible (wagtail#5583)

* Make it possible to override the url used by Page._get_dummy_headers()

* Changed height's description to match  width's. (wagtail#5593)

* Add a note on 'Previewing and Submitting for Moderation' page about potential disabled moderation

* Add new docs page 'Changing rich text representation' (wagtail#5579)

* Add new docs page 'Changing rich text representation' describing how to subclass Format to provide a custom image html representation in rich text

* Output form media on add/edit/chooser document forms with custom models

Similar to eaad013, but for Document

* Deduplicate creation of fake file in document tests

* Add separate GitHub issue templates for feature requests and bugs. Fix wagtail#5560 (wagtail#5594)

* Add cache-busting parameter to admin static files

Fixes wagtail#5493

* Disable querystrings if a storage backend with hashed filenames is active

* Added upgrade note about disabling version strings

* Release note for wagtail#5527

* Implements ES7 support (wagtail#5611)

* Implements ES7 support

* Linter fix

* Adds docs

* isort fix

* Fixes typo

* Release notes for wagtail#5611

* Allow default item in action menu to be overridden with construct_page_action_menu hook

Fixes wagtail#5438

* Add 'Page locked' as a distinct menu item

* Revise action menu ordering so that the first (not last) item is picked as the default

Addresses backwards compatibility of existing action menu hooks, as per wagtail#5500 (review)

* Update construct_page_action_menu example

Now avoids redefining the whole list, and reflects the fact that the first (rather than last) item is picked as the default.

* Add release note about template change for action menu items

* Clarify that menu item order attribute is ignored in construct_page_action_menu

* Release note for wagtail#5500 / wagtail#5612

* Add acknowledgement to The Motley Fool

* Remove mentions of Django 3.0 compatibility from release notes

Work on compatibility is ongoing while Django 3.0 is still in development; we don't want this to be misinterpreted as a statement of formal Django 3.0 support (which we can't promise until the final release)

* Add example of template rendering to TableBlock docs

Addresses wagtail#5540

* Added 'image uploads in forms' to third party tutorials

* Fix multiple minor documentation issues

- Typo in readme (verb did not agree with the subject)
- Grammatical error in topics/pages
- wagtail#5364 - Update URL config code block in getting-started/integrating-into-django

* Replace format() placeholders in translatable strings with % formatting

Fixes wagtail#5539. Transifex and Django's makemessages command have validation to catch invalid placeholder variables within translated strings - for example, where the translator has translated the variable name - but these only recognise old-style `%` formatting, not the `format` method, and so it's better for us to standardise on % formatting.

To reduce the burden on translators having to re-translate these strings, only the ones using named placeholders (`"Edited page {title}"`) rather than numeric ones (`"Edited page {0}"`) have been changed - hopefully the latter give less room for error.

Also fixed some incorrect use of plurals (verbose_name vs verbose_name_plural) in snippet confirmation messages.

* Docs - Add AbstractUser import to custom user model

- `from django.contrib.auth.models import AbstractUser`
- revise a previous changelog entry to clarify 'clean up' vs 'fix'

* Recommend signals rather than hooks for model-level customisations

As per wagtail#5620 - signals are often overlooked as a way of customising model-level behaviour. We should recommend them over admin hooks where possible, as they aren't reliant on users taking one particular path through the admin - for example, an 'add document' signal will be triggered regardless of whether a document is created through the single uploader, multiple uploader, chooser model or a scripted task, whereas a hook would not catch all of these cases.

* Formalise Python 3.8 support

* Make copy of ES6 settings before setting max_ngram_diff (wagtail#5625)

* Change string based reference to class based

* Add model to PersonAdmin in documentation

* Replace rawgit.com links with jsdelivr

rawgit will be shut down soon

* Add thanks to squash.io

* [5225] Take number of frames into account when limiting image size

* Revert "Formalise Python 3.8 support"

This reverts commit ddbbaea.

* Add webp support

* Support format-webp and allow changing default formatting

* Add tests for webp format conversion

* Release note for wagtail#5249 / wagtail#5629

* Add documentation for how to use alternative image tags

This adds documentation for alternative image tags such as `<picture>`
and `<amp-img>`.

* Improvements to "Alternative HTML tags" based on review feedback

* syntax => keyword

* Rename wagtail/admin/locale.py to localization.py

Having a module called locale interferes with Django's makemessages / compilemessages commands :-(

* Changelog cleanup

* note Python 3.8 support as provisional
* Remove mentions of minor doc fixes (there are many more fixes beyond the ones mentioned here, and including them all in the release notes would add too much noise...)

* Fetch new translations from transifex

* Remove redundant ugettext_lazy from non-text labels

* Generate new strings for translation

* Version bump to 2.7rc1

* Ensure admin API always uses SessionAuthentication backend

Fixes wagtail#5585 and (at least partly) wagtail#5628

* Release note for wagtail#5643 in 2.6.3

* Release note for wagtail#5643 in 2.7

* Version bump to 2.7rc2

* Formalise Python 3.8 support

* Mark Python 3.8 support as official in changelog

* Avoid calling versioned_static from static form media definitions (wagtail#5644)

* Avoid calling versioned_static from static form media definitions

Fixes wagtail#5632

Defining media definitions with `class Media:` means that those lines are evaluated on application startup; this means that they cannot contain calls to the Django static file finder, because ManifestStaticFilesStorage doesn't work until collectstatic has completed. Fix this by making those definitions into `def media(self):` methods.

* Add test to confirm that inheritance still works with dynamic form media definitions

* Fetch new translations from Transifex

* Fixed 2.6.3 date in Changelog and updated username on Contributors

* Added label 'URL' for external link

- Regression - missing label for external link URL field in link chooser
- Resolves wagtail#5656

* Fix contributor name

- incorrectly added the issue creator not the PR creator
- updated name to the correct one - Stefani Castellanos

* Fetch new translations from Transifex

* Fill in release date for 2.7

* Version bump to 2.7 final

* Version bump to 2.7.1

* Move all usage of versioned_static to media methods (wagtail#5694)

* Release notes for wagtail#5694

* Fill in release date for 2.7.1

* Apply proper HTML escaping on StreamField block comparisons

An individual StreamField block in the comparison view may be rendered as a plain value (for blocks that are unchanged, added or deleted) or a diff (for blocks that are changed). In both cases, the output is returned as HTML, but must not contain any unescaped editor-supplied HTML.

For CharBlock, TextBlock and RawHTMLBlock, the block value is escaped so that any HTML tags in the content are shown verbatim.

For RichTextBlock and any other block types that do not override the default comparison behaviour, we take the basic (non-templated) HTML rendering of the block and extract text-only content from it. This is then returned in HTML-escaped form for the plain view, and run through diff_text().to_html() for the diff view (which handles escaping itself).

* Don't mark the translatable string 'None' as safe

* Release notes for 2.7.2

* Version bump to 2.7.2

* fix syntax

* bug fix

* remove invalid import

* fix more imports

* fix testapp migrations

* fix images and core migrations

* fix image field help text

* add js to AdminImageRenditionChooser

* fix image chooser

* continue fixing image chooser

* add missing js files back to image chooser

* add onload to image chooser

* fix search backend

Co-authored-by: Eric Dyken <eric.dyken@gsdesign.com>
Co-authored-by: Matt Westcott <matt@west.co.tt>
Co-authored-by: Helen Chapman <helen.chapman@torchbox.com>
Co-authored-by: Andy Babic <andyjbabic@gmail.com>
Co-authored-by: jordan-bauer <31709951+jordan-bauer@users.noreply.github.com>
Co-authored-by: Coen van der Kamp <coen@fourdigits.nl>
Co-authored-by: John Carter <john@therefromhere.org>
Co-authored-by: Fidel Ramos <f@fidelramos.net>
Co-authored-by: Thibaud Colas <thibaudcolas@gmail.com>
Co-authored-by: Jonny Scholes <jonnyscholes@gmail.com>
Co-authored-by: Karl Hobley <karl@torchbox.com>
Co-authored-by: Karl Hobley <karl@kaed.uk>
Co-authored-by: Mikalai Radchuk <m1kola@users.noreply.github.com>
Co-authored-by: jordan_bauer <jordan@corecreative.com>
Co-authored-by: Tom Dyson <tom@torchbox.com>
Co-authored-by: Jaroslaw Zabiello <hipertracker@gmail.com>
Co-authored-by: Jonny <jonny@jonnybarker.com>
Co-authored-by: Michael Hearn <git@mikehearn.net>
Co-authored-by: William Blackie <william.blackie96@gmail.com>
Co-authored-by: Andrew Miller <info@akmiller.co.uk>
Co-authored-by: Michael van Tellingen <michael@mvantellingen.nl>
Co-authored-by: Daniele Procida <daniele@vurt.org>
Co-authored-by: kevinhowbrook <kbhowbrook@gmail.com>
Co-authored-by: Rodrigo <matematica.a3k@gmail.com>
Co-authored-by: Cameron Lamb <jafacakes2011@hotmail.co.uk>
Co-authored-by: Catherine Farman <Catherine.Farman@cfpb.gov>
Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com>
Co-authored-by: Iman Syed <52247241+imansyed000@users.noreply.github.com>
Co-authored-by: mien <mikael.pj.engstrom@gmail.com>
Co-authored-by: Neal Todd <neal.todd@torchbox.com>
Co-authored-by: Martey Dodoo <martey@mobolic.com>
Co-authored-by: John Carter <john.carter@prismaticdigital.com>
Co-authored-by: Andy Chosak <andy@chosak.org>
Co-authored-by: Samir Shah <solaris.smoke@gmail.com>
Co-authored-by: rjpruitt16 <rjpruitt16@gmail.com>
Co-authored-by: Jonathan Liuti <liuti.john@gmail.com>
Co-authored-by: Iman Syed <iman.syed@torchbox.com>
Co-authored-by: Mikalai Radchuk <mikalai.radchuk@torchbox.com>
Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
Co-authored-by: Sanyam Khurana <8039608+CuriousLearner@users.noreply.github.com>
Co-authored-by: Pavel Denisov <rsedoy@gmail.com>
Co-authored-by: Kalob Taulien <kalob.taulien@gmail.com>
Co-authored-by: Bertrand Bordage <bordage.bertrand@gmail.com>
Co-authored-by: Zac Connelly <zac.connelly@neuraum.com>
Co-authored-by: Robert Rollins <rrollins@caltech.edu>
Co-authored-by: pvetch <paul.vetch@torchbox.com>
Co-authored-by: Bojan Mihelac <bmihelac@mihelac.org>
Co-authored-by: Sarath Kumar Somana <sarathsomana@gmail.com>
Co-authored-by: Dani Hodovic <dani.hodovic@gmail.com>
Co-authored-by: Janne Alatalo <janne.alatalo@jamk.fi>
Co-authored-by: Mads Jensen <mje@inducks.org>
Co-authored-by: Colin Klein <40399371+colink-eb@users.noreply.github.com>
Co-authored-by: Edy <luca.eduard@ymail.com>
Co-authored-by: Kiril Staikov <kstaikov@gmail.com>
Co-authored-by: Saptak S <saptak013@gmail.com>
Co-authored-by: Dawid Bugajewski <buugaj@gmail.com>
Co-authored-by: Tobias McNulty <tobias@caktusgroup.com>
Co-authored-by: Dawn Wages <dawn.wages@gmail.com>
Co-authored-by: jacobtm <jacobtm@torchbox.com>
Co-authored-by: Brian Whitton <me@brianwhitton.com>
Co-authored-by: Tim White <tim@cyface.com>
Co-authored-by: Mike Janger <inchingforward@gmail.com>
Co-authored-by: jacobtoppm <55137073+jacobtoppm@users.noreply.github.com>
Co-authored-by: Prithvi MK <32909711+pmk21@users.noreply.github.com>
Co-authored-by: pySilver <silveroff@gmail.com>
Co-authored-by: a-mere-peasant <50142453+a-mere-peasant@users.noreply.github.com>
Co-authored-by: David Thompson <david.thompson86@gmail.com>
Co-authored-by: LB (Ben Johnston) <mail@lb.ee>
Co-authored-by: Thijs Baaijen <Thijss@users.noreply.github.com>
Co-authored-by: Andreas Bernacca <hello@rinti.se>
Co-authored-by: frmdstryr <frmdstryr@protonmail.com>
Co-authored-by: David <2297074+dwasyl@users.noreply.github.com>
Co-authored-by: Stefani Castellanos <scct95@hotmail.com>
Co-authored-by: Alex Tomkins <tomkins@darkzone.net>
@Ibrahim-Noor
Copy link

@adongy @fkromer @atodorov Any update on this issue? Has this been fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants