ImportError: no module named remote

I am trying to create the following template tag for django:

from django import template
from django.utils import translation
from player.remote import MongoDb

register = template.Library()

@register.assignment_tag
def load_item(itemId):
  mongo = MongoDb.instance()
  return mongo['lol-%s' % translation.get_language()]['items'].find_one({'id': int(itemId)})

but whenever I try to download it, it always fails with the following error:

'items' is not a valid tag library: ImportError raised loading tags.templatetags.items: No module named remote

Some notes:

  • I can import MongoDb using the manage.py shell
  • My project path is in Python path
  • 'player' is currently in the settings under "INSTALLED_APPS".
  • I already tried: "player.remote", 'remote', 'app.player.remote', 'teemo.app.player.remote', 'teemo.player.remote'
  • I am using the embedded server since I am still developing it
  • I am using django 1.8 with python 2.7.6 on Ubuntu

Structure (many files are missing, but overall):

teemo
  manage.py
  player
    __init__.py
    remote.py
  templates
    player
      resume.html <-- Importing 'items' tags
  tags
    templatetags
      __init__.py
      items.py

What am I missing here?

+4
2

, items, dict items.

items dict, .

0

'teemo.tags' INSTALLED_APPS, django templatetags.

Edit

, : teemo/tags/__init__.py file.

0

Source: https://habr.com/ru/post/1609666/


All Articles