From e4cd8bb30155bd7dfce274c44dc6f24ba72cab27 Mon Sep 17 00:00:00 2001 From: reverend Date: Mon, 31 Aug 2020 18:18:24 +0200 Subject: [PATCH] Tagging using JS using Partials --- .../templates/partials/tagging.html | 53 +++++++++++++++++++ .../templates/place/place_detail.html | 39 +------------- .../lostplaces_app/views/place_views.py | 5 +- 3 files changed, 59 insertions(+), 38 deletions(-) create mode 100644 lostplaces/lostplaces_app/templates/partials/tagging.html diff --git a/lostplaces/lostplaces_app/templates/partials/tagging.html b/lostplaces/lostplaces_app/templates/partials/tagging.html new file mode 100644 index 0000000..e0af9dd --- /dev/null +++ b/lostplaces/lostplaces_app/templates/partials/tagging.html @@ -0,0 +1,53 @@ +
+ +
+ +
+
+ Tags hinzufügen + {% csrf_token %} +
+
+ {% include 'partials/form/inputField.html' with field=input_field %} +
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/lostplaces/lostplaces_app/templates/place/place_detail.html b/lostplaces/lostplaces_app/templates/place/place_detail.html index 3c48536..d7351c9 100644 --- a/lostplaces/lostplaces_app/templates/place/place_detail.html +++ b/lostplaces/lostplaces_app/templates/place/place_detail.html @@ -38,45 +38,10 @@
- + {% url 'place_tag_submit' place_id=place.id as tag_submit_url%} + {% include 'partials/tagging.html' with tag_list=place.tags.all url=tag_submit_url input_field=tagging_form.tag_list%} -
-
    - {% for tag in place.tags.all %} -
  • -
    -

    {{tag}}

    -
    -
  • - {% endfor %} -
-
- -
-
- Tags hinzufügen - {% csrf_token %} -
-
- {% include 'partials/form/inputField.html' with field=tagging_form.tag_list %} -
-
- -
-
-
- -
diff --git a/lostplaces/lostplaces_app/views/place_views.py b/lostplaces/lostplaces_app/views/place_views.py index 1e5bc67..30a7123 100644 --- a/lostplaces/lostplaces_app/views/place_views.py +++ b/lostplaces/lostplaces_app/views/place_views.py @@ -13,6 +13,8 @@ from lostplaces_app.models import Place, PlaceImage from lostplaces_app.views import IsAuthenticated, IsPlaceSubmitter from lostplaces_app.forms import PlaceForm, PlaceImageCreateForm, TagSubmitForm +from taggit.models import Tag + class PlaceListView(IsAuthenticated, ListView): paginate_by = 5 model = Place @@ -31,7 +33,8 @@ class PlaceDetailView(IsAuthenticated, View): 'place': place, 'place_list': [ place ], 'place_map_center': [ place.latitude, place.longitude ], - 'tagging_form': TagSubmitForm() + 'tagging_form': TagSubmitForm(), + 'all_tags': Tag.objects.all() } return render(request, 'place/place_detail.html', context)