updated pyton versions and wrote hilfsbibliotheken
This commit is contained in:
@@ -16,7 +16,7 @@ class PostForm(forms.ModelForm):
|
||||
fields = ('title', 'text', 'published_date','tags')
|
||||
|
||||
class NewTagForm(forms.ModelForm):
|
||||
m_tags = TagField()
|
||||
tags = TagField()
|
||||
class Meta:
|
||||
model = CustomUser
|
||||
fields = ['m_tags']
|
||||
fields = ['tags']
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
{% extends "base.html" %} {% block content %} {% load taggit_templatetags2_tags %} {% get_taglist as tags for 'application.post'%}
|
||||
{% extends "base.html" %} {% block content %} {% load taggit_templatetags2_tags %}
|
||||
{% get_taglist as tags for 'application.post'%}
|
||||
|
||||
<div id="">
|
||||
<ul>
|
||||
{% for tag in tags %}
|
||||
<li>{{tag}}
|
||||
<a class="btn btn-outline-dark" href="{% url 'tag_remove' tag.slug %}">
|
||||
<span class="glyphicon glyphicon-remove">Remove</span>
|
||||
</a>
|
||||
</li>
|
||||
{{ result }} {% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<form class="post-form" method="post">
|
||||
{% csrf_token %} {{form.as_p}}
|
||||
|
||||
@@ -126,17 +126,21 @@ def post_remove(request, pk):
|
||||
|
||||
@login_required
|
||||
def tag_remove(request, slug=None):
|
||||
log = logging.getLogger('mysite')
|
||||
user_instance = get_object_or_404(CustomUser, user=request.user)
|
||||
log.info(u)
|
||||
tag = Tag.get_object_or_404(Tag, slug = slug)
|
||||
log.info(tag)
|
||||
if slug:
|
||||
tag = get_object_or_404(Tag, slug=slug)
|
||||
tag.delete()
|
||||
user_instance.tags.remove(tag)
|
||||
save_m2m()
|
||||
return redirect('student_page')
|
||||
return redirect('student_page')
|
||||
|
||||
|
||||
@login_required
|
||||
def student_page(request):
|
||||
log = logging.getLogger('mysite')
|
||||
user_instance = get_object_or_404(CustomUser, user=request.user)
|
||||
log.info(user_instance)
|
||||
if request.method == "POST":
|
||||
log.info('post method')
|
||||
form = NewTagForm(request.POST, instance=user_instance)
|
||||
@@ -147,7 +151,7 @@ def student_page(request):
|
||||
obj.save()
|
||||
tag_names = [tag.name for tag in Tag.objects.all()]
|
||||
log.info(tag_names)
|
||||
m_tags = form.cleaned_data['m_tags']
|
||||
m_tags = form.cleaned_data['tags']
|
||||
m_tags = ' '.join(str(m_tags) for m_tags in m_tags)
|
||||
log.info(m_tags)
|
||||
if m_tags in tag_names:
|
||||
|
||||
Reference in New Issue
Block a user