Re: Custom form field

2011-04-23 Thread Karen Tracey
On Wed, Apr 20, 2011 at 11:06 AM, Daniel Gagnon wrote: > The first one uses a jquery plugin that's discontinued and the second one > works only in the admin. > > There is also: https://bitbucket.org/mlavin/django-selectable Karen -- http://tracey.org/kmt/ -- You received this message because

Re: Custom form field

2011-04-22 Thread Derek
On Apr 20, 5:06 pm, Daniel Gagnon wrote: "The first one uses a jquery plugin that's discontinued and the second one works only in the admin." But that first project is live; did you contact the author and ask him/ her about plans to update it (especially as the jquery plugin in question has a cl

Re: Custom form field

2011-04-20 Thread Daniel Gagnon
> > > It probably is related to the this being a foreign key field and in > order for it to produce a valid object instance from the Target model, > it needs a queryset. Try to subclass from ModelChoiceField[1] and see > if that works. > > [1] > http://code.djangoproject.com/browser/django/trunk/dj

Re: Custom form field

2011-04-20 Thread Daniel Gagnon
New code: from django.forms.widgets import Select from django.forms.models import ModelChoiceField from Server_Automation.target_mgmt.models import Target class AutoCompleteWidget(Select): def render(self, name, value, attrs=None, choices=()): logger.debug(value) # Logs 1 (the i

Re: Custom form field

2011-04-20 Thread DrBloodmoney
On Wed, Apr 20, 2011 at 12:45 PM, Daniel Gagnon wrote: > Sure, here's a minimal version of them (I skipped fields that aren't too > relevant to the problem at hand because there's many, including tons of > foreign keys): > class Target(Model): >     name = CharField("Target Name", max_length=255,

Re: Custom form field

2011-04-20 Thread Daniel Gagnon
Sure, here's a minimal version of them (I skipped fields that aren't too relevant to the problem at hand because there's many, including tons of foreign keys): class Target(Model): name = CharField("Target Name", max_length=255, unique=True) created = DateTimeField(auto_now_add=True, edita

Re: Custom form field

2011-04-20 Thread DrBloodmoney
On Wed, Apr 20, 2011 at 12:30 PM, Daniel Gagnon wrote: > Thanks > It still doesn't work though. I found out through logging that value that is > receive is an int (the id) instead of being the object itself. How can I > make my widget pass the object itself to the widget instead of passing > objec

Re: Custom form field

2011-04-20 Thread Daniel Gagnon
Thanks It still doesn't work though. I found out through logging that value that is receive is an int (the id) instead of being the object itself. How can I make my widget pass the object itself to the widget instead of passing object.id ? On Wed, Apr 20, 2011 at 12:17 PM, DrBloodmoney wrote: >

Re: Custom form field

2011-04-20 Thread DrBloodmoney
On Wed, Apr 20, 2011 at 11:48 AM, Daniel Gagnon wrote: > So far, I have the following code: > from django.forms.widgets import TextInput > from django.forms.fields import Field > class AutoCompleteWidget(TextInput): >     def render(self, name, value, attrs=None): >         if hasattr(value, 'name

Re: Custom form field

2011-04-20 Thread Daniel Gagnon
So far, I have the following code: from django.forms.widgets import TextInput from django.forms.fields import Field class AutoCompleteWidget(TextInput): def render(self, name, value, attrs=None): if hasattr(value, 'name'): v = value.name else: v = Non

Re: Custom form field

2011-04-20 Thread Daniel Roseman
On Wednesday, April 20, 2011 4:20:04 PM UTC+1, Dan wrote: > > I'm trying to create a Form Field, not a Model Field. > > The doc about creating a custom one is a tiny paragraph at the end of this > page: http://docs.djangoproject.com/en/1.3/ref/forms/fields/ > > I read the source code of django but

Re: Custom form field

2011-04-20 Thread Daniel Gagnon
I'm trying to create a Form Field, not a Model Field. The doc about creating a custom one is a tiny paragraph at the end of this page: http://docs.djangoproject.com/en/1.3/ref/forms/fields/ I read the source code of django but I'm having trouble even finding where exactly is the value stored in t

Re: Custom form field

2011-04-20 Thread Shawn Milochik
http://docs.djangoproject.com/en/1.3/howto/custom-model-fields/ What specific problems/errors are you experiencing? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscri

Re: Custom form field

2011-04-20 Thread Daniel Gagnon
The first one uses a jquery plugin that's discontinued and the second one works only in the admin. Also, I feel I'm missing something that's not so complex... On Wed, Apr 20, 2011 at 10:48 AM, Shawn Milochik wrote: > Maybe just save your time and re-use some tasty open-source. > > Examples: > >

Re: Custom form field

2011-04-20 Thread Shawn Milochik
Maybe just save your time and re-use some tasty open-source. Examples: http://code.google.com/p/django-ajax-selects/ http://code.google.com/p/django-autocomplete/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: Custom form field validation and required=False

2010-07-17 Thread Paddy Joy
Thanks for that, using: from django.core import validators . . class ExistingUserField(forms.CharField): def clean(self, value): if value in validators.EMPTY_VALUES: return value did the trick. Paddy On Jul 17, 3:31 am, Nuno Maltez wrote: > Hi, > > Looking at Django's f

Re: Custom form field validation and required=False

2010-07-16 Thread Nuno Maltez
Hi, Looking at Django's forms/fiedls.py may give you some ideas. The test for an empty value is if value in validators.EMPTY_VALUES You can also use self.required to see if the required attribute is set (e.g., see Field's validate() method). Of course, a username with a single space will still

Re: custom form field validation

2010-07-15 Thread refreegrata
ok, for my problem that don't works because when i set required=False the field isn't evaluated when it is in blank. I want an evaluation for my function in every situation. With required=True and a custom error message an evaluation can be simulated but if i do a code inside the function in that c

Re: custom form field validation

2010-07-15 Thread Oleg Lomaka
http://docs.djangoproject.com/en/1.2/ref/forms/fields/#required usu = forms.CharField(required=False, ...) On Jul 15, 2010, at 5:25 PM, refreegrata wrote: > Hello list. I'm a newie in django with many questions. I want to do > something like this: > --

Re: Custom form field overrides model attributes?

2008-04-20 Thread Berco Beute
Thanks, Phil! That works perfectly. The only thing that feels awkward about Django's models is that the attributes feel like a mixture of stuff that belongs to the view and stuff that belongs to the model (blank=True, null=True anybody?). But that's about the only small complaint I have about Dja

Re: Custom form field overrides model attributes?

2008-04-20 Thread Juanjo Conti
Berco Beute escribió: > Using: Latest from trunk > > I'm using a custom widget for datetimefields: > BTW, which one are you using? The one that wrappers jscalendar? Juanjo -- mi blog: http://www.juanjoconti.com.ar --~--~-~--~~~---~--~~ You received this messag

Re: Custom form field overrides model attributes?

2008-04-20 Thread Phil Davis
On 20/04/2008, Berco Beute <[EMAIL PROTECTED]> wrote: > > Using: Latest from trunk > > I'm using a custom widget for datetimefields: > > == > #models.py > class Event(models.Model): > endDateTime = models.DateTimeField('Finish', blank=True, > null=True

Re: Custom form field overrides model attributes?

2008-04-20 Thread Malcolm Tredinnick
On Sun, 2008-04-20 at 02:20 -0700, Berco Beute wrote: > Using: Latest from trunk > > I'm using a custom widget for datetimefields: > > == > #models.py > class Event(models.Model): > endDateTime = models.DateTimeField('Finish', blank=True, > null=True) >