@@ -6,7 +6,7 @@ from django.contrib.auth.forms import UserCreationForm, UserChangeForm | |||
class PostForm(forms.ModelForm): | |||
class Meta: | |||
model = Post | |||
fields = ('title', 'text', 'published_date', 'tags') | |||
fields = ('title', 'text', 'published_date','tags') | |||
class NewTagForm(forms.ModelForm): | |||
m_tags = TagField() |
@@ -4,7 +4,7 @@ from django.utils import timezone | |||
from taggit.managers import TaggableManager | |||
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() | |||
@@ -13,6 +13,6 @@ urlpatterns = [ | |||
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+)/remove/$', views.post_remove, name='post_remove'), | |||
url(r'^tags/', include('taggit_templatetags2.urls')), | |||
url(r'^tags/', include('taggit_templatetags2.urls')), | |||
] | |||
@@ -79,6 +79,7 @@ def post_edit(request, pk): | |||
post = form.save(commit=False) | |||
post.author = request.user | |||
post.save() | |||
form.save_m2m() | |||
return redirect('post_detail', pk=post.pk) | |||
else: | |||
form = PostForm(instance=post) |