from apps.core.views import (Index, SignUp, Logout, TermsOfService, BanPage) from apps.accounts.views import ProfileView, UserSettings def favicon(request): f = open('static/favicon.ico', 'rb') x = f.read() f.close() return HttpResponse(x) urlpatterns = [ # Index views url(r'^$', Index.as_view(), name='index'), url(r'^(?i)admin/?', include(admin.site.urls)), url(r'^(?i)terms-of-service/?$', TermsOfService.as_view(), name='terms'), url(r'^(?i)banned/?$', BanPage.as_view(), name='ban-page'), # Stuff to possibly move aside url(r'^(?i)users/(?P<username>\w+)/?$', ProfileView.as_view(), name='profile'), # Namespaces url(r'^(?i)projects/', include('apps.projects.urls', namespace='projects')), url(r'^(?i)accounts/', include('apps.accounts.urls', namespace='accounts')),
from django.conf.urls import include, url from django.contrib import admin from apps.core.views import Index urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^$', Index.as_view(), name='index'), url(r'^api/v1/', include('apps.about.rest_urls', namespace='about')), url(r'^api/v1/posts/', include('apps.posts.rest_urls', namespace='posts')), url(r'^api/v1/accounts/', include('apps.accounts.rest_urls', namespace='accounts')), ]
from apps.core.views import (Index, SignUp, Logout, TermsOfService, BanPage) from apps.accounts.views import ProfileView, UserSettings def favicon(request): f = open('static/favicon.ico', 'rb') x = f.read() f.close() return HttpResponse(x) urlpatterns = [ # Index views path('', Index.as_view(), name='index'), path('admin/', admin.site.urls), path('terms-of-service/', TermsOfService.as_view(), name='terms'), path('banned/', BanPage.as_view(), name='ban-page'), # Stuff to possibly move aside path('users/<username>/', ProfileView.as_view(), name='profile'), # Namespaces path( 'projects/', include(('apps.projects.urls', 'apps.projects'), namespace='projects')), path( 'accounts/', include(('apps.accounts.urls', 'apps.accounts'),
from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() from apps.core.views import Index urlpatterns = patterns( "", # Index views url(r"^$", Index.as_view(), name="index"), url(r"^(?i)admin/?", include(admin.site.urls)), )
https://docs.djangoproject.com/en/3.0/topics/http/urls/ Examples: 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.conf import settings from django.conf.urls.static import static from django.urls import path, include from apps.core.views import Index from apps.post.views import PostDetail, PostListTag urlpatterns = [ path('', Index.as_view()), path('admin/', admin.site.urls), path('posts/<slug:tag>', PostListTag.as_view(), name='posts'), path('<slug:slug>', PostDetail.as_view(), name='post'), path('ckeditor/', include('ckeditor_uploader.urls')), ] + static( settings.STATIC_URL, document_root=settings.STATIC_ROOT ) + static( settings.MEDIA_URL, document_root=settings.MEDIA_ROOT )