Dedicated Home View
This commit is contained in:
parent
b54e81d372
commit
049b672c00
@ -24,7 +24,6 @@ from django.urls import path, include
|
||||
from django.views.generic.base import TemplateView
|
||||
|
||||
urlpatterns = [
|
||||
path('', TemplateView.as_view(template_name='home.html'), name='home'),
|
||||
path('admin/', admin.site.urls),
|
||||
path('explorers/', include('django.contrib.auth.urls')),
|
||||
path('', include('lostplaces_app.urls')),
|
||||
|
@ -1,6 +1,7 @@
|
||||
from django.urls import path
|
||||
from .views import (
|
||||
hello_world,
|
||||
HomeView,
|
||||
place_detail_view,
|
||||
place_list_view,
|
||||
SignUpView,
|
||||
@ -10,6 +11,7 @@ from .views import (
|
||||
|
||||
urlpatterns = [
|
||||
path('hello_world/', hello_world), # You know what this is :P
|
||||
path('', HomeView.as_view(), name='home'),
|
||||
path('signup/', SignUpView.as_view(), name='signup'),
|
||||
path('place/<int:pk>/', place_detail_view, name='place_detail'),
|
||||
path('place/create/', PlaceCreateView.as_view(), name='place_create'),
|
||||
|
@ -28,6 +28,16 @@ def place_detail_view(request, pk):
|
||||
def hello_world(request):
|
||||
return render(request, 'hello_world.html', {'text':'Hello World!'})
|
||||
|
||||
class HomeView(View):
|
||||
def get(self, request, *args, **kwargs):
|
||||
place_list = Place.objects.all().order_by('submitted_when')[:10]
|
||||
print(place_list)
|
||||
context = {
|
||||
'place_list': place_list
|
||||
}
|
||||
return render(request, 'home.html', context)
|
||||
|
||||
|
||||
class PlaceUpdateView(UpdateView):
|
||||
template_name = 'update_place.html'
|
||||
model = Place
|
||||
|
Loading…
Reference in New Issue
Block a user