11125

how does django model after text[] in postgresql [duplicate]

<strong>Possible Duplicate:</strong> How to map PostgreSQL array field in Django ORM

I have a table wit one of the columns of datatype text[] in postgresql. May I know how do I access this column using django models orm? I'm aware that theres a commaseparatedintegerfield, but no such for text related fields. Do i use textfield or need to create a custom field for this?

Answer1:

I don't think Django ORM supports PostgreSQL arrays. It's unsurprising, as this looks like a fairly PostgreSQL-specific feature. If you really have to use arrays, your best bet is to construct SQL queries as text by hand. Otherwise, just turn the array columns into tables, as Mark suggests; that is by far a more portable and conceptually clean solution (although the performance may be lower).

Answer2:

There are often times when the PostgreSQL array field is the right solution. For instance, when working with a legacy database. The django-dbarray project on github adds support for this. I haven't used it, but it looks like usage is basically:

from django.db import model import dbarray class Person(models.Model): birthdate = models.DateField() nicknames = dbarray.TextArrayField()

Recommend

  • Java class containing only private members
  • codeigniter active records join with using?
  • Multiplot and change line color depending on column value in Zingchart
  • UITextField — observe changes to selectedTextRange?
  • for loop iteration in django
  • AngularJS: Returning a promise in directive template function
  • Limit the number of documents in a collection in mongodb
  • Mysql not union
  • php: best way to validate POST
  • Client server multithread Socket
  • Flickr API using javascript
  • How can I use special characters in angular directives attributes?
  • How to get the relative position of a Dictionary element?
  • symfony render json_array entity type and save using form
  • C++ accessing vector
  • Does Context/Scoping of a SQLAlchemy Session Require Non-Automatic Object/Attribute Expiration?
  • Doctrine2 inverse persistance not working in nested forms
  • Iterate twice through a DataReader
  • How to set an entity field that does not exist on the table but does exists in the raw SQL as an ali
  • KnockoutObservableArray with typed elements in TypeScript
  • OSX - always hide certain files
  • SAVE attribute needed for Fortran variables when only the C_LOC address is returned to a C program?
  • Why cepheus don't send int without quotes to orion?
  • Tamper-proof configuration files in .NET?
  • How can I enlarge video fullscreen without the affected interface project in as3?
  • Rails Find when some params will be blank
  • C++ Partial template specialization - design simplification
  • NHibernate Validation Localization with S#arp Architecture
  • How can I send an e-mail from a vbs script
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • Bug in WPF DataGrid
  • Can Jackson SerializationFeature be overridden per field or class?
  • WinForms: two way TextBox problem
  • Redux, normalised entities and lodash merge
  • Adding custom controls to a full screen movie
  • Comma separated Values
  • Error creating VM instance in Google Compute Engine
  • Hits per day in Google Big Query
  • how does django model after text[] in postgresql [duplicate]
  • Cant find why the layout is getting smaller