Wednesday, August 20, 2014

Re: How to delete a referenced object when the object, referencing the other object, is deleted?

On Wed, Aug 20, 2014 at 4:34 PM, Oliver Funk <oli.funk@gmail.com> wrote:
> I posted the following question on SO (link) and I haven't received any
> helpful answers. Can someone here please help me?

Sorry, same answers here - move the OneToOne to the other model or use
pre_delete signals to check how many related objects there will be
post delete.

You can simplify the whole logic by removing the need for two classes
- a Todo is a Reminder with null/empty start/stop time.

> Also, with regards to:
>
> stop_time = models.DateTimeField(blank=True)
>
> If it is left blank in the form, what will the default value be, stored in
> the database?
>

I don't know; whenever I have a DateTimeField that is potentially not
specified, I will specify the field as "blank=True, null=True". In
that scenario, Django stores NULL as the date in the database,
represented as None in python.

Cheers

Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFHbX1Lm4y%3DAYSe73rDf7AiaX%2B7rY-DQaVw0gQJWoQFjeF59cA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment