Hello,
On Monday, October 26, 2015 at 7:18:24 AM UTC-4, Luca Moiana wrote:
-- Are you trying to combine multiple models into one, like this?
class PolyModel(pdmpunto, pdmtransetto, pdmarea):
pass
You could also try asking on the geodjango list: http://groups.google.com/group/geodjango
Collin
On Monday, October 26, 2015 at 7:18:24 AM UTC-4, Luca Moiana wrote:
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:
import datetime
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)
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/45f813d4-c476-4cc5-a299-03fb10edd6b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment