Comments (14)
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.
Hi, please check #56
from django-mobile.
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.
Ursidours, can you copy a full traceback?
from django-mobile.
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
File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/debug_panel/middleware.py" in process_responseresponse = middleware_method(request, response)
File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/debug_toolbar/middleware.py" in process_responseresponse = super(DebugPanelMiddleware, self).process_response(request, response)
File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/debug_toolbar/toolbar.py" in render_toolbarbits[-2] += toolbar.render_toolbar()
File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/template/loader.py" in render_to_stringreturn 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 get_templatetemplate = get_template(template_name, using=using)
File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/template/backends/django.py" in get_templatereturn engine.get_template(template_name, dirs)
File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/template/engine.py" in get_templatereturn 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 find_templatetemplate, origin = self.find_template(template_name, dirs)
File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/utils/functional.py" in getfor loader in self.template_loaders:
File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/template/engine.py" in template_loadersres = instance.**dict**[self.name] = self.func(instance)
File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/template/engine.py" in get_template_loadersreturn self.get_template_loaders(self.loaders)
File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/template/engine.py" in find_template_loaderloader = self.find_template_loader(template_loader)
File "/home/ursi/workspace/New_App/virtual/lib64/python3.4/site-packages/django/utils/module_loading.py" in import_stringloader_class = import_string(loader)
File "/usr/local/opt/python-3.4.2/lib/python3.4/importlib/init.py" in import_modulemodule = import_module(module_path)
return _bootstrap._gcd_import(name[level:], package, level)
Exception Type: SyntaxError at /
Exception Value: invalid syntax (loader.py, line 17)
from django-mobile.
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.
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.
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.
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.
You are welcome
from django-mobile.
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.
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.
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.
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)
- self.request.flavour not work in view
- Ubuntu doesn't like the "ΓΌ" in __init__.py HOT 6
- No option to provide empty exceptions HOT 1
- CachedLoader is broken on Django 1.7 HOT 4
- Withdrawn
- Template name for Class Based View. HOT 1
- no flavour cookie HOT 7
- cause a 500 error when set DEBUG=True
- Skip mobile detection after flavour is saved permanently HOT 3
- Adding smart watch flavour ? HOT 4
- Got 'django.template.loader_tags.ExtendsError' when customizing admin interface in Django 1.9 HOT 2
- Over time, more desktops are detecting as "mobile"... HOT 6
- iPad not detected as mobile HOT 2
- Django 1.10 incompatibility HOT 7
- CachedLoader breaks application HOT 4
- Django 1.10 support HOT 1
- How to disable mobile detection
- Is still alive the project? HOT 4
- Django mobile
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-mobile.