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


Python urlresolvers.reverse_lazy方法代码示例

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


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

示例1: send_email

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse_lazy [as 别名]
def send_email(self, regenerate=False):
        if not self.verification_code or regenerate:
            self.generate_token()

        context = dict(
            verification_code=self.verification_code,
            first_name=self.owner.first_name,
            accounts_reset_password_link='http://%s%s' % (
                get_current_site().domain,
                reverse_lazy('accounts_reset_password', args=(self.id,))
            )
        )
        email(
            recipient=[self.owner.email],
            context=context,
            template_name='password_reset'
        ) 
开发者ID:pixlie,项目名称:oxidizr,代码行数:19,代码来源:models.py

示例2: index

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse_lazy [as 别名]
def index(request):
    if not user_model.objects.filter(is_staff=True).exists():
        return HttpResponseRedirect(reverse_lazy('welcome_staff'))
    content = Content.objects.published().order_by('published_at').first()
    random_book = Book.objects.available().order_by('?').first()
    random_doc = Document.objects.order_by('?').first()

    staff_cards = settings.STAFF_HOME_CARDS
    builtin_cards = build_builtin_card_info()
    extra_cards = build_extra_app_card_info()
    custom_cards = settings.CUSTOM_CARDS
    package_cards = build_package_card_info()

    cards = (
        staff_cards + builtin_cards + extra_cards + custom_cards +
        package_cards)

    context = {
        'blog_content': content,
        'random_book': random_book,
        'random_doc': random_doc,
        'cards': cards,
    }
    return render(request, 'index.html', context) 
开发者ID:ideascube,项目名称:ideascube,代码行数:26,代码来源:views.py

示例3: test_post_checkout

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse_lazy [as 别名]
def test_post_checkout(self):
        """
        Test correctly posting to the checkout view
        """
        country = CountryFactory()
        request = RequestFactory().post(
            reverse_lazy('longclaw_checkout_view'),
            {
                'shipping-name': 'bob',
                'shipping-line_1': 'blah blah',
                'shipping-postcode': 'ytxx 23x',
                'shipping-city': 'London',
                'shipping-country': country.pk,
                'email': 'test@test.com'
            }
        )
        request.session = {}
        bid = basket_id(request)
        BasketItemFactory(basket_id=bid)
        response = CheckoutView.as_view()(request)
        self.assertEqual(response.status_code, 302) 
开发者ID:JamesRamm,项目名称:longclaw,代码行数:23,代码来源:tests.py

示例4: get

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse_lazy [as 别名]
def get(self, request, *args, **kwargs):
        """ Makes a clone within the current mission of a specified test case """

        # Verify the test case passed is an int and within the path's mission
        id_to_clone = int(self.kwargs['pk'])
        passed_mission_id = int(self.kwargs['mission'])

        try:
            test_case = TestDetail.objects.get(pk=id_to_clone)
        except TestDetail.DoesNotExist:
            return HttpResponse("Test case not found.", status=404)

        if test_case.mission.id != passed_mission_id:
            return HttpResponse("Test case not linked to specified mission.", status=400)

        test_case.pk = None
        test_case.test_case_status = 'NEW'
        test_case.save()

        return HttpResponse(reverse_lazy('mission-test-edit',
                            kwargs={'mission': test_case.mission.id, 'pk': test_case.pk})) 
开发者ID:lmco,项目名称:dart,代码行数:23,代码来源:views.py

示例5: get_form_kwargs

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse_lazy [as 别名]
def get_form_kwargs(self, *args, **kwargs):
        form_kwargs = super().get_form_kwargs(*args, **kwargs)
        try:
            user_id = self.request.session['password_reset_id']
            user = User.objects.get(id=user_id)
            form_kwargs['user'] = user
        except KeyError:
            message = _(
                "You must first verify your token before resetting password."
                " Click <a href='{url}'>here</a> to get the password reset"
                " verification token. ")
            message = format_html(message.format(
                url=reverse_lazy('account:account_reset_password')))
            messages.add_message(self.request, messages.ERROR, message)

        return form_kwargs 
开发者ID:Cadasta,项目名称:cadasta-platform,代码行数:18,代码来源:default.py

示例6: form_valid

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse_lazy [as 别名]
def form_valid(self, form):
        login = form.cleaned_data['login']
        user = form.user

        if (login == user.username and
                not user.phone_verified and
                not user.email_verified):
            user.is_active = False
            user.save()
            messages.add_message(
                self.request, messages.ERROR, account_inactive)
            return redirect(reverse_lazy('account:resend_token'))

        if(login == user.email and not user.email_verified or
                login == user.phone and not user.phone_verified):
            messages.add_message(
                self.request, messages.ERROR, unverified_identifier)
            return redirect(reverse_lazy('account:resend_token'))
        else:
            return super().form_valid(form) 
