Examples: Function views 1. Add an import: from my_app import views 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. Add an import: from blog import urls as blog_urls 2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) """ from django.conf.urls import include, url from django.contrib import admin from django.conf import settings from artists.views import ArtistDetailView urlpatterns = [ url(r'^$', 'tracks.views.homepage', name='homepage'), url(r'^grappelli/', include('grappelli.urls')), # grappelli URLS url(r'^admin/', include(admin.site.urls)), url(r'^tracks/(?P<title>[\w\-\W]+)/', 'tracks.views.track_view', name='track_view'), url(r'^signup/', 'userprofiles.views.signup', name='signup'), url(r'^signin/', 'userprofiles.views.signin', name='signin'), url(r'^artists/(?P<pk>[\d]+)', ArtistDetailView.as_view()), url(r'^media/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': settings.MEDIA_ROOT, }), ]
from rest_framework import routers from artists.views import ArtistViewSet from albums.views import AlbumViewSet from tracks.views import TrackViewSet router = routers.DefaultRouter() router.register(r'artists', ArtistViewSet) router.register(r'albums', AlbumViewSet) router.register(r'tracks', TrackViewSet) urlpatterns = patterns('', # Examples: # url(r'^$', 'sfotipy.views.home', name='home'), # url(r'^blog/', include('blog.urls')), url(r'^admin/', include(admin.site.urls)), url(r'^tracks/(?P<title>[\w\-\W]+)/', 'tracks.views.track_view', name='track_view'), url(r'^tracks/', TrackListView.as_view()), url(r'^signup/', 'userprofiles.views.signup', name='signup'), url(r'^signin/', 'userprofiles.views.signin', name='signin'), url(r'^artists/(?P<pk>[\d]+)', ArtistDetailView.as_view()), url(r'^artists/', ArtistListView.as_view()), url(r'^api/', include(router.urls)), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), ) urlpatterns += patterns('', url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT,}), )
#!/usr/bin/env python """ Contains the artist related url mappings. """ from django.conf.urls import patterns, url from django.shortcuts import redirect from artists.views import ArtistListView, ArtistDetailView from pages.views import ProfileView __author__ = "Eraldo Helal" urlpatterns = patterns( '', # ex: ../ url(r'^$', ArtistListView.as_view(), name='artist_list'), # ex: ../4/ url(r'^(?P<pk>\d+)/$', ArtistDetailView.as_view(), name='artist_detail'), )
from django.conf.urls import patterns, include, url from django.conf import settings from django.contrib import admin from rest_framework import routers from tracks.views import TrackViewSet from artists.views import ArtistDetailView, ArtistViewSet from albums.views import AlbumViewSet router = routers.DefaultRouter() router.register(r'tracks', TrackViewSet) router.register(r'artists', ArtistViewSet) router.register(r'albums', AlbumViewSet) urlpatterns = patterns('', # Examples: # url(r'^$', 'sfotipy.views.home', name='home'), # url(r'^blog/', include('blog.urls')), (r'^grappelli/', include('grappelli.urls')), # grappelli URLS url(r'^admin/', include(admin.site.urls)), url(r'^tracks/(?P<id>[0-9]+)/', 'tracks.views.track_view', name='track_view'), url(r'^signup/', 'userprofiles.views.signup', name='signup'), url(r'^signin/', 'userprofiles.views.signin', name='signin'), url(r'^artist/(?P<pk>[\d]+)/', ArtistDetailView.as_view(), name='artist'), url(r'^api/', include(router.urls)), ) urlpatterns += patterns('', url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, }), )
#!/usr/bin/env python """ Contains the artist related url mappings. """ from django.conf.urls import patterns, url from django.shortcuts import redirect from artists.views import ArtistListView, ArtistDetailView from pages.views import ProfileView __author__ = "Eraldo Helal" urlpatterns = patterns('', # ex: ../ url(r'^$', ArtistListView.as_view(), name='artist_list'), # ex: ../4/ url(r'^(?P<pk>\d+)/$', ArtistDetailView.as_view(), name='artist_detail'), )
from artists.views import ArtistViewSet from albums.views import AlbumViewSet from tracks.views import TrackViewSet router = routers.DefaultRouter() router.register(r"artists", ArtistViewSet) router.register(r"albums", AlbumViewSet) router.register(r"tracks", TrackViewSet) urlpatterns = patterns( "", # Examples: # url(r'^$', 'sfotipy.views.home', name='home'), # url(r'^blog/', include('blog.urls')), url(r"^grappelli/", include("grappelli.urls")), # grappelli URLS url(r"^admin/", include(admin.site.urls)), url(r"^tracks/(?P<title>[\w\-\W]+)/", "tracks.views.track_view", name="track_view"), # url(r'^tracks/(?P<title>[\w\-]+)/', 'tracks.views.track_view', name='track_view'), url(r"^signup/", "userprofiles.views.signup", name="signup"), url(r"^signin/", "userprofiles.views.signin", name="signin"), url(r"^artists/(?P<pk>[\d]+)", ArtistDetailView.as_view()), url(r"^api/", include(router.urls)), url(r"^api-auth/", include("rest_framework.urls", namespace="rest_framework")), ) if settings.DEBUG: urlpatterns += patterns( "", url(r"^media/(?P<path>.*)$", "django.views.static.serve", {"document_root": settings.MEDIA_ROOT}) )
from django.conf.urls import patterns, include, url from django.contrib import admin from rest_framework import routers from tracks.views import TrackViewSet from artists.views import ArtistDetailView, ArtistViewSet from albums.views import AlbumViewSet router = routers.DefaultRouter() router.register(r'artists', ArtistViewSet) router.register(r'albums', AlbumViewSet) router.register(r'tracks', TrackViewSet) urlpatterns = patterns('', # Examples: # url(r'^$', 'sfotipywin.views.home', name='home'), # url(r'^blog/', include('blog.urls')), (r'^grappelli/', include('grappelli.urls')), # grappelli URLS url(r'^admin/', include(admin.site.urls)), url(r'^track/(?P<id>[0-9]+)/$', 'tracks.views.track_view', name='track'), url(r'^signup/$', 'userprofiles.views.signup', name='signup'), url(r'^signin/$', 'userprofiles.views.signin', name='signin'), url(r'^artist/(?P<pk>[\d]+)/$', ArtistDetailView.as_view(), name='artist'), url(r'^api/', include(router.urls)), ) # if settings.DEBUG: # Manejar archivos estaticos en Mono DEBUG urlpatterns += patterns('', url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}) )