Browse Source

edited tag code

newsletter
Esther Kleinhenz 6 years ago
parent
commit
b8a6c16ac2
4 changed files with 4 additions and 3 deletions
  1. 1
    1
      application/forms.py
  2. 1
    1
      application/models.py
  3. 1
    1
      application/urls.py
  4. 1
    0
      application/views.py

+ 1
- 1
application/forms.py View File

class PostForm(forms.ModelForm): class PostForm(forms.ModelForm):
class Meta: class Meta:
model = Post model = Post
fields = ('title', 'text', 'published_date', 'tags')
fields = ('title', 'text', 'published_date','tags')


class NewTagForm(forms.ModelForm): class NewTagForm(forms.ModelForm):
m_tags = TagField() m_tags = TagField()

+ 1
- 1
application/models.py View File

from taggit.managers import TaggableManager from taggit.managers import TaggableManager


class CustomUser(models.Model): class CustomUser(models.Model):
user = models.OneToOneField(User, null = True, on_delete=models.CASCADE)
user = models.OneToOneField('auth.User', null = True, on_delete=models.CASCADE)
tags = TaggableManager() tags = TaggableManager()





+ 1
- 1
application/urls.py View File

url(r'^drafts/$', views.post_draft_list, name='post_draft_list'), url(r'^drafts/$', views.post_draft_list, name='post_draft_list'),
url(r'^post/(?P<pk>\d+)/publish/$', views.post_publish, name='post_publish'), url(r'^post/(?P<pk>\d+)/publish/$', views.post_publish, name='post_publish'),
url(r'^post/(?P<pk>\d+)/remove/$', views.post_remove, name='post_remove'), url(r'^post/(?P<pk>\d+)/remove/$', views.post_remove, name='post_remove'),
url(r'^tags/', include('taggit_templatetags2.urls')),
url(r'^tags/', include('taggit_templatetags2.urls')),
] ]



+ 1
- 0
application/views.py View File

post = form.save(commit=False) post = form.save(commit=False)
post.author = request.user post.author = request.user
post.save() post.save()
form.save_m2m()
return redirect('post_detail', pk=post.pk) return redirect('post_detail', pk=post.pk)
else: else:
form = PostForm(instance=post) form = PostForm(instance=post)

Loading…
Cancel
Save