#28347: Adding custom attributes to django model field
-------------------------------+--------------------------------------
     Reporter:  Tom Turner     |                    Owner:  nobody
         Type:  Uncategorized  |                   Status:  new
    Component:  Uncategorized  |                  Version:  1.11
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------

Old description:

> I want to add a custom attributes to a Django model field
>

> {{{
> name = models.CharField(max_length=255, data_merge=True)
> }}}
>

> I want to do this so i can loop round my fields and see if this field is
> set.
>
> {{{
>         for field in Project._meta.get_fields(include_parents=False,
> include_hidden=False):
>             if field.extra_info.data_merge:
>                    // do something here
> }}}
>
> I haven't been the first to ask for this see
> [https://stackoverflow.com/questions/20679057/adding-custom-attributes-
> to-django-model-field]
>
> If you accept this enhancement I am happy to write a patch, test and
> documentation. Please let me know.

New description:

 I want to add a custom attributes to a Django model field


 {{{
 name = models.CharField(max_length=255, data_merge=True)
 }}}


 I want to do this so i can loop round my fields and see if this field is
 set.

 {{{
         for field in Project._meta.get_fields(include_parents=False,
 include_hidden=False):
             if field.extra_info.data_merge:
                    // do something here
 }}}

 I haven't been the first to ask for this see
 [https://stackoverflow.com/questions/20679057/adding-custom-attributes-to-
 django-model-field]

 I understand that you might say if you allow any attribute won't be good
 as it could have error. So one could do

 {{{
 name = models.CharField(max_length=255, meta_data={'data_merge':True})
 }}}


 If you accept this enhancement I am happy to write a patch, test and
 documentation. Please let me know.

--

Comment (by Tom Turner):

 Replying to [ticket:28347 Tom Turner]:
 > I want to add a custom attributes to a Django model field
 >
 >
 > {{{
 > name = models.CharField(max_length=255, data_merge=True)
 > }}}
 >
 >
 > I want to do this so i can loop round my fields and see if this field is
 set.
 >
 > {{{
 >         for field in Project._meta.get_fields(include_parents=False,
 include_hidden=False):
 >             if field.extra_info.data_merge:
 >                    // do something here
 > }}}
 >
 > I haven't been the first to ask for this see
 [https://stackoverflow.com/questions/20679057/adding-custom-attributes-to-
 django-model-field]
 >
 > If you accept this enhancement I am happy to write a patch, test and
 documentation. Please let me know.
 >

--
Ticket URL: <https://code.djangoproject.com/ticket/28347#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.6183cf089a6fa4d2c7523d8c735d7de7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to