Wednesday, July 27, 2022

Re: ForeignKey Reverse Relation Fail

Hi
Have you tried using OneToMany relationship ?

On 27 Jul 2022 12:18, "Malik Rumi" <malik.a.rumi@gmail.com> wrote:
I have a model with a recursive foreign key to 'self'. This is intended to model a parent child
relation among instances. The forward relation, on a field called 'childof', works as expected.
The reverse relation, using the related_name 'parent', comes up as a RelatedManager,
again as expected. However, parent.count(), parent.all(), etc., always give me the "Manager is
not accessible on instances" error. Many of these parent instances will themselves also be a
childof some other instance, and apparently, that's my problem. I don't know how to make Django
recognize the dual nature of some instances. Is there a way to hack the RelatedManager to fix this?

I am not getting any accessor errors from manage.py check.

I posted this to Django Forum, but the respondent was not able to duplicate my issue - i.e.,
he said it worked as expected for him. :-(

I saw a suggestion to use an explicit junction table on Stack Overflow, but making a round trip - or two - to an external table seems like an
awful lot of overhead for this situation.

If instead of a junction table, if I made an explicit parentto field on the model, would that work?
Presumably the related name on the childof field would still fail like it does now,
but I would instead have the explicit parent field to work with. I still would not have the
automatic reverse relation, and I would have to come up with a script to fill in the parentto
field, but that might solve my problem:
# pseudocode
family = c.itertools.groupby(instance.childof)
family = c.pandas.groupby(instance.childof)
for f in family:
pop = c.objects.get(instance.childof)
OR
pop = instance.childof
c.objects.update(pop.parentto=f) # where parentto is a Postgresql ArrayField
OR # https://docs.djangoproject.com/en/4.0/ref/models/relations/#django.db.models
.fields.related.RelatedManager.add:
>>> b = Blog.objects.get(id=1)
>>> e = Entry.objects.get(id=234)
>>> b.entry_set.add(e) # Associates Entry e with Blog b
SEE ALSO: https://docs.djangoproject.com/en/4.0/topics/db/examples/many_to_one/

If I did this two field hack, then I don't really need either one to be ForeignKeys any more,
do I? They could be a CharField and an ArrayField, couldn't they? That breaks the extended
lookup chain - but I don't have that now, anyway - or at least, I only have it in one direction.

--
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/3555d391-9c9e-440f-a603-103c9ccdc858n%40googlegroups.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/CAHs1H7tjom_GRucP8Dx3x8AzQobS4GCva8a0nuN3bEWVB2Taqw%40mail.gmail.com.

Re: Django tutor.

Hi
Yes of course
Available every weekend !

Ammar Mohammed

On 27 Jul 2022 15:49, "pediah wanmi" <pediahw@gmail.com> wrote:
I am a djongk intermediary, please can I
 get a tutor?

--
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/CABd3QauHU4wdePFvGsY3V-GSO8Ly37zMqgmcV2tyDV56Sw81Tw%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/CAHs1H7t9Uh35%2B8pdsN1JjMLqphkimWaHwoRusWuhx8mndgsZLQ%40mail.gmail.com.

Re:Django tutor.

Show Django Official website 

Sent from my Huawei phone


-------- Original message --------
From: pediah wanmi <pediahw@gmail.com>
Date: Wed, Jul 27, 2022, 5:22 PM
To: django-users@googlegroups.com
Subject: Django tutor.
I am a djongk intermediary, please can I
 get a tutor?

--
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/CABd3QauHU4wdePFvGsY3V-GSO8Ly37zMqgmcV2tyDV56Sw81Tw%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/dun4asa4bdzxtzjwj4-3qjf8j-urdlt42i1gaiz8sfaua9chke-albmexg650pjd8w9no-mjoqq4cguikj-bk51if-em08lf-jw7g21idl3xdyre5d8-v97n9i-lanxvz6om99w-w4oi0-dog49dbovagl.1658932720646%40email.android.com.

Re: Django tutor.

You always consult, anytime you need help...

On Wed, Jul 27, 2022, 2:49 PM pediah wanmi <pediahw@gmail.com> wrote:
I am a djongk intermediary, please can I
 get a tutor?

--
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/CABd3QauHU4wdePFvGsY3V-GSO8Ly37zMqgmcV2tyDV56Sw81Tw%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/CAP%2BiQEYyo9a%2BFu%2BjDzxGh6snMH2sNg30jecQQYW1sYTwWXWhcA%40mail.gmail.com.

Django tutor.

I am a djongk intermediary, please can I
 get a tutor?

--
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/CABd3QauHU4wdePFvGsY3V-GSO8Ly37zMqgmcV2tyDV56Sw81Tw%40mail.gmail.com.

ForeignKey Reverse Relation Fail

I have a model with a recursive foreign key to 'self'. This is intended to model a parent child
relation among instances. The forward relation, on a field called 'childof', works as expected.
The reverse relation, using the related_name 'parent', comes up as a RelatedManager,
again as expected. However, parent.count(), parent.all(), etc., always give me the "Manager is
not accessible on instances" error. Many of these parent instances will themselves also be a
childof some other instance, and apparently, that's my problem. I don't know how to make Django
recognize the dual nature of some instances. Is there a way to hack the RelatedManager to fix this?

I am not getting any accessor errors from manage.py check.

I posted this to Django Forum, but the respondent was not able to duplicate my issue - i.e.,
he said it worked as expected for him. :-(

I saw a suggestion to use an explicit junction table on Stack Overflow, but making a round trip - or two - to an external table seems like an
awful lot of overhead for this situation.

If instead of a junction table, if I made an explicit parentto field on the model, would that work?
Presumably the related name on the childof field would still fail like it does now,
but I would instead have the explicit parent field to work with. I still would not have the
automatic reverse relation, and I would have to come up with a script to fill in the parentto
field, but that might solve my problem:
# pseudocode
family = c.itertools.groupby(instance.childof)
family = c.pandas.groupby(instance.childof)
for f in family:
pop = c.objects.get(instance.childof)
OR
pop = instance.childof
c.objects.update(pop.parentto=f) # where parentto is a Postgresql ArrayField
OR # https://docs.djangoproject.com/en/4.0/ref/models/relations/#django.db.models
.fields.related.RelatedManager.add:
>>> b = Blog.objects.get(id=1)
>>> e = Entry.objects.get(id=234)
>>> b.entry_set.add(e) # Associates Entry e with Blog b
SEE ALSO: https://docs.djangoproject.com/en/4.0/topics/db/examples/many_to_one/

If I did this two field hack, then I don't really need either one to be ForeignKeys any more,
do I? They could be a CharField and an ArrayField, couldn't they? That breaks the extended
lookup chain - but I don't have that now, anyway - or at least, I only have it in one direction.

--
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/3555d391-9c9e-440f-a603-103c9ccdc858n%40googlegroups.com.

Tuesday, July 26, 2022

Re: hello users


On Mon, 25 Jul 2022 at 19:04, Aliyu Muazu <aliyumuazu0767@gmail.com> wrote:
i'm currently new here, any guide up on where to start.
thanks

--
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/522cf16d-148c-4291-baa8-c99577f103fcn%40googlegroups.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/CAGp2JVGbEHoFjUqf9jO0JtBad-BeCppN1TTo361qSDNypg640w%40mail.gmail.com.