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


Python urlresolvers.reverse方法代码示例

本文整理汇总了Python中django.core.urlresolvers.reverse方法的典型用法代码示例。如果您正苦于以下问题:Python urlresolvers.reverse方法的具体用法?Python urlresolvers.reverse怎么用?Python urlresolvers.reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.core.urlresolvers的用法示例。


在下文中一共展示了urlresolvers.reverse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: close

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse [as 别名]
def close(request, pk):
    """Close this Service Order."""
    order = get_object_or_404(Order, pk=pk)

    if request.method == 'POST':
        try:
            order.close(request.user)
        except Exception as e:
            messages.error(request, e)
            return redirect(order)

        if request.session.get("current_order_id"):
            del(request.session['current_order_id'])
            del(request.session['current_order_code'])
            del(request.session['current_order_customer'])

        messages.success(request, _('Order %s closed') % order.code)

        return redirect(order)

    data = {'order': order, 'action': reverse(close, args=[pk])}
    return render(request, "orders/close.html", data) 
开发者ID:fpsw,项目名称:Servo,代码行数:24,代码来源:order.py

示例2: accessories

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse [as 别名]
def accessories(request, pk, device_id):
    from django.utils import safestring

    if request.POST.get('name'):
        a = Accessory(name=request.POST['name'])
        a.order_id = pk
        a.device_id = device_id
        a.save()

    choice_list = []
    choices = Accessory.objects.distinct('name')

    for c in choices:
        choice_list.append(c.name)

    action = reverse('orders-accessories', args=[pk, device_id])
    selected = Accessory.objects.filter(order_id=pk, device_id=device_id)
    choices_json = safestring.mark_safe(json.dumps(choice_list))

    return render(request, 'devices/accessories_edit.html', locals()) 
开发者ID:fpsw,项目名称:Servo,代码行数:22,代码来源:order.py

示例3: __init__

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse [as 别名]
def __init__(self, *args, **kwargs):
        super(NoteForm, self).__init__(*args, **kwargs)
        note = kwargs['instance']
        self.fields['sender'] = forms.ChoiceField(
            label=_('From'),
            choices=note.get_sender_choices(),
            widget=forms.Select(attrs={'class': 'span12'})
        )

        self.fields['body'].widget = AutocompleteTextarea(
            rows=20,
            choices=Template.templates()
        )

        if note.order:
            url = reverse('notes-render_template', args=[note.order.pk])
            self.fields['body'].widget.attrs['data-url'] = url 
开发者ID:fpsw,项目名称:Servo,代码行数:19,代码来源:notes.py

示例4: site_login

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse [as 别名]
def site_login(request):
    """
    Logs in current user
    :param request:
    :return render:
    """
    if request.method == "POST":
        user = None
        user_login = request.POST['login']
        user_password = request.POST['password']
        print("Login tryout by "+user_login)
        if user_login != "" and user_password != "":
            user = authenticate(username=user_login, password=user_password)
        if user is not None:
            login(request, user)
            return HttpResponseRedirect(reverse('public_gate:home'))
        else:
            # User.objects.create_user(user_login, '', user_password).save()
            return render(request, 'public_gate/home.html', {"error_message": "Wrong login/password combination"})
    return render(request, 'public_gate/home.html', {"error_message": "One or more fields are empty"}) 
开发者ID:OpenMDM,项目名称:OpenMDM,代码行数:22,代码来源:views.py

示例5: hijack_field

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse [as 别名]
def hijack_field(self, obj):
        hijack_attributes = hijack_settings.HIJACK_URL_ALLOWED_ATTRIBUTES

        if 'user_id' in hijack_attributes:
            hijack_url = reverse('hijack:login_with_id', args=(obj.pk, ))
        elif 'email' in hijack_attributes:
            hijack_url = reverse('hijack:login_with_email', args=(obj.email, ))
        else:
            hijack_url = reverse('hijack:login_with_username', args=(obj.username, ))

        button_template = get_template(hijack_admin_settings.HIJACK_BUTTON_TEMPLATE)
        button_context = {
            'hijack_url': hijack_url,
            'username': str(obj),
        }

        return button_template.render(button_context) 
开发者ID:arteria,项目名称:django-hijack-admin,代码行数:19,代码来源:admin.py

示例6: item_link

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse [as 别名]
def item_link(self, job):
        return reverse('job-show', args=[job.pk]) 
开发者ID:kimeraapp,项目名称:pythonjobs.ie,代码行数:4,代码来源:views.py

示例7: get_absolute_url

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse [as 别名]
def get_absolute_url(self):
        return reverse('job-show', args=[str(self.id)]) 
开发者ID:kimeraapp,项目名称:pythonjobs.ie,代码行数:4,代码来源:models.py

示例8: test_index_returns_200

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse [as 别名]
def test_index_returns_200(self):
        response = self.client.get(reverse("job-home"))
        self.assertEquals(response.status_code, 200) 
开发者ID:kimeraapp,项目名称:pythonjobs.ie,代码行数:5,代码来源:test_views.py

示例9: test_index_list_active_jobs

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse [as 别名]
def test_index_list_active_jobs(self):
        mommy.make(Job, status=0)
        response = self.client.get(reverse("job-home"))
        self.assertEquals(len(response.context["jobs"]), 1) 
开发者ID:kimeraapp,项目名称:pythonjobs.ie,代码行数:6,代码来源:test_views.py

示例10: test_show_returns_200

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse [as 别名]
def test_show_returns_200(self):
        response = self.client.get(reverse("job-show", args=[self.job.pk]))
        self.assertEquals(response.status_code, 200) 
开发者ID:kimeraapp,项目名称:pythonjobs.ie,代码行数:5,代码来源:test_views.py

示例11: test_show_inactive_job_returns_404

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse [as 别名]
def test_show_inactive_job_returns_404(self):
        job = mommy.make(Job, status=0)
        response = self.client.get(reverse("job-show", args=[job.pk]))
        self.assertEquals(response.status_code, 404) 
开发者ID:kimeraapp,项目名称:pythonjobs.ie,代码行数:6,代码来源:test_views.py

示例12: test_new_returns_200

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse [as 别名]
def test_new_returns_200(self):
        response = self.client.get(reverse("job-new"))
        self.assertEquals(response.status_code, 200) 
开发者ID:kimeraapp,项目名称:pythonjobs.ie,代码行数:5,代码来源:test_views.py

示例13: test_new_template

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse [as 别名]
def test_new_template(self):
        response = self.client.get(reverse("job-new"))
        self.assertTemplateUsed(response, "new.html") 
开发者ID:kimeraapp,项目名称:pythonjobs.ie,代码行数:5,代码来源:test_views.py

示例14: test_create_new_job

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse [as 别名]
def test_create_new_job(self):
        self.job.pk = 0
        params = model_to_dict(self.job)
        response = self.client.post(reverse("job-new"), params)
        self.assertEquals(response.status_code, 302) 
开发者ID:kimeraapp,项目名称:pythonjobs.ie,代码行数:7,代码来源:test_views.py

示例15: test_edit_returns_200

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse [as 别名]
def test_edit_returns_200(self):
        response = self.client.get(reverse("job-edit", args=[self.job.token]))
        self.assertEquals(response.status_code, 200) 
开发者ID:kimeraapp,项目名称:pythonjobs.ie,代码行数:5,代码来源:test_views.py


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