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. 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
from django.contrib import admin
# from restaurants.views import HomeView, AboutView, ContactView
from django.views.generic import TemplateView
from restaurants.views import RestaurantListView, RestaurantDetailView, restaurant_createview, RestaurantCreateView

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', TemplateView.as_view(template_name='home.html')),
    # url(r'^restaurants/$', restaurants_list_view),
    url(r'^restaurants/$', RestaurantListView.as_view()),
    # url(r'^restaurants/create/$', restaurant_createview),
    url(r'^restaurants/create/$', RestaurantCreateView.as_view()),
    # url(r'^restaurants/(?P<slug>\w+)/$', RestaurantListView.as_view()),
    url(r'^restaurants/(?P<slug>[\w-]+)/$', RestaurantDetailView.as_view()),
    url(r'^about/$', TemplateView.as_view(template_name='about.html')),
    url(r'^contact/$', TemplateView.as_view(template_name='contact.html')),
    # url(r'^about/$', AboutView.as_view()),
    # # url(r'^contact/$', ContactView.as_view())
    # url(r'^contact/$', ContactView.as_view())
]
Example #2
0
from django.conf.urls import url

from restaurants.views import (
    RestaurantUpdateView,
    RestaurantListView,
    RestaurantDetailView,
    RestaurantCreateView,
)

urlpatterns = [
    url(r'^create/$', RestaurantCreateView.as_view(), name='create'),
    #url(r'^(?P<slug>[\w-]+)/edit$', RestaurantUpdateView.as_view(), name='edit'),
    url(r'^(?P<slug>[\w-]+)/$', RestaurantUpdateView.as_view(), name='detail'),
    url(r'^$', RestaurantListView.as_view(), name='list'),
]
Example #3
0
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.views import LoginView, LogoutView
from restaurants.views import (home,about,contact,ContactView,ContactTemplateView,restaurant_listview,
RestaurantListView,RestaurantDetailView,restaurant_create_view,RestaurantCreateView,RestaurantDetailUpdateView)
from menus.views import ItemCreateView,HomeView
from profiles.views import ProfileFollowToggle, RegisterView, activate_user_view
urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', HomeView.as_view(),name='home'),
    url(r'^restaurants/(?P<slug>[\w-]+)/$', RestaurantDetailUpdateView.as_view(),name='restaurant-detail-update'),
    url(r'^restaurants_create/$',RestaurantCreateView.as_view(),name='restaurant-create'),
    url(r'^register/$',RegisterView.as_view(),name='register'),
    url(r'^activate/(?P<code>[a-z0-9].*)/$', activate_user_view, name='activate'),
    #url(r'^restaurants/(?P<slug>[\w-]+)/update/$',RestaurantUpdateView.as_view(),name='restaurant-update'),
    #url(r'^restaurants_create/$',restaurant_create_view),
    #url(r'^restaurants/(?P<rest_id>\w+)/$', RestaurantDetailView.as_view()),
    url(r'^items/',include('menus.urls',namespace='menus')),
    url(r'^u/',include('profiles.urls',namespace='profiles')),
    url(r'^restaurants/$', restaurant_listview,name='restaurants'),
    url(r'^login/', LoginView.as_view(),name='login'),
    url(r'^logout/', LogoutView.as_view(),name='logout'),
    url(r'^about/$', about,name='about'),
    url(r'^contact/$', ContactTemplateView.as_view(),name='contact'),
    #url(r'^items_create/$',ItemCreateView.as_view(),name='create'),
    url(r'^follow/', ProfileFollowToggle.as_view(),name='follow'),
    #url(r'^items_update/$',ItemUpdateView.as_view(),name='update'),
Example #4
0
    restaurant_listview,
    RestaurantListView,
    RestaurantDetailView,
    RestaurantCreateView,
)

urlpatterns = [
    url(r'^admin/', admin.site.urls),

    # The only reason we are using 'HomeView' here is, we are customizing
    # the get_context_data in views.py if not we would use TemplateView.as_view()
    # url(r'^$', HomeView.as_view()),
    url(r'^$', TemplateView.as_view(template_name="home.html"), name="home"),
    url(r'^login/$', LoginView.as_view(), name="login"),
    url(r'^restaurants/$', RestaurantListView.as_view(), name="restaurants"),
    url(r'^restaurants/create/$',
        RestaurantCreateView.as_view(),
        name="restaurants-create"),
    #url(r'^restaurants/create/$', restaurant_createview),
    url(r'^restaurants/(?P<slug>[\w-]+)/$',
        RestaurantDetailView.as_view(),
        name="restaurant-detail"),
    #url(r'^restaurants/(?P<slug>\w+)/$', RestaurantListView.as_view()),
    #url(r'^restaurants/asian/$', AsianFusionRestaurantListView.as_view()),
    url(r'^about/$',
        TemplateView.as_view(template_name="about.html"),
        name="about"),
    url(r'^contact/$',
        TemplateView.as_view(template_name="contact.html"),
        name="contact"),
]
Example #5
0
from django.urls import path

from restaurants.views import RestaurantListView, RestaurantCreateView, RestaurantUpdateView

app_name = 'restaurants'

urlpatterns = [
    path('', RestaurantListView.as_view(), name="list"),
    path('create/', RestaurantCreateView.as_view(), name="create"),
    path('<slug:slug>/', RestaurantUpdateView.as_view(), name="detail")
]
Example #6
0
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include
from django.urls import path, re_path
from restaurants.views import restaurant_createview, \
    RestaurantListView, \
    RestaurantDetailView, \
    RestaurantCreateView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', restaurant_createview, name="home"),
    path('restaurants/', RestaurantListView.as_view(), name="restaurant_page"),
    path('restaurants/create/', RestaurantCreateView.as_view()),
    # re_path('restaurants/(?P<slug>[\w+-])/', RestaurantListView.as_view(), name="search_restaurant_page"),
    re_path('restaurants/(?P<slug>[\w-]+)/',
            RestaurantDetailView.as_view(),
            name="search_restaurant_detail_page"),
    path('cart/', include('cart.urls', namespace='cart')),
    path('orders/', include('orders.urls', namespace='orders')),
    path('shop/', include('shop.urls', namespace='shop')),
]

if settings.DEBUG:
    # urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL,
                          document_root=settings.MEDIA_ROOT)