I've been reading the documentation and have some questions about certain behaviour.
1 Why does calling .clear() on a intermediate model, delete the intermediate models? source<https://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships> >>> Membership.objects.all() [<Membership: Membership object>, <Membership: Membership object>] >>> beatles.members.clear() >>> Membership.objects.all() [] I thinkk that the Membership models should still exist but just not be associated with the Group model. 2 Why can't you call create on a intermediate model and pass the required fields? For example. >>> john = Person.objects.create(name="John Lennon") >>> beatles.members.create(person=john, date_joined=date(1960, 8, 1), invite_reason="Wanted to form a band.") 3 Why do Q objects use '&', '|' and '~' for AND, OR and NOT when python uses 'and', 'or' and 'not'? source<https://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects> 4 Due to how inheritance works, you have to set both pk and id to None: django_blog.pk = None django_blog.id = None django_blog.save() # django_blog.pk == 4 source<https://docs.djangoproject.com/en/dev/topics/db/queries/#copying-model-instances> Why is this? 5 When using aggregate why do you get a dictionary instead of a value? # Average price across all books. >>> from django.db.models import Avg >>> Book.objects.all().aggregate(Avg('price')) {'price__avg': 34.35} So you have to do average_price = Book.objects.all().aggregate(Avg('price')) ['price__avg'] 6. Why do Max, Sum, etc take a string a parameter while .filter() does not? Are they inconsistent to easier tell them apart? -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/87e6de2a-72bb-476f-bbec-610f7fefa41f%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
