Extract bookmark form tag

This commit is contained in:
Sascha Ißbrücker 2019-06-29 01:00:52 +02:00
parent 37ee00077a
commit 251fda609c
6 changed files with 36 additions and 37 deletions

View File

@ -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'

View File

@ -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 %}

View 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">

View File

@ -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 %}

View File

View 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,
}