Other attempts to write a clean that would run a print statement and then
call to_python(), validate(), and run_validators() did not result in that
print statement being called.

Am I missing something about data being cleaned? The hooks I've tried to
override don't seem to be being called.

On Mon, Sep 13, 2010 at 3:44 PM, Christos Jonathan Hayward <
christos.jonathan.hayw...@gmail.com> wrote:

> I have a TextURLField defined below, and I am trying to get the clean() to
> prepend http:// to all entries that do not contain a ':'. In other words,
> if someone enters "google.com", I'd like to store "http://google.com";.
>
> Right now it appears not to be making any difference; if I enter an FQDN
> then it just stores the FQDN and nothing more.
>
> What I have is:
>
> class TextURLField(models.URLField):
>     def clean(self, value):
>         if not u':' in value:
>             value = u'http://' + value
>         value = self.to_python(value)
>         self.validate(value)
>         self.run_validators(value)
>         return value
>     def get_internal_type(self):
>         return u'TextField'
>     def __init__(self, *arguments, **keywords):
>         models.URLField.__init__(self, *arguments, **keywords)
>
>
> Any suggestions?
>
> --
> [image: Christos Jonathan Hayward] <http://jonathanscorner.com/>
> Christos Jonathan Hayward, an Orthodox Christian author.
>
> Author Bio <http://jonathanscorner.com/author/> • 
> Books<http://cjshayward.com/>
>  • *Email <christos.jonathan.hayw...@gmail.com>* • 
> Facebook<http://www.facebook.com/christos.jonathan.hayward>
>  • LinkedIn <http://www.linkedin.com/in/jonathanhayward> • 
> Twitter<http://twitter.com/JonathansCorner>
>  • *Web <http://jonathanscorner.com/>* • What's 
> New?<http://jonathanscorner.com/>
> I invite you to visit my "theology, literature, and other creative works"
> site.
>
>


-- 
[image: Christos Jonathan Hayward] <http://jonathanscorner.com/>
Christos Jonathan Hayward, an Orthodox Christian author.

Author Bio <http://jonathanscorner.com/author/> • Books<http://cjshayward.com/>
 • *Email <christos.jonathan.hayw...@gmail.com>* •
Facebook<http://www.facebook.com/christos.jonathan.hayward>
 • LinkedIn <http://www.linkedin.com/in/jonathanhayward> •
Twitter<http://twitter.com/JonathansCorner>
 • *Web <http://jonathanscorner.com/>* • What's
New?<http://jonathanscorner.com/>
I invite you to visit my "theology, literature, and other creative works"
site.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to