Removed title and slug field from blogpost model and db

This commit is contained in:
2016-02-25 09:37:03 +01:00
parent 5b033803a8
commit 62ec42297d
9 changed files with 14 additions and 43 deletions

View File

@@ -23,19 +23,15 @@ from django.contrib import admin
class PostAdmin(admin.ModelAdmin):
# fields display on change list
list_display = ['title']
list_display = ['content']
# fields to filter the change list with
list_filter = ['published', 'created']
# fields to search in change list
search_fields = ['title', 'content']
search_fields = ['content']
# enable the date drill down on change list
date_hierarchy = 'created'
# enable the save buttons on top on change form
save_on_top = True
# prepopulate the slug from the title - big timesaver!
prepopulated_fields = {"slug": ("title",)}
admin.site.register(Team)
admin.site.register(Match)

View File

@@ -46,7 +46,7 @@ class TippForm(forms.Form):
class BlogpostForm(ModelForm):
class Meta:
model = Post
fields = ['title', 'content']
fields = ['content']
class UserForm(forms.ModelForm):
class Meta:

View File

@@ -112,8 +112,6 @@ class RelUserMandant(models.Model):
return (str(self.user) + " -> " + str(self.mandant))
class Post(models.Model):
title = models.CharField(max_length=255, null=False, blank=False)
slug = models.SlugField(unique=True, max_length=255)
content = models.TextField()
published = models.BooleanField(default=True)
created = models.DateTimeField(auto_now_add=True)
@@ -123,9 +121,6 @@ class Post(models.Model):
ordering = ['-created']
def __unicode__(self):
return u'%s' % self.title
def get_absolute_url(self):
return reverse('tipp.views.blogpost', args=[self.slug])
return u'%s' % self.created

View File

@@ -449,17 +449,6 @@ def blogindex(request, page):
'page': page
})
@login_required
def blogpost(request, slug):
# get the Post object
post = get_object_or_404(Post, slug=slug)
# now return the rendered template
return render(request, 'blogpost.html', {
'post': post,
'ls': get_current_ls(),
'season': get_current_season()
})
@login_required
def newBlogpost(request):
"""
@@ -470,12 +459,8 @@ def newBlogpost(request):
form = BlogpostForm(request.POST)
# check whether it's valid:
if form.is_valid():
# process the data
# fix me
# What to to, if subject is empty?
data = form.cleaned_data
slug = slugify(data['title'])
p = Post(author_id=request.user.id, slug=slug, title=data['title'], content=data['content'])
p = Post(author_id=request.user.id, content=data['content'])
p.save()
# ...