当前位置: 首页>>代码示例>>Python>>正文


Python Location.marker方法代码示例

本文整理汇总了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))
开发者ID:e-Luminate,项目名称:eluminate_web,代码行数:37,代码来源:views.py


注:本文中的models.Location.marker方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。