Run the following command
$ update-locale LC_ALL="en_US.UTF-8"
If it failed, you will need to add the following to /var/lib/locales/supported.d/local file
en_US.UTF-8 UTF-8
1:20 PM <collinanderson> i had one really, really crazy idea that i almost posted on the thread back in the day. why no just have a _meta.fields that _is_ an OrderedDict of _all_ (non related object?) fields. it would be name -> field_instance | |
1:21 PM <collinanderson> that way you don't even need .get_field() (singular). you just say _meta.fields['field_name'] | |
1:21 PM <collinanderson> though you would likely do a lot of iterating over _meta.fields.values() | |
1:22 PM <collinanderson> that way it would preserve the order |
#!/usr/bin/env python | |
import os | |
import site | |
import sys | |
sys.dont_write_bytecode = True # don't write .pyc files | |
sys.argv[0] = os.path.abspath(__file__) # show full path in ps and top | |
sys.path.append(os.path.dirname(__file__)) | |
site.addsitedir('/path/to/virtenv/lib/python2.7/site-packages') | |
os.environ['DJANGO_SETTINGS_MODULE'] = 'demo.settings' |
def serialize_object(obj): | |
args = [] | |
for field in obj._meta.fields: | |
value = field.value_from_object(obj) | |
if value and value != field.default: | |
from decimal import Decimal | |
if isinstance(value, unicode): | |
try: | |
value = str(value) | |
except UnicodeEncodeError: |
#!/usr/bin/env python | |
from django.db.models.aggregates import Aggregate | |
from django.db.models.sql.aggregates import Aggregate as SqlAggregate | |
from django.db.models.sql.query import Query | |
class SqlGetter(SqlAggregate): | |
sql_function = '' | |
class SqlQuery(Query): |