本文整理匯總了Python中models.Config.save方法的典型用法代碼示例。如果您正苦於以下問題:Python Config.save方法的具體用法?Python Config.save怎麽用?Python Config.save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Config
的用法示例。
在下文中一共展示了Config.save方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_default_configs
# 需要導入模塊: from models import Config [as 別名]
# 或者: from models.Config import save [as 別名]
def create_default_configs(request, user, is_new, **kwargs):
if is_new:
cf = Config()
cf.name = "Default config"
cf.user = user
cf.sv_motd = 'Standard capture the flag game'
cf.save()
示例2: register
# 需要導入模塊: from models import Config [as 別名]
# 或者: from models.Config import save [as 別名]
def register(request):
if request.method == "GET":
template = get_template('registration/register.html')
context = RequestContext(request, {})
return HttpResponse(template.render(context))
elif request.method == "POST":
username = strip_tags(request.POST.get('username'))
password = make_password(request.POST.get('password'))
title = "Pagina de " + username
user = User(username=username, password=password)
user.save()
user = User.objects.get(username=username)
config = Config(user=user, title=title, color='#D7C4B7', size=14)
config.save()
return HttpResponseRedirect("/")
else:
template = get_template('notfound.html')
return HttpResponseNotFound(template.render())