Ejemplo n.º 1
0
from django.conf.urls import patterns, include, url
from django.contrib import admin
from trips.views import TripView

urlpatterns = patterns('',
    url(r'^$', TripView.as_view()),
    url(r'^api/', include('api.urls')),
    url(r'^admin/', include(admin.site.urls)),
)
Ejemplo n.º 2
0
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import patterns, url, include
from trips import views
from trips.views import TripView
from trips.models import Trip

urlpatterns = [
    
	#To display a full list of current trips being offered we accept the /trips/ portion of the url
    #url(r'^trips/$', views.ListTrips.as_view(), name='trips_list'),
    
    #If a number exists after /trips/ such as /trips/1, we display that particular trip detail
    url(r'^trips/(?P<pk>[0-9]+)/$', views.TripDetail.as_view()),
    
	#Collect the data when /trips/ is typed and format it in a template for user
    url(r'^trips/$', TripView.as_view(
    	queryset = Trip.objects.all(),
    	context_object_name = "trips",
    	template_name='trips/index.html'))
]



Ejemplo n.º 3
0
from django.contrib import admin
from django.urls import path

from trips.views import TripView

app_name = 'trips'

urlpatterns = [
    path('', TripView.as_view({'get': 'list'}), name='trip_list'),
    path('<uuid:trip_id>/', TripView.as_view({'get': 'retrieve'}), name='trip_detail'),  # new
]
Ejemplo n.º 4
0
from django.urls import path

from trips.views import TripView

app_name = 'taxi'

urlpatterns = [
    path('', TripView.as_view({'get': 'list'}), name='trip_list'),
    path(
        '<uuid:trip_id>/',
        TripView.as_view({'get': 'retrieve'}),
        name='trip_detail'
    ),
]