diff --git a/bookmarks/forms/bookmark_form.py b/bookmarks/forms/bookmark_form.py index f5e96fa..f7ce222 100644 --- a/bookmarks/forms/bookmark_form.py +++ b/bookmarks/forms/bookmark_form.py @@ -1,6 +1,6 @@ from django import forms -from ..models import Bookmark +from bookmarks.models import Bookmark auto_fill_placeholder = 'Leave empty to fill from website metadata' diff --git a/bookmarks/templates/bookmarks/edit.html b/bookmarks/templates/bookmarks/edit.html index aca5889..56cd3da 100644 --- a/bookmarks/templates/bookmarks/edit.html +++ b/bookmarks/templates/bookmarks/edit.html @@ -1,24 +1,9 @@ -{% extends "bookmarks/layout.html" %} +{% extends 'bookmarks/layout.html' %} +{% load bookmarks %} {% block content %}

New bookmark

- {% csrf_token %} -
- - {{ form.url }} - {{ form.url.errors }} -
-
- - {{ form.title }} - {{ form.title.errors }} -
-
- - {{ form.description }} - {{ form.description.errors }} -
- + {% bookmark_form form %}
{% endblock %} diff --git a/bookmarks/templates/bookmarks/form.html b/bookmarks/templates/bookmarks/form.html new file mode 100644 index 0000000..bdd57e8 --- /dev/null +++ b/bookmarks/templates/bookmarks/form.html @@ -0,0 +1,17 @@ +{% csrf_token %} +
+ + {{ form.url }} + {{ form.url.errors }} +
+
+ + {{ form.title }} + {{ form.title.errors }} +
+
+ + {{ form.description }} + {{ form.description.errors }} +
+ diff --git a/bookmarks/templates/bookmarks/new.html b/bookmarks/templates/bookmarks/new.html index d9f0ae2..2b24726 100644 --- a/bookmarks/templates/bookmarks/new.html +++ b/bookmarks/templates/bookmarks/new.html @@ -1,24 +1,9 @@ -{% extends "bookmarks/layout.html" %} +{% extends 'bookmarks/layout.html' %} +{% load bookmarks %} {% block content %}

New bookmark

- {% csrf_token %} -
- - {{ form.url }} - {{ form.url.errors }} -
-
- - {{ form.title }} - {{ form.title.errors }} -
-
- - {{ form.description }} - {{ form.description.errors }} -
- + {% bookmark_form form %}
{% endblock %} diff --git a/bookmarks/templatetags/__init__.py b/bookmarks/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bookmarks/templatetags/bookmarks.py b/bookmarks/templatetags/bookmarks.py new file mode 100644 index 0000000..51e2c15 --- /dev/null +++ b/bookmarks/templatetags/bookmarks.py @@ -0,0 +1,12 @@ +from django import template + +from bookmarks.forms import BookmarkForm + +register = template.Library() + + +@register.inclusion_tag('bookmarks/form.html', name='bookmark_form') +def bookmark_form(form: BookmarkForm): + return { + 'form': form, + }