Hi there,

Are you sure that you want to denormalize your schema like that ?
I now this is a totally different issue and question but in this case
do you really need to perform this operation ? Have considered the
problems that this approach will bring?

Imagine this simple use case:
If one changes the country_of _orign of the Producer that wont reflect
on the Car instance!
I can see some utility for this use but in any case I would review my
requirements.

Cheers,
N.

On Jan 25, 12:36 pm, Euan Goddard <euan.godd...@gmail.com> wrote:
> I agree with the previous poster - the title is misleading as the word
> "method" is incorrect in both places.
>
> It seems that the original poster is talking about denormalizing data.
> However, this is unnecessary as the ORM allows for this type of data
> to be retrieved any how, e.g.
> Car.objects.all().select_related(depth=1) will allow statements like:
> car.producer.country_of_origin
>
> If you want access to country_of_origin directly on the Car instances,
> I'd suggest a property:
>
> @property
> def country_of_origin(self):
>    return self.producer.country_of_origin
>
> Euan
>
> On Jan 25, 11:30 am, bruno desthuilliers
>
>
>
>
>
>
>
> <bruno.desthuilli...@gmail.com> wrote:
> > On 25 jan, 11:57, Jaroslav Dobrek <jaroslav.dob...@gmail.com> wrote:
>
> > > Hi,
>
> > > can I use methods of methods in Django?
>
> > What's a "methods of methods" ???
>
> > > Like so:
>
> > > class Car(models.Model):
> > >     producer = models.ForeignKey(CarProducer)
> > >     country_of_origin = producer.country_of_origin
>
> > What is CarProducer.country_of_origin ? A method ? A model.Field ?
> > Something else ?
>
> > > This doesn't seem to work.
>
> > What happens ? And what did you expect to happen ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to