本文整理汇总了Python中models.Location.marker方法的典型用法代码示例。如果您正苦于以下问题:Python Location.marker方法的具体用法?Python Location.marker怎么用?Python Location.marker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Location
的用法示例。
在下文中一共展示了Location.marker方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add
# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import marker [as 别名]
def add(request, form_class=AddLocationForm, template='maps/add_location.html'):
center_obj = DEFAULT_CENTER_OBJ
if request.method == 'POST': # If the form has been submitted...
form = form_class(request.user, request.POST)
if form.is_valid():
location = form.save(commit=False)
location.user = request.user
location.save()
msg = _("%(name)s has been saved.") %{'name': location.name}
messages.add_message(request, messages.SUCCESS, msg)
if request.session.has_key('next'):
redirect_url = request.session.get('next')
return HttpResponseRedirect(redirect_url)
return HttpResponseRedirect(reverse('locations_list'))
else:
# We re-pass the default location if the form is not valid
location = Location()
location.marker = Point(DEFAULT_CENTER_OBJ['x'], DEFAULT_CENTER_OBJ['y'])
else:
# A dynamically loaded form
location = Location()
location.marker = Point(DEFAULT_CENTER_OBJ['x'], DEFAULT_CENTER_OBJ['y'])
form = form_class(initial={'user' : request.user,
'marker' : location.marker})
if request.GET.has_key('next'):
request.session['next'] = request.GET['next']
return render_to_response(template,
{ "form": form,
"location": location,
},
context_instance=RequestContext(request))