Extract bookmark form tag
This commit is contained in:
parent
37ee00077a
commit
251fda609c
@ -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'
|
||||
|
||||
|
@ -1,24 +1,9 @@
|
||||
{% extends "bookmarks/layout.html" %}
|
||||
{% extends 'bookmarks/layout.html' %}
|
||||
{% load bookmarks %}
|
||||
|
||||
{% block content %}
|
||||
<h2>New bookmark</h2>
|
||||
<form action="{% url 'bookmarks:edit' bookmark_id %}" method="post">
|
||||
{% csrf_token %}
|
||||
<div class="field">
|
||||
<label for="{{ form.url.id_for_label }}">URL</label>
|
||||
{{ form.url }}
|
||||
{{ form.url.errors }}
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="{{ form.title.id_for_label }}">Title</label>
|
||||
{{ form.title }}
|
||||
{{ form.title.errors }}
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="{{ form.description.id_for_label }}">Description</label>
|
||||
{{ form.description }}
|
||||
{{ form.description.errors }}
|
||||
</div>
|
||||
<input type="submit" value="Save">
|
||||
{% bookmark_form form %}
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
17
bookmarks/templates/bookmarks/form.html
Normal file
17
bookmarks/templates/bookmarks/form.html
Normal file
@ -0,0 +1,17 @@
|
||||
{% csrf_token %}
|
||||
<div class="field">
|
||||
<label for="{{ form.url.id_for_label }}">URL</label>
|
||||
{{ form.url }}
|
||||
{{ form.url.errors }}
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="{{ form.title.id_for_label }}">Title</label>
|
||||
{{ form.title }}
|
||||
{{ form.title.errors }}
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="{{ form.description.id_for_label }}">Description</label>
|
||||
{{ form.description }}
|
||||
{{ form.description.errors }}
|
||||
</div>
|
||||
<input type="submit" value="Save">
|
@ -1,24 +1,9 @@
|
||||
{% extends "bookmarks/layout.html" %}
|
||||
{% extends 'bookmarks/layout.html' %}
|
||||
{% load bookmarks %}
|
||||
|
||||
{% block content %}
|
||||
<h2>New bookmark</h2>
|
||||
<form action="{% url 'bookmarks:new' %}" method="post">
|
||||
{% csrf_token %}
|
||||
<div class="field">
|
||||
<label for="{{ form.url.id_for_label }}">URL</label>
|
||||
{{ form.url }}
|
||||
{{ form.url.errors }}
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="{{ form.title.id_for_label }}">Title</label>
|
||||
{{ form.title }}
|
||||
{{ form.title.errors }}
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="{{ form.description.id_for_label }}">Description</label>
|
||||
{{ form.description }}
|
||||
{{ form.description.errors }}
|
||||
</div>
|
||||
<input type="submit" value="Save">
|
||||
{% bookmark_form form %}
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
0
bookmarks/templatetags/__init__.py
Normal file
0
bookmarks/templatetags/__init__.py
Normal file
12
bookmarks/templatetags/bookmarks.py
Normal file
12
bookmarks/templatetags/bookmarks.py
Normal file
@ -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,
|
||||
}
|
Loading…
Reference in New Issue
Block a user