How to do some additional process while saving a django flatpage

38 views
Skip to first unread message

Swaroop Shankar V

unread,
Oct 2, 2011, 10:03:12 AM10/2/11
to django...@googlegroups.com
Hi,
I am trying to build a menu system which can be controlled at the admin area. For the content management purpose i am using django flatpage. So when a page is getting saved i need to insert the page title and url in the menu table i have created. So i guess a flatpage signal is the best way to go, but after searching a lot i could not find any such signals available for flatpage. So which is the best approach to implement whatever i had described above. Thanks
Regards,

Swaroop Shankar V

Phang Mulianto

unread,
Oct 3, 2011, 3:05:11 AM10/3/11
to django...@googlegroups.com

why not query your flatpage db and use the field for the menu in ur table.. flatpage have url and title.. get url n title and put in your menu template..no need signaling....
can add cache to as the flatpage not modified to often..

> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>

Swaroop Shankar V

unread,
Oct 3, 2011, 5:44:02 AM10/3/11
to django...@googlegroups.com
Hello Phang,

Thanks for your reply. Well the requirement is like when ever a page is created i want to save an entry into the menu table to. This is to be an automatic process. If i understand correctly, the method you suggested will require a manual process or a cron running to fetch the data from the flatpage table and then enter it into my menu table. So is there any way to make it an automated process?

Thanks and Regards,

Swaroop Shankar V

Daniel Roseman

unread,
Oct 3, 2011, 6:51:21 AM10/3/11
to django...@googlegroups.com
You don't need a specific flatpages signal. You can just use the normal pre-save signal and attach the listener to flatpages only.

from django.db.models.signals import pre_save
from django.dispatch import receiver
from django.contrib.flatpages.models import FlatPage

@receiver(pre_save, sender=FlatPage)
def my_handler(sender, **kwargs):
   ...


--
DR.

Swaroop Shankar V

unread,
Oct 3, 2011, 11:52:31 AM10/3/11
to django...@googlegroups.com
Thanks a lot Daniel, I guess this is exactly what I require. Will check it and revert back.

Thanks and Regards,
Swaroop Shankar V



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/-xs77MXmBh0J.

Swaroop Shankar V

unread,
Nov 27, 2011, 10:26:15 AM11/27/11
to django...@googlegroups.com
Well Daniel, I tried this but i am not able to see the function being called while saving any flatpage page. Is it possible to give me a step by step instruction on how to achieve the same? I read through the signals documents but i am kind of confused on where to include the signal related statements since the document do not give much details about it. I am still not able to completely understand the signal's system in django. So I would request for a step by step instruction, if its possible. Thanks

Regards,
Swaroop Shankar V
Reply all
Reply to author
Forward
0 new messages