优化所有提交页面的翻页显示

This commit is contained in:
virusdefender
2016-05-30 14:35:16 +08:00
parent 3b6cbc51a1
commit df4db5141f
7 changed files with 61 additions and 28 deletions

View File

@@ -110,4 +110,18 @@ def paginate(request, query_set, object_serializer=None):
def rand_str(length=32):
if length > 128:
raise ValueError("length must <= 128")
return hashlib.sha512(os.urandom(128)).hexdigest()[0:length]
return hashlib.sha512(os.urandom(128)).hexdigest()[0:length]
def build_query_string(kv_data, ignore_none=True):
# {"a": 1, "b": "test"} -> "?a=1&b=test"
query_string = ""
for k, v in kv_data.iteritems():
if ignore_none is True and kv_data[k] is None:
continue
if query_string != "":
query_string += "&"
else:
query_string = "?"
query_string += (k + "=" + str(v))
return query_string