Code Monkey home page Code Monkey logo

Comments (14)

gregmuellegger avatar gregmuellegger commented on June 30, 2024

Hi, I'm not really using django-mobile in any recent project, so it might take a while until I get around to provide the fix. However I'm very happy to merge any pull requests in that regard. Would you like to work on this and provide the project with a good fix?

from django-mobile.

Sinkler avatar Sinkler commented on June 30, 2024

Hi, please check #56

from django-mobile.

arnaudblois avatar arnaudblois commented on June 30, 2024

Hi, many thanks Sinkler for your help. I checked #56 but unfortunately I am still having issues. It works fine if I use django.template.loaders.cached.Loader as loader, however using django_mobile.loader.CachedLoader gives me a rather obscure error
SyntaxError: invalid syntax (loader.py, line 17) Exception Location: /usr/local/opt/python-3.4.2/lib/python3.4/importlib/__init__.py in import_module, line 109

from django-mobile.

Sinkler avatar Sinkler commented on June 30, 2024

Ursidours, can you copy a full traceback?

from django-mobile.

arnaudblois avatar arnaudblois commented on June 30, 2024

I hope this helps

Request Method: GET
Request URL: http://localhost:8000/

Django Version: 1.8
Python Version: 3.4.2
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'debug_toolbar',
'debug_panel',
'django_mobile')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django_mobile.cache.middleware.CacheFlavourMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.http.ConditionalGetMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'debug_panel.middleware.DebugPanelMiddleware',
'django_mobile.middleware.MobileDetectionMiddleware',
'django_mobile.middleware.SetFlavourMiddleware')

Traceback:
File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/core/handlers/base.py" in get_response

  1.             response = middleware_method(request, response)
    
    File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/debug_panel/middleware.py" in process_response
  2.     response = super(DebugPanelMiddleware, self).process_response(request, response)
    
    File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/debug_toolbar/middleware.py" in process_response
  3.         bits[-2] += toolbar.render_toolbar()
    
    File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/debug_toolbar/toolbar.py" in render_toolbar
  4.         return render_to_string('debug_toolbar/base.html', context)
    
    File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/template/loader.py" in render_to_string
  5.         template = get_template(template_name, using=using)
    
    File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/template/loader.py" in get_template
  6.             return engine.get_template(template_name, dirs)
    
    File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/template/backends/django.py" in get_template
  7.     return Template(self.engine.get_template(template_name, dirs))
    
    File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/template/engine.py" in get_template
  8.     template, origin = self.find_template(template_name, dirs)
    
    File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/template/engine.py" in find_template
  9.     for loader in self.template_loaders:
    
    File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/utils/functional.py" in get
  10.     res = instance.**dict**[self.name] = self.func(instance)
    
    File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/template/engine.py" in template_loaders
  11.     return self.get_template_loaders(self.loaders)
    
    File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/template/engine.py" in get_template_loaders
  12.         loader = self.find_template_loader(template_loader)
    
    File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/template/engine.py" in find_template_loader
  13.         loader_class = import_string(loader)
    
    File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/utils/module_loading.py" in import_string
  14. module = import_module(module_path)
    
    File "/usr/local/opt/python-3.4.2/lib/python3.4/importlib/init.py" in import_module
  15. return _bootstrap._gcd_import(name[level:], package, level)
    

Exception Type: SyntaxError at /
Exception Value: invalid syntax (loader.py, line 17)

from django-mobile.

Sinkler avatar Sinkler commented on June 30, 2024

Ursidours, please, try to change order of middlewares, CacheFlavourMiddleware shoud be after MobileDetectionMiddleware

MIDDLEWARE_CLASSES = (
    // ...
    'django_mobile.middleware.MobileDetectionMiddleware',
    'django_mobile.middleware.SetFlavourMiddleware',
    'django_mobile.cache.middleware.CacheFlavourMiddleware',
    // ...
)

from django-mobile.

arnaudblois avatar arnaudblois commented on June 30, 2024

I'm getting the same error with

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.http.ConditionalGetMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'debug_panel.middleware.DebugPanelMiddleware',
'django_mobile.middleware.MobileDetectionMiddleware',
'django_mobile.middleware.SetFlavourMiddleware',
'django_mobile.cache.middleware.CacheFlavourMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
)

