python - Colon in variable identifier -


is possible have colon in variable name ? tried backslash doesn't work...

i'm using geodjango identifiers in models have keep same name in database. trouble that, migrated data osm, have columns named colon (ie addr:housenumber)

here's example :

class myclass(models.model): # ... addr:housename = models.textfield(blank=true) 

when i'm trying syncdb :

addr:housename = models.textfield(blank=true)     ^ syntaxerror: invalid syntax 

which seems normal. when try escape colon, have error :

addr\:housename = models.textfield(blank=true)                                              ^ syntaxerror: unexpected character after line continuation character 

i don't understand why got error.

someone knows how put column in identifier ?

use db_column field parameter specify real column name. , yes, colons not allowed in identifiers names in python.

class myclass(models.model):     addr_housename = models.textfield(blank=true, db_column="addr:housename") 

Comments