Пример #1
0
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
#from django_registration.backends.activation import urls
from django.urls import path, include
from django.contrib.auth.decorators import login_required as auth
from django.contrib.auth.views import LoginView, logout_then_login
from links.views import LinkListView, UserProfileDetailView, UserProfileEditView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', LinkListView.as_view(), name='home'),
    path('login/',
         LoginView.as_view(template_name="links/login.html"),
         name='login'),
    path('logout/', logout_then_login, name='logout'),
    path('accounts/', include('django_registration.backends.one_step.urls')),
    path('users/<slug>/', UserProfileDetailView.as_view(), name="profile"),
    path('edit_profile/',
         auth(UserProfileEditView.as_view()),
         name="edit_profile"),
]
Пример #2
0
from django.conf.urls import include, url
from django.contrib import admin
from links.views import LinkListView
from links.views import UserProfileDetailView
from django.contrib.auth.decorators import login_required as auth
from links.views import UserProfileEditView
from links.views import LinkCreateView
from links.views import LinkDetailView
from links.views import LinkUpdateView
from links.views import LinkDeleteView
from links.views import VoteFormView

urlpatterns = [
    url(r'^static/(?P<path>.*)$','django.views.static.serve',{'document_root': 'static'}),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', LinkListView.as_view(), name='home'),
    url(r'^login/$', 'django.contrib.auth.views.login', {
    'template_name': 'login.html'}, name="login"),
    url(r'^logout/$', 'django.contrib.auth.views.logout_then_login',
        name="logout"),
    url(r'^accounts/', include('registration.backends.simple.urls')),
    url(r'^users/(?P<slug>\w+)/$', UserProfileDetailView.as_view(), name="profile"),
    url(r'^edit_profile/$', auth(UserProfileEditView.as_view()), name="edit_profile"),
    url(r'^link/create/$', auth(LinkCreateView.as_view()),name='link_create'),
    url(r'^link/(?P<pk>\d+)/$', LinkDetailView.as_view(), name='link_detail'),
    url(r'^link/update/(?P<pk>\d+)/$', auth(LinkUpdateView.as_view()), name='link_update'),
    url(r'^link/delete/(?P<pk>\d+)/$', auth(LinkDeleteView.as_view()), name='link_delete'),
    url(r'^comments/', include('django_comments.urls')),
    url(r'^vote/$', auth(VoteFormView.as_view()), name="vote"),
]
Пример #3
0
from django.conf.urls import patterns, include, url
from django.contrib.auth.decorators import login_required as auth
from django.contrib import admin
admin.autodiscover()

from links.views import LinkListView
from links.views import UserProfileDetailView
from links.views import UserProfileEditView

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', LinkListView.as_view(), name='home'),

    url(r"^login/$", "django.contrib.auth.views.login",
        {"template_name": "login.html"}, name="login"),
    url(r"^logout/$", "django.contrib.auth.views.logout_then_login",
        name="logout"),

    url(r"^accounts/", include("registration.backends.simple.urls")),
    url(r"^users/(?P<slug>\w+)/$", UserProfileDetailView.as_view(),
        name="profile"),
    url(r"edit_profile/$", auth(UserProfileEditView.as_view()),
        name="edit_profile")
)
Пример #4
0
urlpatterns = patterns('',

    url(r'^admin/', include(admin.site.urls)),
    url(r'^comments/', include("django.contrib.comments.urls")),
    url(r'^$',LinkListView.as_view(), name='home'),
    
    url(r"^login/$", "django.contrib.auth.views.login",
        {"template_name": "login.html"}, name="login"),
    url(r"^logout/$", "django.contrib.auth.views.logout_then_login",
        name="logout"),
        
    url(r"^accounts/", include("registration.backends.simple.urls")),
    url(r"^users/(?P<slug>\w+)/$", UserProfileDetailView.as_view(), 
        name="profile"),
    url(r"edit_profile/$", UserProfileEditView.as_view(),
        name="edit_profile"),
        
    url(r"^link/create/$", auth(LinkCreateView.as_view()),
        name="link_create"),
    
    url(r"^link/(?P<pk>\d+)$", LinkDetailView.as_view(),
        name="link_detail"),
        
    url(r"^link/update/(?P<pk>\d+)$", auth(LinkUpdateView.as_view()),
        name="link_update"),
        
    url(r"^link/delete/(?P<pk>\d+)$", auth(LinkDeleteView.as_view()),
        name="link_delete"),
)
Пример #5
0
from django.contrib import admin
from django.contrib.auth.decorators import login_required
from django.urls import path, include
from links.views import UserProfileDetailView, UserProfileEditView

admin.autodiscover()
urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('links.urls')),
    path('users/<slug>/', UserProfileDetailView.as_view(), name="profile"),
    path('edit_profile/',
         login_required(UserProfileEditView.as_view()),
         name="edit_profile"),
]
Пример #6
0
    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 url, include
from django.contrib import admin
from django.contrib.auth import views as auth_views
from links.views import LinkListView
from links.views import UserProfileDetailView
from django.contrib.auth.decorators import login_required as auth # Keep non-users out
from links.views import UserProfileEditView
from links.views import LinkCreateView, LinkDetailView
from links.views import LinkEditView
from links.views import LinkDeleteView

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', LinkListView.as_view(), name='home'),
    url(r'^login/$', auth_views.login, name='login'),
    url(r'^logout/$', auth_views.logout, name='logout'),
    url(r'^accounts/', include('registration.backends.simple.urls')),
    url(r'^users/(?P<slug>\w+)/$', UserProfileDetailView.as_view(),name='profile'),
    url(r'^edit_profile/$', auth(UserProfileEditView.as_view()), name='edit_profile'),
    url(r'^link/submit/$', auth(LinkCreateView.as_view()), name='link_submit'),
    url(r'^link/(?P<pk>\d+)/$', LinkDetailView.as_view(), name='link_detail'),
    url(r'^link/edit/(?P<pk>\d+)/$', auth(LinkEditView.as_view()), name='link_edit'),
    url(r'^link/delete/(?P<pk>\d+)/$', auth(LinkDeleteView.as_view()), name='link_delete'),
    url(r'^comments/', include('django_comments.urls')),
]
Пример #7
0


urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'gogoreader.views.home', name='home'),
    # url(r'^gogoreader/', include('gogoreader.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
    url(r'^comments', include("django.contrib.comments.urls")),
    url(r'^$', show_profile, name='home'),
    url(r'^post', post_data, name='post_data'),

    url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}, name="login"),
    url(r'^logout/$', 'django.contrib.auth.views.logout_then_login',name="logout"),
    url(r'^accounts/', include('registration.backends.simple.urls')),
    url(r'^users/(?P<slug>\w+)/$', UserProfileDetailView.as_view(), name="profile"),
    url(r'edit_profile/$', auth(UserProfileEditView.as_view()), name='edit_profile'),
    url(r'^link/create/$', auth(LinkCreateView.as_view()), name='link_create'),
    url(r'^rss/create/$', auth(RssCreateView.as_view()), name='rss_create'),
    url(r'^link/update/(?P<pk>\d+)/$', auth(LinkUpdateView.as_view()), name='link_update'),
    url(r'^link/delete/(?P<pk>\d+)/$', auth(LinkDeleteView.as_view()), name='link_delete'),
    url(r'^link/(?P<pk>\d+)$', LinkDetailView.as_view(), name='link_detail'),
    url(r'^tag/(?P<pk>\d+)$', show_tag_links, name='link_tag'),

)