On Feb 28, 7:07 am, sinanjj <sina...@gmail.com> wrote:
> hello everyone.
> I am doing a GIS related project, with django.
> There is a question that how to get the one-to-one relation class's
> name of a class?
> for example:
> class Thing(models.Model):
>         lat = models.FloatField(default=0.0)
>         lng = models.FloatField(default=0.0)
> class Streetlight(models.Model):
>         thing = models.OneToOneField(Googlemap_thing, primary_key=True)
>         state = models.BooleanField(default=False)
> class Tree(models.Model):
>         thing = models.OneToOneField(Googlemap_thing, primary_key=True)
>         state = models.CharField(max_length=30)
> class House(models.Model):
>         thing = models.OneToOneField(Googlemap_thing, primary_key=True)
>         owner = models.CharField(max_length=30)
>
> Thing is a class that with the comman attribtion in map, lat and lng.
> Streetlight,Tree,House is a "child" class of Thing, using
> OneToOneField to do that.
> For a Thing instance, how to know which class have OneToOne relation
> with it?
>
> Thank you

I would use a generic relation instead of the OneToOne fields. See
http://docs.djangoproject.com/en/1.1/ref/contrib/contenttypes/#id1
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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