HamlPy icon indicating copy to clipboard operation
HamlPy copied to clipboard

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

Open Sanshain opened this issue 5 years ago • 2 comments

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

Sanshain avatar Oct 30 '19 09:10 Sanshain

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?

nathanredblur avatar Jun 08 '23 18:06 nathanredblur

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.

Sanshain avatar Jun 11 '23 17:06 Sanshain