model Field subclass + validation

2015-11-01 Thread Luke M
Hi folks, I asked a question on StackOverflow and I don't know if it will get any answers because it is quite specific. I would like to subclass a JSONField implementation to add some custom validation logic and don't really know where to start. I would really appreciate if anyone could help out

Re: Model Field Subclass

2010-01-25 Thread Igor Rubinovich
Thanks for the comment Bill. I did define the profile myself :) and I already see this thing working in test :) On Jan 25, 5:10 pm, Bill Freeman wrote: > Just to be clear, who defined get_profile() on the user object?  If not you, > then it may not be returning an instance of your "UserProfile" m

Re: Model Field Subclass

2010-01-25 Thread Bill Freeman
Just to be clear, who defined get_profile() on the user object? If not you, then it may not be returning an instance of your "UserProfile" model, but some other model (e.g.; the pinax Profile app's Profile). That Profile model doesn't have your modified field. Because otherwise, I'd expect your

Re: Model Field Subclass

2010-01-25 Thread Igor
Ok, I've figured the answer myself - but maybe someone will find it useful... When retrieving an ImageField, Django doesn't return the field but rather the underlying ImageFieldFile. So say you have a custom ImageField like this: class Profile(models.Model) ... photo = models.Remo

Re: Model Field Subclass

2010-01-25 Thread Igor
Ok, I've figured the answer myself - but maybe someone will find it useful... When retrieving an ImageField, Django doesn't return the field but rather the underlying ImageFieldFile. So say you have a custom ImageField this: class Profile(models.Model) ... photo = models.ImageFiel

Model Field Subclass

2010-01-24 Thread Igor
Hi all, I'm subclassing ImageField to add another function/property to the standard one (probably will add more later): from django.db import models class RemoteImageField(models.ImageField): def thumbnail_url(self, name): self.storage.thumbnail_url(name) ...and then I do