Я на самом деле хотел иметь отдельный шаблон для мобильных и настольных компьютеров, в настоящее время использующий django 2.1.7
перед следующей ошибкой
system check identified no issues (0 silenced).
April 06, 2019 - 18:42:59
Django version 2.1.7, using settings 'project_x.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f64bd6c8ae8>
Traceback (most recent call last):
File "/home/kanishk/newhostA/testhostA/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/home/kanishk/newhostA/testhostA/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 137, in inner_run
handler = self.get_handler(*args, **options)
File "/home/kanishk/newhostA/testhostA/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 27, in get_handler
handler = super().get_handler(*args, **options)
File "/home/kanishk/newhostA/testhostA/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 64, in get_handler
return get_internal_wsgi_application()
File "/home/kanishk/newhostA/testhostA/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 45, in get_internal_wsgi_application
return import_string(app_path)
File "/home/kanishk/newhostA/testhostA/lib/python3.6/site-packages/django/utils/module_loading.py", line 17, in import_string
module = import_module(module_path)
File "/home/kanishk/newhostA/testhostA/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/kanishk/Downloads/project_newstart-master/project_offer/project_x/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/home/kanishk/newhostA/testhostA/lib/python3.6/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
return WSGIHandler()
File "/home/kanishk/newhostA/testhostA/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 136, in __init__
self.load_middleware()
File "/home/kanishk/newhostA/testhostA/lib/python3.6/site-packages/django/core/handlers/base.py", line 36, in load_middleware
mw_instance = middleware(handler)
TypeError: object() takes no parameters
middleware.py
from django.conf import settings
class MobileTemplatesMiddleware(object):
def __init__(self,get_response):
self.get_response = get_response
"""Determines which set of templates to use for a mobile site"""
def __call__(self, request):
# sets are used here, you can use other logic if you have an older version of Python
MOBILE_SUBDOMAINS = set(['m', 'mobile'])
domain = set(request.META.get('HTTP_HOST', '').split('.'))
if request.flavour=='mobile':
settings.TEMPLATE_DIRS = settings.MOBILE_TEMPLATE_DIRS
else:
settings.TEMPLATE_DIRS = settings.DESKTOP_TEMPLATE_DIRS
response = self.get_response(request)
return response
Я следил https://github.com/gregmuellegger/django-mobile
и Django WebApp для мобильных и настольных ПК этот ответ