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

Hamlpy on django 1.11 uses the standard django-templates instead hamlpy #173

Open
Sanshain opened this issue Oct 30, 2019 · 2 comments
Open

Comments

@Sanshain
Copy link

I tried to start hamlpy by django 1.11 python 2.7.16. The package was installed 'pip install hamlpy' and followed instructions for setting.

Settings of project:

INSTALLED_APPS = [

    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'django.contrib.sites',                                                     ##

    'hamlpy',
    'testapp',
]


TEMPLATE_LOADERS = (

    'hamlpy.template.loaders.HamlPyFilesystemLoader',
    'hamlpy.template.loaders.HamlPyAppDirectoriesLoader',

    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',

)

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [TEMPLATE_DIR,],
##        'APP_DIRS': True,
        'OPTIONS': {
            'loaders': TEMPLATE_LOADERS,
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

my view:

haml = lambda request: render(request,"test.haml",{})

my test.haml:

#profile
    .left.column
        #date 2010/02/18
        #address Toronto, ON
    .right.column
        #bio Jesse Miller {{user}}

the result page output is one line:

#profile .left.column #date 2010/02/18 #address Toronto, ON .right.column #bio Jesse Miller AnonymousUser

It meens, template has displayed as usually django-template.

I tried to understand why and visit to loaders.py. I discovered for myself that load_template_source is never be called by rendering test.haml and be rendered by integrated in django standart loaders.

I cann't find the answers why

@nathanredblur
Copy link

I'm stuck too. even just importing hamlpy I get this error

  File "/Users/xx/.pyenv/versions/2.7.18/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/Users/xx/.pyenv/versions/2.7.18/lib/python2.7/site-packages/hamlpy/__init__.py", line 2, in <module>
    import templatize
  File "/Users/xx/.pyenv/versions/2.7.18/lib/python2.7/site-packages/hamlpy/templatize.py", line 18, in <module>
    trans_real.templatize = decorate_templatize(trans_real.templatize)
AttributeError: 'module' object has no attribute 'templatize'

I did the same
Python 2.7.18
Django 1.11
pip install hamlpy

what I'm wrong?

@Sanshain
Copy link
Author

Sanshain commented Jun 11, 2023

what I'm wrong?

This is my old question 4 years ago, to which I have not found an answer. The original repository has not been supported for 10 years. Then I found and made my fork, which worked for me. You can try it out.

I also just looked that there is also activity in the repository from which I made the fork.

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

2 participants