Skip to content

ImportError when running the extraction process #48

@antrodart

Description

@antrodart

Hello, I had an ImportError when extracting the messages of my Django app. The message error was the following one:

from django.template.base import Lexer, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK
ImportError: cannot import name 'TOKEN_TEXT' from 'django.template.base' (c:\users\artac\appdata\local\programs\python\python37-32\lib\site-packages\django\template\base.py)

I managed to solve it by making some changes in the django_babel/extract.py file. Those changes where:

  1. Changing the line 2 imports to this: from django.template.base import Lexer, TokenType
  2. Changing the extract_django(fileobj, keywords, comment_tags, options) method, replacing every TOKEN_BLOCK to TokenType.BLOCK, TOKEN_TEXT to TokenType.TEXT and TOKEN_VAR to TokenType.VAR.

My package versions are:

  • Django==2.1.7
  • django-babel==0.6.2
  • Babel==2.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions