Hello guys I want to display labes for a layer in the map from geoserver but geoserver doesn't allow me to display the id field as a label. I created a new value no_man and would like for this field to automatically get the value of the id. If there is a way to display the id label I would remove the no_man, otherwise I would like to populate this field with the value of the id.
models.py
class ww_manholes(models.Model):
id = models.BigIntegerField(primary_key=True)
no_man = models.BigIntegerField()
l_ass_obj = models.BigIntegerField()
l_field_re = models.BigIntegerField()
street = models.BigIntegerField()
zip_code = models.BigIntegerField()
regio_code = models.BigIntegerField()
owner = models.BigIntegerField()
ww_type = models.BigIntegerField()
accuracy = models.BigIntegerField()
x = models.FloatField()
y = models.FloatField()
x_ge = models.FloatField()
y_ge = models.FloatField()
z = models.FloatField()
invert_el = models.FloatField()
inv_start = models.FloatField()
inv_end = models.FloatField()
depth = models.FloatField()
depth_star = models.FloatField()
depth_end = models.FloatField()
material = models.BigIntegerField()
lining = models.BigIntegerField()
coating = models.BigIntegerField()
contractor = models.BigIntegerField()
const_year = models.BigIntegerField()
diam_nom = models.BigIntegerField()
diam_inner = models.BigIntegerField()
joint_type = models.BigIntegerField()
cover_dim = models.BigIntegerField()
cover_mat = models.BigIntegerField()
access = models.BigIntegerField()
rough_coef = models.FloatField()
slope = models.FloatField()
type = models.BigIntegerField()
sc_condit = models.BigIntegerField()
sc_perform = models.BigIntegerField()
sc_fail_pr = models.BigIntegerField()
sc_fin_imp = models.BigIntegerField()
sc_soc_imp = models.BigIntegerField()
sc_leg_imp = models.BigIntegerField()
sc_env_imp = models.BigIntegerField()
sc_red_sl = models.BigIntegerField()
sc_imp_ph = models.BigIntegerField()
sc_imp_rep = models.BigIntegerField()
sc_rep_cos = models.BigIntegerField()
sc_co_fail = models.BigIntegerField()
l_picture = models.CharField(max_length=254)
l_drawing = models.CharField(max_length=254)
key_om = models.FloatField()
comments = models.CharField(max_length=254)
geom = models.MultiPointField(srid=7392)
def __unicode__(self):
return self.id
Adding this to you model would solve your problem mostly.
def __str__(self):
return self.id
UPDATE : As asked
NOT RECOMMENDED but this is how you can copy field value using Django signals:
@receiver(post_save, sender= ww_manholes)
def copy_id(sender, **kwargs):
data = ww_manholes.objects.get(id=kwargs.get('instance').id)
data.no_man = data.id
data.save()