當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。