Entity has an event Lifecycle, how does Django do it?

38 views
Skip to first unread message

Glyn Jackson

unread,
Dec 19, 2012, 4:53:40 AM12/19/12
to django...@googlegroups.com
In other languages and frameworks I have used when you have an entity such as user. Each entity has an event lifecycle i.e. post update, pre update, post save etc

The following code below is my first save using Django. But its looks very messy, it should be than user has a pre create for member and member has a pre create for user depending on which way you are coming at it
In Django is this possible?     


in my views.py


 user = User.objects.create_user(
                                            username=form.cleaned_data.get()['username'],
                                            email=form.cleaned_data['email'],
                                            password=form.cleaned_data['password']
                                            )
user.save()
member = Member(
                            user=user,
                            name=form.cleaned_data['name']
                            )
member.save()

Sergiy Khohlov

unread,
Dec 19, 2012, 5:26:48 AM12/19/12
to django...@googlegroups.com
Have you checked https://docs.djangoproject.com/en/dev/topics/auth/ ?

Allso views and forms for this one are already created
Many thanks,

Serge


+380 636150445
skype: skhohlov


2012/12/19 Glyn Jackson <cfsp...@gmail.com>:
> --
> 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/-/M2vbXJQCJQAJ.
> 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.

Russell Keith-Magee

unread,
Dec 19, 2012, 6:29:28 PM12/19/12
to django...@googlegroups.com
Hi Glyn,

What you're calling "events", Django calls "signals" [1]. In particular, I'm guessing you're looking for the pre_save and post_save signals.

Yours,
Russ Magee %-)


--

Glyn Jackson

unread,
Dec 20, 2012, 4:22:53 AM12/20/12
to django...@googlegroups.com
@Russel, right, now I know what i'm looking for it makes it easier lol. thank you signals is what I needed.
Reply all
Reply to author
Forward
0 new messages