- 浏览: 12020 次
- 性别:
- 来自: 浙江
最新评论
文章列表
from django.core.urlresolvers import reverse, NoReverseMatch
from django.newforms import HiddenInput, TextInput
from django.utils import simplejson
from django.utils.safestring import mark_safe
class AutocompleteWidget(TextInput):
"""
Autocomplete widget to use with j ...
根据不同的用户显示不同的语言
- 博客分类:
- python
class LocaleMiddleware(object):
def get_language_forr_user(self,request):
if request.user.is_authenticated():
try:
account = Account.objects.get(user=request.user)
return account.language
except:
pass
...
1。context[-1].['somevalue']= samevalue
2.使用content processor
from django.db import models
from django.db.models.query import QuerySet
class ChildQuerySet(QuerySet):
def iterator(self):
for obj in super(ChildQuerySet, self).iterator():
yield obj.get_child_object()
class ChildManager(models.Manager):
def get_query_set ...
def _parseJSON(self, obj):
newobj = {}
for key, value in obj.iteritems():
key = str(key)
if isinstance(value, dict):
newobj[key] = self._parseJSON(value)
elif isinstance(value, list):
...
class TimeoutException(Exception):
pass
ThreadStop = Thread._Thread__stop#获取私有函数
def timelimited(timeout):
def decorator(function):
def decorator2(*args,**kwargs):
class TimeLimited(Thread):
def __init__(self,_error= None,):
...