开发者ID:Cadasta,项目名称:cadasta-platform,代码行数:22,代码来源:default.py

示例7: post

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse_lazy [as 别名]
def post(self, request, question_pk):
        queryset = self.get_queryset()
        try:
            question = queryset.get(pk=question_pk)
        except models.Question.DoesNotExist as e:
            raise Http404(e)
        try:
            choice = question.choice_set.get(pk=request.POST['choice_pk'])
        except (KeyError, models.Choice.DoesNotExist):
            return render(request, 'polls/detail.html', {
                'question': question,
                'error_message': 'no choice selected'
            })
        else:
            choice.votes += 1
            choice.save()

            redirect_url = reverse_lazy('polls:tpl-poll-result', args=(question.pk,))
            return HttpResponseRedirect(redirect_url) 
开发者ID:forcemain,项目名称:notes,代码行数:21,代码来源:question.py

示例8: test_request_token_with_post_method_and_access_key_and_signdata_and_no_login

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse_lazy [as 别名]
def test_request_token_with_post_method_and_access_key_and_signdata_and_no_login(self):
        url = reverse_lazy('cas_app:cas-request-token')
        serializer = TimedSerializer(self.secret_key)
        data = serializer.dumps({'redirect_to': self.redirect_to})
        data_extra = {
            'HTTP_X_SERVICES_PUBLIC_KEY': self.access_key,
        }
        response = self.client.post(url, data, content_type='application/json', **data_extra)
        response_data = serializer.loads(response.content)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(self.cas_consumer.cas_tokens.count(), 1)
        self.assertIn('request_token', response_data)

        request_token = response_data['request_token']

        url = reverse_lazy('cas_app:cas-user-authentication')
        response = self.client.get(url, data={
            'request_token': request_token,
        })

        self.assertEqual(response.status_code, status.HTTP_302_FOUND)

        print response 
开发者ID:forcemain,项目名称:notes,代码行数:26,代码来源:test_auth.py

示例9: get_success_url

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse_lazy [as 别名]
def get_success_url(self):
        return reverse_lazy('tracker:incident-list') 
开发者ID:abarto,项目名称:tracker_project,代码行数:4,代码来源:views.py

示例10: get_authenticated_redirect_url

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse_lazy [as 别名]
def get_authenticated_redirect_url(self):
        messages.add_message(
            self.request,
            messages.ERROR,
            _('You are already logged in')
        )
        return reverse_lazy('home_page') 
开发者ID:pixlie,项目名称:oxidizr,代码行数:9,代码来源:views.py

示例11: get_success_url

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse_lazy [as 别名]
def get_success_url(self):
        return reverse_lazy('home_page') 
开发者ID:pixlie,项目名称:oxidizr,代码行数:4,代码来源:views.py

示例12: get

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse_lazy [as 别名]
def get(self, request):
        logout(request)
        return redirect(reverse_lazy('welcome_page')) 
开发者ID:pixlie,项目名称:oxidizr,代码行数:5,代码来源:views.py

示例13: get_login_url

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse_lazy [as 别名]
def get_login_url(self):
        if self.request.user.is_authenticated():
            return reverse_lazy('home_page')
        else:
            return reverse_lazy('accounts_register') 
开发者ID:pixlie,项目名称:oxidizr,代码行数:7,代码来源:views.py

示例14: get_admin_url

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse_lazy [as 别名]
def get_admin_url(self):
        content_type = ContentType.objects.get_for_model(self.__class__)
        return reverse_lazy("admin:%s_%s_change" % (content_type.app_label, content_type.model), args=(self.id,)) 
开发者ID:pixlie,项目名称:oxidizr,代码行数:5,代码来源:models.py

示例15: get_login_url

# 需要导入模块: from django.core import urlresolvers [as 别名]
# 或者: from django.core.urlresolvers import reverse_lazy [as 别名]
def get_login_url(self):
        if not self.request.user.is_authenticated():
            not_logged_in_error_message(self.request)
            return reverse_lazy('accounts_login')
        if not self.request.project:
            project_not_set_error_message(self.request)
            return reverse_lazy('projects_index') 
开发者ID:pixlie,项目名称:oxidizr,代码行数:9,代码来源:views.py


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