#14820: Use `TextField` instead of `PositiveIntegerField` in docs and examples 
for
generic relations.
-----------------------------------------+----------------------------------
               Reporter:  mrmachine      |         Owner:                       
                                                    
                 Status:  new            |     Milestone:  1.3                  
                                                    
              Component:  Documentation  |       Version:  SVN                  
                                                    
             Resolution:                 |      Keywords:  generic relation 
genericforeignkey object_id type textfield sprintdec2010
           Triage Stage:  Accepted       |     Has patch:  1                    
                                                    
    Needs documentation:  0              |   Needs tests:  0                    
                                                    
Patch needs improvement:  0              |  
-----------------------------------------+----------------------------------

Comment (by mrmachine):

 Thanks for your feedback, PaulM.

 As far as I can tell, using `PositiveIntegerField` is the same as
 `IntegerField`, except for some additional form field validation when the
 model is used in a `ModelForm` class. I'm happy to leave the examples as
 using `PositiveIntegerField` if it really makes a practical difference
 anywhere, but I'm not sure that it does.

 There won't be any performance benefit, because it's still the same
 integer field at the database backend. Only when people use the model in a
 `ModelForm` class AND a database backend that doesn't support negative
 integer primary keys (could you elaborate on this point?), they'll get
 some additional validation on that form field to prevent them typing in
 negative values. On the flip side, anyone using the model in a `ModelForm`
 and a database backend that DOES support negative integer primary keys
 will get some additional validation that they might not want.

 At the end of the day, I think the form field validation for `object_id`
 fields is a non-issue. I think that in most cases, people will not assign
 values directly through model forms, and if they do they'll probably add
 their own validation to ensure that the value references an actual object
 in the target model (not just that it is positive). Especially if integer
 fields on some database backends do and some don't support negative
 integers, we should leave this validation out of it.

 All I really care about though is adding a note that character and text
 fields can be used for greater compatibility, for authors of generic apps
 that won't know what types of objects people want to link their models
 through generic relations. If changing the examples from `IntegerField`
 back to `PositiveIntegerField` will get this change committed, I'm all for
 it :)

-- 
Ticket URL: <http://code.djangoproject.com/ticket/14820#comment:12>
Django <http://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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to