Wednesday, February 10, 2021

Re: Model.objects.create as default

ok thanks

Le mer. 10 févr. 2021 à 01:42, Rama akki <sonulucky777@gmail.com> a écrit :
Better, you can use signal or model manager with one-to-one relationship

On Sat, 6 Feb 2021, 7:13 pm degnon...@gmail.com, <degnonfrancis@gmail.com> wrote:
hi, say I have this model

class Event(models.Model):
  ...
  metrics = models.OneToOneField("evmetrics.Metrics", on_delete=models.PROTECT,
default=Metrics.objects.create)

I want to be sure of what I'm writing here, for each new Event object created, a new Metrics object will be create and link to the event by a OneToOne relationship, is there any chance this is really bad code or this could be a problem ?

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/541e8075-0ded-41cd-a565-e552c66a0183n%40googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/Iw83-HaVevc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAAmXcB67yeFY%2Bv-ASUKu3bVEUVUPy%3Difz2fehg%2BKmhd7nDkBnw%40mail.gmail.com.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACeK5b%3DTb1qqrUtwCONgmBt%2BM6do91T9h2G1rOuj8Z06%2Bi%2Bm4A%40mail.gmail.com.

No comments:

Post a Comment