Wednesday, June 1, 2011

Re: Passing parameters to form class

On 1 June 2011 14:13, skyde <madpoet81@gmail.com> wrote:
Thank you for the links!

I had actually skimmed the first of those and I could not see at the
time how it related to my problem.
The second is very interesting and I'll try to read both of them asap.

Rant begins...
Most of my issues stem of poor understanding of python and not
directly related to django.
This is what you get from trying to understand django with limited
knowledge of python.
Why I haven't had the time to study python is another matter
alltogether...

On Jun 1, 2:15 pm, Derek <gamesb...@gmail.com> wrote:
> On Jun 1, 11:39 am, skyde <madpoe...@gmail.com> wrote:
>
> > Thank you very much! I had not realised the self.fields['vaihtoehdot']
> > part!
>
> > Best regards,
> > skyde
>
> For what it's worth (as this question comes up from time to time and,
> occasionally, people actually search in the archives before asking
> again...), I'll add links to these excellent blog posts, by two of
> Django's core developers, on this topic:
>
> http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/http://jacobian.org/writing/dynamic-form-generation/


Well, the very first piece of code in the first link  includes the line:
  self.fields['captcha'] = CaptchaField()
  and if your earlier reply, you said
"I had not realised the self.fields['vaihtoehdot'] part!" 
so it seems it does relate, perhaps, to your understanding of the problem.

I do agree that trying to understand Django with limited knowledge of Python is going to be very difficult.  I suggest you look at the current thread on this topic on the mailing list...

--
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 unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Passing parameters to form class

Thank you for the links!

I had actually skimmed the first of those and I could not see at the
time how it related to my problem.
The second is very interesting and I'll try to read both of them asap.

Rant begins...
Most of my issues stem of poor understanding of python and not
directly related to django.
This is what you get from trying to understand django with limited
knowledge of python.
Why I haven't had the time to study python is another matter
alltogether...

On Jun 1, 2:15 pm, Derek <gamesb...@gmail.com> wrote:
> On Jun 1, 11:39 am, skyde <madpoe...@gmail.com> wrote:
>
> > Thank you very much! I had not realised the self.fields['vaihtoehdot']
> > part!
>
> > Best regards,
> > skyde
>
> For what it's worth (as this question comes up from time to time and,
> occasionally, people actually search in the archives before asking
> again...), I'll add links to these excellent blog posts, by two of
> Django's core developers, on this topic:
>
> http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/http://jacobian.org/writing/dynamic-form-generation/

--
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 unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Passing parameters to form class

On Jun 1, 11:39 am, skyde <madpoe...@gmail.com> wrote:
> Thank you very much! I had not realised the self.fields['vaihtoehdot']
> part!
>
> Best regards,
> skyde

For what it's worth (as this question comes up from time to time and,
occasionally, people actually search in the archives before asking
again...), I'll add links to these excellent blog posts, by two of
Django's core developers, on this topic:

http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/
http://jacobian.org/writing/dynamic-form-generation/

--
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 unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: getting 'NoneType' object is unsubscriptable errors

On Wed, Jun 1, 2011 at 8:48 AM, saureen adani <saureen_adani@yahoo.co.in> wrote:
>
> Hi,
>
> I am getting the following errors on some of the web pages
>
> 'NoneType' object is unsubscriptable
>
> Help would be highly appreciated !

This error occurs when you attempt to subscript a variable that is None.

IE:

>>> a=None
>>> a[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is unsubscriptable


Don't try to index into a list without verifying that it is a list.

Cheers

Tom

--
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 unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

can't import flup.server.fcgi

i saw this bug has been fixed after 1.1plpha version,but it appeared
now
windows xp
django1.3
flup1.0.2

--
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 unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Passing parameters to form class

Thank you very much! I had not realised the self.fields['vaihtoehdot']
part!

Best regards,
skyde

On Jun 1, 12:01 am, "christian.posta" <christian.po...@gmail.com>
wrote:
> Yes, you will want to do this within the __init__ method.
>
> Run the super class's init method first so that everything's
> initialized as normal.
>
> Then you will have to grab the field for that instance within the
> __init__ method (self.fields['vaihtoehdot']) and set the choices
> property for it.
>
> On May 31, 3:09 am, skyde <madpoe...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > I've hit a brick wall while trying to create dynamic forms.
> > Basically I am trying to give parameter to a class form and then based
> > on that do a multiple choice questionaire.
>
> > For example
>
> > def somefunction():
> >     formi = someForm(ids='1')
>
> > class someForm(forms.Form):
> >    # get id from, use it to get some information from a model and then
> > based on that create a multiplechoice questionnaire. Or better yet do
> > the model querying in somefuntion and only pass the results to
> > someForm.
>
> > *****
> > Inside someForm I can create a tuple and then use this tuple to do a
> > MultipleChoiceField but I can't for the life of me understand how I
> > could parametrize this.
>
> > So this works:
> > C = (('a','a'), ('b','b'), ('c','c'), ('d','d'),)
> > vaihtoehdot = forms.MultipleChoiceField(choices=C,
> > widget=forms.CheckboxSelectMultiple)
>
> > but when I try to change the C to be dynamic I get an empty form. I've
> > tried fiddling with the __init__ function but to no avail.

--
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 unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Model 'Child' is inherited from 'Parent', trying to filter to get only Child results with Parent.objects.filter(...)

Yes that works, thank you.
I've submitted a bug report here https://code.djangoproject.com/ticket/16135
The bug is that Parent.objects.filter(child__isnull=False) is not
giving the result I expect.

On Jun 1, 10:40 am, Matías Aguirre <matiasagui...@gmail.com> wrote:
> This worked on on Django 1.2.5:
>
>     Parent.objects.exclude(child__isnull=True)
>
> Does it work for you?
>
> Excerpts from robin's message of Tue May 31 05:53:26 -0300 2011:
>
>
>
> > Example code:
>
> >    class Parent(models.Model):
> >         name = models.CharField(max_length='20',blank=True)
>
> >     class Child(Parent):
> >         pass
>
> > I want to get the result of Child.objects.all() but I DO NOT want to
> > use Child.
> > I want to use Parent instead, which I tried to do with:
>
> >     Parent.objects.filter(child__isnull=False)
>
> > Which doesn't work and gives the result of Product.objects.all()
> > instead.
> > However If I do the following, it WORKS:
>
> >     Parent.objects.filter(child__name__isnull=False)
>
> > Another way, if I insist on using
> > Parent.objects.filter(child__isnull=False), is to change the Child
> > model to the following:
>
> >     class Child(models.Model):
> >         parent = models.OneToOneField(Parent)
>
> > Then Parent.objects.filter(child__isnull=False) would WORK
>
> > The problem with the 2 solutions above is that filtering with
> > child__name__isnull looks hackish, and I don't want to change my Child
> > model to use OneToOneField.
>
> > So is there a better way?
>
> > Thanks,
> > Robin
>
> --
> Matías Aguirre <matiasagui...@gmail.com>

--
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 unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.