from django.conf.urls import url from tweets.api.views import TweetListAPIView from django.views.generic.base import RedirectView urlpatterns = [ #url(r'^admin/', admin.site.urls), # url(r'^$', RedirectView.as_view(url="/")), url(r'^(?P<username>[\w.@+-]+)/tweet/$', TweetListAPIView.as_view(), name='list'), ]
from django.conf.urls import url from django.views.generic.base import RedirectView from tweets.api.views import ( TweetListAPIView, ) urlpatterns = [ url(r'^(?P<username>[\w.@+-]+)/tweet/$', TweetListAPIView.as_view(), name='list'), ]
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 url, include from django.contrib import admin from django.conf import settings from django.conf.urls.static import static from tweets.api.views import ( LikeToggleAPIView, RetweetAPIView, TweetCreateAPIView, TweetListAPIView, TweetDetailAPIView, ) urlpatterns = [ # url(r'^admin/', admin.site.urls), url(r'^$', TweetListAPIView.as_view(), name='list'), url(r'^create/$', TweetCreateAPIView.as_view(), name='create'), url(r'^(?P<pk>\d+)/$', TweetDetailAPIView.as_view(), name='detail'), url(r'^(?P<pk>\d+)/like/$', LikeToggleAPIView.as_view(), name='like-toggle'), url(r'^(?P<pk>\d+)/retweet/$', RetweetAPIView.as_view(), name='retweet'), ]
from django.urls import path from django.views.generic.base import RedirectView from tweets.api.views import ( TweetListAPIView, ) app_name = 'tweets' urlpatterns = [ path('<username>/tweets/', TweetListAPIView.as_view(), name='list'), # ]
from django.urls import path, include from django.views.generic.base import RedirectView from tweets.api.views import TweetListAPIView app_name = 'accounts' urlpatterns = [ path('<username>/tweet', TweetListAPIView.as_view()), ]
from django.contrib import admin from django.urls import path from django.conf import settings from django.conf.urls.static import static from django.views.generic.base import RedirectView from tweets.api.views import ( TweetListAPIView, ) app_name = "tweets" urlpatterns = [ path(r'<str:username>/tweet/', TweetListAPIView.as_view(), name='list'), ]
from django.urls import path from django.views.generic.base import RedirectView from tweets.api.views import (TweetListAPIView) app_name = "profiles-api" urlpatterns = [ path('<slug:username>/tweet/', TweetListAPIView.as_view(), name='list') ]
from django.conf.urls import url from django.views.generic.base import RedirectView from tweets.api.views import ( TweetListAPIView, ) urlpatterns = [ url(r'^(?P<username>[\w.@+-]+)/tweet/$', TweetListAPIView.as_view(), name='list'), # /api/tweet/ ]
from django.urls import path from tweets.api.views import TweetListAPIView from .views import UserProfileAPIView, UsernameTakenAPIView app_name = 'accounts' urlpatterns = [ path('<str:username>/', UserProfileAPIView.as_view(), name='user-profile'), path('<str:username>/tweet/', TweetListAPIView.as_view(), name='user-tweets'), path('find/<str:username>/', UsernameTakenAPIView.as_view(), name='find-user') ]