from django-mobile.

Sinkler avatar Sinkler commented on June 30, 2024

I can't reproduce this with Python 3.4.3, requirements

django
django-debug-toolbar
django-debug-panel
-e git+https://github.com/Sinkler/[email protected]#egg=django-mobile

and settings

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'debug_toolbar',
    'debug_panel',
    'django_mobile',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.http.ConditionalGetMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'debug_panel.middleware.DebugPanelMiddleware',
    'django_mobile.middleware.MobileDetectionMiddleware',
    'django_mobile.middleware.SetFlavourMiddleware',
    'django_mobile.cache.middleware.CacheFlavourMiddleware',
    'django.middleware.cache.FetchFromCacheMiddleware',
)

TEMPLATE_LOADERS = (
    ('django_mobile.loader.CachedLoader', (
        'django_mobile.loader.Loader',
        'django.template.loaders.filesystem.Loader',
        'django.template.loaders.app_directories.Loader',
    )),
)

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.core.context_processors.debug',
    'django.core.context_processors.request',
    'django.contrib.auth.context_processors.auth',
    'django.contrib.messages.context_processors.messages',
    'django_mobile.context_processors.flavour',
)

Very strange πŸ˜”

from django-mobile.

arnaudblois avatar arnaudblois commented on June 30, 2024

Following your post, I built Python 3.4.3 from source and installed Django 1.8.1 on a fresh virtual environment. For some reason, this seems to have solved the issue, was very strange indeed !
Many thanks again for your help Sinkler

from django-mobile.

Sinkler avatar Sinkler commented on June 30, 2024

You are welcome

from django-mobile.

gregmuellegger avatar gregmuellegger commented on June 30, 2024

Fixed with the merge #56. I just released 0.5.0 which contains these changes: https://pypi.python.org/pypi/django-mobile/

from django-mobile.

lechatpito avatar lechatpito commented on June 30, 2024

Hi

I can't get the CacheLoader working since I've upgraded to Django 1.8.
I am using v0.5.1 and I get this error:
TypeError at / __init__() takes exactly 3 arguments (2 given)

Here is my config. I have tried different ordering, using array or tuples for the loaders section but no luck so far.

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            root("templates"),
            root("beta_registration/templates"),
            root("sociologin/templates/plain/sociologin")
        ],
        'OPTIONS': {
            'context_processors': [
                "django.contrib.auth.context_processors.auth",
                "beta_registration.context_processors.beta_main_proc",
                "django.contrib.messages.context_processors.messages",
                "django.template.context_processors.i18n",
                "zinnia.context_processors.version",
                "django.template.context_processors.request",
                "django_mobile.context_processors.flavour",
            ],
            'loaders': (
                'django_mobile.loader.CachedLoader',
                ('django_mobile.loader.Loader',
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader',))
        },
    },
]

MIDDLEWARE_CLASSES = (
    'django.middleware.cache.UpdateCacheMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django_mobile.middleware.MobileDetectionMiddleware',
    'django_mobile.middleware.SetFlavourMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'beta_registration.middleware.RemoveMessages',
    'django.contrib.messages.middleware.MessageMiddleware',
    'share.middleware.ShortUrlMiddleware',
    'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'security.middleware.ContentSecurityPolicyMiddleware',
    'django_mobile.cache.middleware.CacheFlavourMiddleware',
    'django.middleware.cache.FetchFromCacheMiddleware',
)

Thanks for your help

from django-mobile.

lechatpito avatar lechatpito commented on June 30, 2024

I solved the problem, the loaders section had to be a tuple inside an array:

'loaders': [(
                'django_mobile.loader.CachedLoader',
                ('django_mobile.loader.Loader',
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader',))]

It could be good to update the documentation on cache with the Django 1.8 templates API.

from django-mobile.

gregmuellegger avatar gregmuellegger commented on June 30, 2024

Thanks for clarifying what the solution is. I would be super happy for a PR on this πŸ˜ƒ The doc change should be straightforward.

from django-mobile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.