Django Python runserver error: Project is using Twilio for surveys - python

I'm currently working on a project that uses Twilio to have an automated survey. I'm trying python manage.py runserver and I get the following results:
System check identified no issues (0 silenced).
April 23, 2017 - 12:15:51
Django version 1.11, using settings 'vizeserver.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x04406FA8
>
Traceback (most recent call last):
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\uti
ls\autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\cor
e\management\commands\runserver.py", line 147, in inner_run
handler = self.get_handler(*args, **options)
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\con
trib\staticfiles\management\commands\runserver.py", line 27, in get_handler
handler = super(Command, self).get_handler(*args, **options)
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\cor
e\management\commands\runserver.py", line 68, in get_handler
return get_internal_wsgi_application()
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\cor
e\servers\basehttp.py", line 47, in get_internal_wsgi_application
return import_string(app_path)
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\uti
ls\module_loading.py", line 20, in import_string
module = import_module(module_path)
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py",
line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "C:\Users\Thomas\Documents\Development\TwilioSurvey\vizeserver\vizeserver\wsgi.py", lin
e 16, in <module>
application = get_wsgi_application()
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\cor
e\wsgi.py", line 14, in get_wsgi_application
return WSGIHandler()
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\handlers\wsgi.py", line 151, in __init__
self.load_middleware()
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\handlers\base.py", line 82, in load_middleware
mw_instance = middleware(handler)
TypeError: object() takes no parameters
I have looked into my vizeserver.settings and I don't see anything off.
The link for the github is https://github.com/Vize-Programming-Team/web-server. I've been trying to see if there is anything wrong with the middleware but I don't know what's wrong.
Thanks!

The problem is with your middleware, try changing your middleware.py in auto_survey to
class SMSMiddleware(object):
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
response = self.get_response(request)
args = request.POST or request.GET
request.is_sms = args and args.get('MessageSid')
return response

Related

Python socketio connection refused by the server

import os
import sys
from django.core.wsgi import get_wsgi_application
import socketio
sio = socketio.Client()
print('Created socketio client')
#sio.event
def connect():
print('connected to server')
#sio.event
def disconnect():
print('disconnected from server')
sio.connect('http://localhost:8000/socket.io/')
sio.wait()
app_path = os.path.abspath(os.path.join(
os.path.dirname(os.path.abspath(__file__)), os.pardir))
sys.path.append(os.path.join(app_path, 'myapp'))
if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production':
from raven.contrib.django.raven_compat.middleware.wsgi import Sentry
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
application = get_wsgi_application()
if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production':
application = application
Here is my wsgi.py file, I am not sure whether to use it here or not. When I start the server it throws
File "C:\Users\prabh\AppData\Local\Programs\Python\Python37\lib\site-packages\socketio\client.py", line 246, in connect
six.raise_from(exceptions.ConnectionError(exc.args[0]), None)
File "<string>", line 3, in raise_from
socketio.exceptions.ConnectionError: Connection refused by the server
Am I missing out something else?
UPDATE 1
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x000001E926004C18>
Traceback (most recent call last):
File "C:\Users\prabh\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\prabh\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 140, in inner_run
handler = self.get_handler(*args, **options)
File "C:\Users\prabh\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\staticfiles\management\commands\runserver.py", line 27, in get_handler
handler = super().get_handler(*args, **options)
File "C:\Users\prabh\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 65, in get_handler
return get_internal_wsgi_application()
File "C:\Users\prabh\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\servers\basehttp.py", line 44, in get_internal_wsgi_application
return import_string(app_path)
File "C:\Users\prabh\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\module_loading.py", line 17, in import_string
module = import_module(module_path)
File "C:\Users\prabh\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "D:\Programming\python\myapp\config\wsgi.py", line 34, in <module>
sio.connect('http://localhost:8000/socket.io/')
File "C:\Users\prabh\AppData\Local\Programs\Python\Python37\lib\site-packages\socketio\client.py", line 246, in connect
six.raise_from(exceptions.ConnectionError(exc.args[0]), None)
File "<string>", line 3, in raise_from
UPDATE 2
socket.on('connect', function() {
console.log('CONNECTED');
socket.emit('on message', 'data');
});

Importing a custom APM processor in a Python FastAPI app

I am using Elasticsearch APM in Python to log requests for a FastAPI app.
There is a mechanism to load custom processors by simply specifying the module path to the custom processor function.
My app layout is as follows:
app
├── __init__.py
├── apm_processors.py
├── main.py
└── version.py
My apm_processors.py file has the following function defined:
def ip_processor(client, event):
# process the event
pass
So, in my app, I do:
# other imports
from elasticapm.contrib.starlette import make_apm_client, ElasticAPM
from . import apm_processors
And to set up APM, I call:
apm_config = {
"SERVICE_NAME": config('ELASTIC_APM_SERVICE_NAME', cast=str, default="Server"),
"SECRET_TOKEN": str(config('ELASTIC_APM_SECRET_TOKEN', cast=Secret, default="")),
"SERVER_URL": config('ELASTIC_APM_SERVER_URL', cast=str, default="http://localhost:8200"),
"PROCESSORS": (
"elasticapm.processors.sanitize_http_request_cookies",
"elasticapm.processors.sanitize_http_headers",
"apm_processors.ip_processor"
)
}
apm = make_apm_client(apm_config)
app = FastAPI()
# other app setup
app.add_middleware(ElasticAPM, client=apm)
This throws an error:
ModuleNotFoundError: No module named 'apm_processors'
With the following stacktrace:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/usr/local/lib/python3.9/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.9/site-packages/uvicorn/subprocess.py", line 76, in subprocess_started
target(sockets=sockets)
File "/usr/local/lib/python3.9/site-packages/uvicorn/server.py", line 60, in run
return asyncio.run(self.serve(sockets=sockets))
File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File "/usr/local/lib/python3.9/site-packages/uvicorn/server.py", line 67, in serve
config.load()
File "/usr/local/lib/python3.9/site-packages/uvicorn/config.py", line 458, in load
self.loaded_app = import_from_string(self.app)
File "/usr/local/lib/python3.9/site-packages/uvicorn/importer.py", line 24, in import_from_string
raise exc from None
File "/usr/local/lib/python3.9/site-packages/uvicorn/importer.py", line 21, in import_from_string
module = importlib.import_module(module_str)
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/home/statisticsserver/./app/main.py", line 75, in <module>
apm = make_apm_client(apm_config)
File "/usr/local/lib/python3.9/site-packages/elasticapm/contrib/starlette/__init__.py", line 70, in make_apm_client
return client_cls(config, **defaults)
File "/usr/local/lib/python3.9/site-packages/elasticapm/base.py", line 153, in __init__
"processors": self.load_processors(),
File "/usr/local/lib/python3.9/site-packages/elasticapm/base.py", line 640, in load_processors
return [seen.setdefault(path, import_string(path)) for path in processors if path not in seen]
File "/usr/local/lib/python3.9/site-packages/elasticapm/base.py", line 640, in <listcomp>
return [seen.setdefault(path, import_string(path)) for path in processors if path not in seen]
File "/usr/local/lib/python3.9/site-packages/elasticapm/utils/module_import.py", line 47, in import_string
module = import_module(module_path)
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'apm_processors'
As far as I can tell it uses import_module to import the function as specified, but for some reason it claims there is no such module — although I am actually able to import it.
How can I specify the processor?
Since the context/main module of the application is app, the import should be done as follows:
"PROCESSORS": (
"elasticapm.processors.sanitize_http_request_cookies",
"elasticapm.processors.sanitize_http_headers",
"app.apm_processors.ip_processor"
)
This way, the import succeeds and the function will be called for each event.

"Apps aren't loaded yet" when import model to a file run by manage.py

I want to get cryptocurrency data from external websocket and save it to database. In order to run producer.py from start, I added it to INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
'crypto.spot.producer',
]
producer.py is:
from .models import Spot
async def message(u, t, interval, timeout):
async with websockets.connect(uri=u + '?token=' + t, ping_interval=interval, ping_timeout=timeout) as websocket:
await websocket.send(json.dumps({"id": "4848226",
"type": "subscribe",
"topic": "/market/ticker:all",
"response": True}))
while True:
response = await websocket.recv()
result = json.loads(response)
'''
write result to django model (Spot)
'''
while True:
response = r.post('https://api.kucoin.com/api/v1/bullet-public')
payload = json.loads(response.text)
uri = payload['data']['instanceServers'][0]['endpoint']
token = payload['data']['token']
ping_interval = payload['data']['instanceServers'][0]['pingInterval']
ping_timeout = payload['data']['instanceServers'][0]['pingTimeout']
asyncio.get_event_loop().run_until_complete(message(uri, token, ping_interval, ping_timeout))
asyncio.get_event_loop().run_forever()
However, I get the following error:
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\a.daghestani\Desktop\marlikfund\crypto\spot\producer.py", line 9, in <module>
from .models import Spot
File "C:\Users\a.daghestani\Desktop\marlikfund\crypto\spot\models.py", line 6, in <module>
class Spot(models.Model):
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\base.py", line 107, in __new__
app_config = apps.get_containing_app_config(module)
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 252, in get_containing_app_config
self.check_apps_ready()
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 135, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
any idea?
You getting this error because you can not access models before django loading is finished. Your module tries to access models while they are not loaded yet.
To solve your problem you should create a django management command or an standalone script which loads and configures django, after that you can run your producer loop and access models without any problem. e.g.
producer.py modeuls:
import sys, os, django
sys.path.append("/path/to/your/project")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "your-project.settings")
django.setup()
from <your-app>.models import Spot
.... Your script
Don't forget to remove the module (crypto.spot.producer) from INSTALLED_APPS.

'tuple' object is not callable , machine learning API using Django API

I am trying build a machine learning API using DJANGO rest framework API. After creating a project and configuring model.py of created project 'MyAPI' ,for required approvals. And used the following commend to run the server, got following error.
how to fix them ?, Please guide me.
````C:\Users\Padmini\DjangoAPI>python manage.py runserver```
error
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\Padmini\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\Padmini\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Padmini\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\Padmini\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\Padmini\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "C:\Users\Padmini\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\Padmini\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\Padmini\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Padmini\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\Users\Padmini\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\Padmini\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Padmini\DjangoAPI\MyAPI\models.py", line 4, in <module>
class approvals(models.Model):
File "C:\Users\Padmini\DjangoAPI\MyAPI\models.py", line 7, in approvals
('Female','Female')
TypeError: 'tuple' object is not callable````
my model.py as following code
from django.db import models
# Create your models here.
class approvals(models.Model):
GENDER_CHOICES= (
('Male', 'Male')
('Female','Female')
)
MARRIED_CHOICES=(
('Yes','Yes'),
('No','No')
)
GRADUATED_CHOICES= (
('Graduate','Graduated'),
('Not_Graduate','Not_Graduate')
)
SELFEMPLOYED_CHOICES=(
('Yes','Yes'),
('No','No')
)
PROPERTY_CHOICES=(
('Rural','Rural'),
('Semiurban','Semiurban'),
('Urban','Urban')
)
firstname=models.CharField(max_length=15)
lastname=models.CharField(max_length=15)
dependants=models.IntegerField(default=0)
applicantincome=models.IntegerField(default=0)
coapplicatincome=models.IntegerField(default=0)
loanamt=models.IntegerField(default=0)
loanterm=models.IntegerField(default=0)
credithistory=models.IntegerField(default=0)
gender=models.CharField(max_length=15, choices=GENDER_CHOICES)
married=models.CharField(max_length=15, choices=MARRIED_CHOICES)
graduatededucation=models.CharField(max_length=15, choices=GRADUATED_CHOICES)
selfemployed=models.CharField(max_length=15, choices=SELFEMPLOYED_CHOICES)
area=models.CharField(max_length=15, choices=PROPERTY_CHOICES)
def __str__(self):
return '{}, {}'.format(self.lastname, self.firstname)`````

migrating to Django 1.11 django-hvad error

I'm new to Django. Trying to migrate from django==1.8.5 to 1.11
django-hvad package is essential for me, however, when upgraded to django==1.10, it throws the assertion error about the Django version.
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f407d733b70>
Traceback (most recent call last):
File "/home/riddle/pro/blog/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/riddle/pro/blog/env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 113, in inner_run
autoreload.raise_last_exception()
File "/home/riddle/pro/blog/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "/home/riddle/pro/blog/env/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/riddle/pro/blog/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/riddle/pro/blog/env/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/riddle/pro/blog/env/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/riddle/pro/blog/env/lib/python3.6/site-packages/django/apps/config.py", line 199, in import_models
self.models_module = import_module(models_module_name)
File "/home/riddle/pro/blog/env/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/riddle/pro/blog/app/apps/frontend/website/models.py", line 116, in <module>
class ContentBlock(Common, TranslatableModel, OrderedModel):
File "/home/riddle/pro/blog/env/lib/python3.6/site-packages/django/db/models/base.py", line 309, in __new__
new_class._prepare()
File "/home/riddle/pro/blog/env/lib/python3.6/site-packages/django/db/models/base.py", line 359, in _prepare
signals.class_prepared.send(sender=cls)
File "/home/riddle/pro/blog/env/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 191, in send
response = receiver(signal=self, sender=sender, **named)
File "/home/riddle/pro/blog/env/lib/python3.6/site-packages/hvad/models.py", line 447, in prepare_translatable_model
assert django.VERSION < (1, 10)
AssertionError
My project is actually a single-page website, so it is not a big hassle to remove django-hvad and use something else. That is my question therefore, what steps are better to take:
(1) try to use another "app" for model translation, as in:
https://djangopackages.org/grids/g/model-translation/
(however, as I see, only one package supports Django1.10 there).
(2) Or maybe Django has a native model translation option which I should use.
(3) another option
The strange thing also is that https://django-hvad.readthedocs.io/en/latest/index.html indicates that django1.9 is the last supported version, but in GitHub page https://github.com/kristianoellegaard/django-hvad it is written that django 1.10 as well as django 1.11 are supported.
Please indicate what more information is needed, I will try to provide.
My pip freeze output:
Django==1.10
django-appconf==1.0.2
django-compressor==2.2
django-filebrowser-no-grappelli==3.7.4
django-geoposition==0.3.0
django-hvad==1.8.0
django-jquery==3.1.0
django-libsass==0.7
django-ordered-model==1.4.3
django-tinymce==2.7.0
libsass==0.14.2
Pillow==5.1.0
psycopg2-binary==2.7.4
pytz==2018.3
rcssmin==1.0.6
rjsmin==1.0.12
six==1.11.0
Usage of django-hvad (example):
from hvad.models import TranslatableModel, TranslatedFields
class SliderBox(TranslatableModel, OrderedModel):
translations = TranslatedFields(
image = FileBrowseField(
"Image",
max_length=200,
directory="uploads/",
extensions=[".png", ".jpg"],
blank=True,
null=True
),
text = models.CharField(max_length=200),
)

Categories

Resources