I seem to be having trouble understanding some of how form validation 
works, resulting in two problems. 

I am trying to write a CreateView in which a user can type in an item 
number, and the program will use that instead of the item's primary key to 
perform the lookup. 

The docs appear to recommend overriding form_valid, but these are the 
issues I've been running into: 

   1. I would need duplicate code in both form_valid and form_invalid 
   because the item number entered by the user may or may not also happen to 
   be a primary key for a different item. As far as I've seen, Django assumes 
   that the input is a primary key, and will call either method as appropriate 
   based on whether or not it could find an item with that primary key.
   2. Overriding form_invalid doesn't seem to be working anyway:
   - Django appears to clean data before validating it, and I believe 
      cleaned data is immutable. 
      - CreateView has no clean() method to override that I can find 
      (either here 
      
<http://ccbv.co.uk/projects/Django/2.0/django.views.generic.edit/CreateView/> 
or 
      the source code itself on github)
      - I made a ModelForm to use with CreateView expressly for the clean() 
      methods it offers, but neither clean() nor clean_<field> are being called 
      (my breakpoints are being skipped). 
   
Does anybody know a way to accomplish this? How does CreateView clean its 
data? Any suggestions would be helpful.

Thank you!
Heather

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" 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].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/af2a159b-5ba8-4939-bf48-c89ba7ebd710%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to