Quantcast
Channel: How to call a specific url from Django views? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

How to call a specific url from Django views?

$
0
0

I want to make a call to specific url pattern from Django Views.The call should be inside first IF conditional and outside the inner if. Is the any function which provides redirection? Or something like redirect(map_vertical_crawl)? The code portion forDjango Views:

def add_vertical(request):    if request.method == 'POST':        form = VerticalForm(request.POST)        if form.is_valid():            form.save()        #I WANT TO CALL URL EXACTLY AT THIS POINT, INSIDE OUTER IF.    verticals = Verticals.objects.all()    return  render(request, 'cfman/add_vertical.html',                   {'form': VerticalForm(),'verticals': verticals}                  )

Django URLS:

from django.conf.urls import urlfrom . import views, appsurlpatterns = [    #Generates Login Screen    url(r'^$', views.LoginView.as_view(), name="login"),    #Directs to manager view level 1    url(r'^manager/$', views.verticals_view, name="manager"),    #Directs to manager view level 2    url(r'^manager/(?P<verticalid>\d+)/$', views.source_list, name='source_list'),    #Add Vertical    url(r'^verticals/add_vertical/$', views.add_vertical, name="add_vertical"),    #Add Source    url(r'^sources/add_source/$', views.add_source, name="add_source"),    #Add Crawl Type    url(r'^crawls/add_crawl/$', views.add_crawl, name="add_crawl"),    #Map verticals and crawl types    url(r'^vertical_crawl/$', views.map_vertical_crawl, name="map_vertical_crawl"),]

I want to call the last url pattern , 'map_vertical_crawl' from views.


Viewing all articles
Browse latest Browse all 2

Trending Articles