Created
May 20, 2011 14:39
-
-
Save andreypopp/983040 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PGArrayField(models.Field): | |
""" Custom field for mapping between postgresql array and python list.""" | |
def __init__(self, element_field, **kwargs): | |
self.element_field = element_field | |
models.Field.__init__(self, **kwargs) | |
def db_type(self, *connection): | |
return '%s[]' % self.element_field.db_type(*connection) | |
def to_python(self, value): | |
# psycopg2 handles arrays with care | |
return value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment