Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. # models.py
  2. class UserModel(AbstractUser):
  3.     photo = models.FileField(upload_to=get_upload_dir,
  4.                              validators=[validators.photo_technicien_validator, ],
  5.                              null=True, blank=True, )
  6.     description = models.CharField(max_length=2048, null=True, )
  7.  
  8. # views.py
  9. class UserMod(generic_views.UpdateView):
  10.     template_name = 'users/user_edit.html'
  11.     form_class = forms.UserAdminForm
  12.     model = models.UserModel
  13.  
  14. # forms.py
  15. class UserAdminForm(forms.ModelForm):
  16.     class Meta:
  17.         model = models.UserModel
  18.         fields = ('username', 'description', 'photo')
  19.  
  20. # validators.py
  21. def photo_technicien_validator(value):
  22.     from Online import constants
  23.  
  24.     import pdb
  25.     pdb.set_trace()
  26.  
  27.     logger.info('value: {}'.format(value))
  28.     logger.info('run photo technicien')
  29.     raise forms.ValidationError(
  30.         _('photo invalid')
  31.     )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement