suor / handy Goto Github PK
View Code? Open in Web Editor NEWHandy django tools
License: BSD 3-Clause "New" or "Revised" License
Handy django tools
License: BSD 3-Clause "New" or "Revised" License
Why there is text/plain content type for decorators.render_to_json? JSON response should have application/json type to determine automatically on client side (e.g. with jQuery.ajax)
/src/handy/handy/models/fields.py:25:
DeprecationWarning: A Field class whose get_db_prep_value method hasn't been updated to take `connection` and `prepared` arguments.
class AdditionalAutoField(models.Field):
/src/handy/handy/models/fields.py:238:
DeprecationWarning: A Field class whose db_type method hasn't been updated to take a `connection` argument.
class BigIntegerField(models.IntegerField):
In decorators.py
import simplejson as json
Why don't simply import simplejson from django utils as environments may not have simplejson installed (as mine one) and use simplejson bundled with django:
from django.utils import simplejson as json
После pip install handy==0.1.2
получил следующее в системе:
$ find /home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/ajax.pyc
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/db.py
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/__init__.pyc
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/logger.py
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/text.py
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/funcs.pyc
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/decorators.py
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/funcs.py
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/mail.py
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/db.pyc
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/utils.py
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/middleware.py
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/decorators.pyc
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/logger.pyc
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/mail.pyc
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/__init__.py
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/text.pyc
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/ajax.py
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/utils.pyc
/home/nuklea/.virtualenvs/nazya/lib/python2.7/site-packages/handy/middleware.pyc
Отсутствуют многие файлы.
It seems that handy
doesn't support Django 1.9. If I try to use the package I get the following error:
Traceback (most recent call last):
File "runtests.py", line 37, in <module>
runtests(*sys.argv[1:])
File "runtests.py", line 24, in runtests
django.setup()
File "/home/gregor/projects/oTree/otree-core/.tox/py2.7-django1.9-unittest/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/gregor/projects/oTree/otree-core/.tox/py2.7-django1.9-unittest/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/gregor/projects/oTree/otree-core/.tox/py2.7-django1.9-unittest/lib/python2.7/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/gregor/projects/oTree/otree-core/otree/apps.py", line 11, in <module>
from otree.models_concrete import StubModel
File "/home/gregor/projects/oTree/otree-core/otree/models_concrete.py", line 1, in <module>
from otree.db import models
File "/home/gregor/projects/oTree/otree-core/otree/db/models.py", line 13, in <module>
from handy.models import JSONField, PickleField
File "/home/gregor/projects/oTree/otree-core/.tox/py2.7-django1.9-unittest/lib/python2.7/site-packages/handy/models/__init__.py", line 1, in <module>
from .fields import *
File "/home/gregor/projects/oTree/otree-core/.tox/py2.7-django1.9-unittest/lib/python2.7/site-packages/handy/models/fields.py", line 17, in <module>
from handy.utils import get_module_attr
File "/home/gregor/projects/oTree/otree-core/.tox/py2.7-django1.9-unittest/lib/python2.7/site-packages/handy/utils.py", line 10, in <module>
from django.db.models.sql.where import Constraint
ImportError: cannot import name Constraint
Is there any chance that Django 1.9 will be supported in the future?
In addition to @ajax.login_required
Currently @ajax
and render_to_json
uses two different json encoders, one that uses a very old datetime format (the @Ajax one) and another one that uses datetime isoformat (which should be fine to meet current javascript date formatting).
Would be great to have all json serialization code to use the same encoder, and even better, use the django one (DjangoJSONEncoder) that's already implemented to handle all non standard data types.
Because of this https://github.com/Suor/handy/blob/master/handy/models/fields.py#L263 hack, i can't override widget for JSONField in ordinary way.
https://github.com/Suor/handy/blob/master/handy/mail.py#L45
That line won't work properly since render_to_string signature was updated, it should instead pass the request as the third parameter and a an empty dict as a context, currently it will make any context processor that relies on it to fail/crash since it is expecting a request object.
При сохранении русских символов, получаю ошибку
'ascii' codec can't decode byte 0xd1 in position 0: ordinal not in range(128). You passed in <django.forms.forms.BoundField object at 0x7f0e77a2f290> (<class 'django.forms.forms.BoundField'>)
Request Method: GET
Request URL: http://local.nazya.com:8000/admin/base/patternreplacement/3/
Django Version: 1.4.2
Exception Type: DjangoUnicodeDecodeError
Exception Value:
'ascii' codec can't decode byte 0xd1 in position 0: ordinal not in range(128). You passed in <django.forms.forms.BoundField object at 0x7f0e77a2f290> (<class 'django.forms.forms.BoundField'>)
Exception Location: /home/nikolay/env/nazya-env/local/lib/python2.7/site-packages/django/utils/encoding.py in force_unicode, line 93
Python Executable: /home/nikolay/env/nazya-env/bin/python
Python Version: 2.7.3
Python Path:
['/home/nikolay/env/nazya-env/local/lib/python2.7/site-packages/requests/packages',
'/home/nikolay/PycharmProjects/nazya/apps',
'/home/nikolay/PycharmProjects/nazya/libs',
'/home/nikolay/PycharmProjects/nazya',
'/home/nikolay/PycharmProjects/nazya',
'/home/nikolay/pycharm-2.6.3/helpers/pydev',
'/home/nikolay/env/nazya-env/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
'/home/nikolay/env/nazya-env/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg',
'/home/nikolay/env/nazya-env/local/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg',
'/home/nikolay/env/nazya-env/src/django-mptt',
'/home/nikolay/env/nazya-env/src/coffin',
'/home/nikolay/env/nazya-env/src/django-pure-pagination',
'/home/nikolay/env/nazya-env/src/django-autocomplete',
'/home/nikolay/env/nazya-env/src/django-debug-toolbar',
'/home/nikolay/env/nazya-env/src/django-piston',
'/home/nikolay/env/nazya-env/local/lib/python2.7/site-packages/mercurial_keyring-0.5.3-py2.7.egg',
'/home/nikolay/env/nazya-env/local/lib/python2.7/site-packages/keyring-0.9.2-py2.7.egg',
'/home/nikolay/env/nazya-env/lib/python2.7',
'/home/nikolay/env/nazya-env/lib/python2.7/plat-linux2',
'/home/nikolay/env/nazya-env/lib/python2.7/lib-tk',
'/home/nikolay/env/nazya-env/lib/python2.7/lib-old',
'/home/nikolay/env/nazya-env/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/home/nikolay/env/nazya-env/local/lib/python2.7/site-packages',
'/home/nikolay/env/nazya-env/local/lib/python2.7/site-packages/PIL']
Server time: Птн, 14 Дек 2012 11:17:06 +0100
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.