I really hope someone can shed some light on this problem,
I have built a new and blog app that I’m using in a django cms site. The client requested that blog and news posts go through an editor before they are published to the website
To accomplish this I did the following
def publish(self, request, queryset):
rows_updated = queryset.update(status='p')
if rows_updated == 1:
message_bit = "1 story was"
else:
message_bit = "%s stories were" % rows_updated
self.message_user(request, "%s successfully marked as published." % message_bit)
def un_publish(self, request, queryset):
rows_updated = queryset.update(status='w')
if rows_updated == 1:
message_bit = "1 entry was"
else:
message_bit = "%s entries were" % rows_updated
self.message_user(request, "%s successfully marked as un-published." % message_bit)
in the model admin for each model (blog and news) this allows the client to update the status of the blog or new post to published etc. However, client has also requested that they be able to preview the posts before they are published. As my blog and new query sets only return posts that have a status of ‘p’ for published the new/blog matching queries fail when trying to view the posts using the Preview on site feature built into django’s admin interface
Has anyone got a work around for this of perhaps recommend something i could try to get this working
Thanks
To keep code clean you can create separate view that renders page the same way as standard one but does not filter over status.
Than to have admin link working edit/add get_absolute_url so in case of state=”w” it returns address for the new view. I.e:
PS: If you are a purist you may prefer using permalink decorator 🙂
See: http://docs.djangoproject.com/en/dev/ref/models/instances/