Hi, working on my first django app, and run into a problem.
I tend to create geodjango objects, and add all data from external tables with pk.
Then I want to have different geometries 8points, lines, polygons) into a unique polymorphic class, can I do that?
I have an error that I'll document later, and I'm trying to figure out what to do.
Here is the model:
from django.db import modelsfrom django.contrib.gis.db import models as geomodelsfrom django.utils import timezonefrom django.forms import ModelFormfrom polymorphic import PolymorphicModel
# Geometria linea da monitorareclass geolinea(geomodels.Model): progetto = models.CharField(max_length=14, primary_key=True) geom = geomodels.MultiLineStringField() objects = geomodels.GeoManager() def __str__(self): return '%s' % (self.progetto)# Oggetto Progetto soggetto a PMAclass linea(models.Model): progetto = models.ForeignKey(geolinea) nome = models.CharField(max_length=200) TENSIONE = ( ('132', '132kV'), ('150', '150kV'), ('220', '220kV'), ('380', '380kV'), ) tensione = models.CharField(max_length=5, choices=TENSIONE) def __str__(self): return '%s' % (self.nome)
# Geometria dei pdmclass pdmpunto(geomodels.Model): linea = models.ForeignKey(linea) numero = models.CharField(max_length=3) geom = geomodels.PointField() objects = geomodels.GeoManager()
class pdmtransetto(geomodels.Model): linea = models.ForeignKey(linea) numero = models.CharField(max_length=3) geom = geomodels.LineStringField() objects = geomodels.GeoManager()
class pdmarea(geomodels.Model): linea = models.ForeignKey(linea) numero = models.CharField(max_length=3) geom = geomodels.PolygonField() objects = geomodels.GeoManager()
class pdm(PolymorphicModel): numero = models.CharField(max_length=14, primary_key=True)class punto(pdm): rifpunto = models.ForeignKey(pdmpunto)class transetto(pdm): riftransetto = models.ForeignKey(pdmtransetto)class area(pdm): rifarea = models.ForeignKey(pdmarea)
class PolyModel(pdmpunto, pdmtransetto, pdmarea):
pass
Visit this group at https://groups.google.com/group/django-users.--
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...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cd243d25-0aff-446d-b9c9-cb5682d9bdf3%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/70b475b9-34d7-498c-ad1f-d27f020d02d0%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9da11934-7a41-40b3-be7c-d6bbb876a29c%40googlegroups.com.