Well, the simplest way is making DictionaryField more like CharField, except
that it's values will be stored in separate table. For example (application
name is "hardware", engine is sqlite3), if I define

*class HDD(models.Model):
  form_factor = DictionaryField(max_length=10)
  capacity = models.FloatField()
*
there will be 2 tables generated:

*CREATE TABLE "hardware_hdd_form_factor_dict" (
    "id" integer NOT NULL PRIMARY KEY,
    "form_factor" varchar(10) NOT NULL UNIQUE
)
CREATE TABLE "hardware_hdd" (
    "id" integer NOT NULL PRIMARY KEY,
    "form_factor_id" integer NOT NULL REFERENCES
"hardware_hdd_form_factor_dict" ("id"),
    "capacity" real NOT NULL
)

* I guess, field constructor should not accept "unique" argument as it make
no sense.
I see 2 ways of rendering such field on a form:
1) usual <input> with autocompletion;
2) <select> + <input> + (maybe) radio buttons
as it should be allowed to choose from existing and to create new dictionary
item.

2010/1/17 Łukasz Rekucki <lreku...@gmail.com>

> Could you describe this more closely? I don't think I quite follow.
> What those auto-generated tables would contain? What would be
> acceptable values for this field ?
> --
> Łukasz Rekucki
>
>
-- 
regards,
Mihail
--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.

Reply via email to