diff --git a/bookmarks/admin.py b/bookmarks/admin.py index 8c38f3f..29929ed 100644 --- a/bookmarks/admin.py +++ b/bookmarks/admin.py @@ -1,3 +1,5 @@ from django.contrib import admin -# Register your models here. +from . import models + +admin.site.register(models.Bookmark) diff --git a/bookmarks/models.py b/bookmarks/models.py index 3ffaaa7..9bd5e92 100644 --- a/bookmarks/models.py +++ b/bookmarks/models.py @@ -2,4 +2,7 @@ from django.db import models class Bookmark(models.Model): title = models.CharField(max_length=255,null=True) - url = models.URLField(max_length=2048) \ No newline at end of file + url = models.URLField(max_length=2048) + + def __str__(self): + return self.title \ No newline at end of file diff --git a/bookmarks/templates/bookmarks/bookmark_list.html b/bookmarks/templates/bookmarks/bookmark_list.html new file mode 100644 index 0000000..c82e9c9 --- /dev/null +++ b/bookmarks/templates/bookmarks/bookmark_list.html @@ -0,0 +1,8 @@ +

Bookmarks

+ \ No newline at end of file diff --git a/bookmarks/urls.py b/bookmarks/urls.py new file mode 100644 index 0000000..2b6b8ca --- /dev/null +++ b/bookmarks/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path('', views.BookmarkListView.as_view(), name='bookmark-list') +] \ No newline at end of file diff --git a/bookmarks/views.py b/bookmarks/views.py index 91ea44a..a216e9c 100644 --- a/bookmarks/views.py +++ b/bookmarks/views.py @@ -1,3 +1,13 @@ -from django.shortcuts import render +from django.utils import timezone +from django.views.generic.list import ListView -# Create your views here. +from .models import Bookmark + +class BookmarkListView(ListView): + model = Bookmark + paginate_by = 20 + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context['now'] = timezone.now() + return context diff --git a/forgetmenot/urls.py b/forgetmenot/urls.py index 69b73ae..2dbc13a 100644 --- a/forgetmenot/urls.py +++ b/forgetmenot/urls.py @@ -14,8 +14,9 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import include, path urlpatterns = [ + path('bookmarks/', include('bookmarks.urls')), path('admin/', admin.site.urls), ]