Re: iterate over query set

2021-07-26 Thread DJANGO DEVELOPER
because you have provided the get_department with index 0. so it will only give you the info about first department. On Tue, Jul 27, 2021 at 3:17 AM sum abiut wrote: > I am trying to get the values of the userid by iterating through the > queryset. However not all the values are displayed. I am

Re: iterate through list

2020-02-14 Thread Kai Kobschätzki
Thanks for the tip, I will read it :) Greetings bengoshi On 2/14/20 2:31 PM, Roger Gammans wrote: > No problem, > > It 's all explained here : > https://docs.djangoproject.com/en/3.0/ref/models/querysets/ > > > On Fri, 2020-02-14 at 14:27 +0100, Kai Kobschätzki wrote: >> Hi Roger: >> >> Thanks

Re: iterate through list

2020-02-14 Thread Roger Gammans
No problem, It 's all explained here : https://docs.djangoproject.com/en/3.0/ref/models/querysets/ On Fri, 2020-02-14 at 14:27 +0100, Kai Kobschätzki wrote: > Hi Roger: > > Thanks a lot! Such as easy :) > > Greetings > > bengoshi > > > On 2/14/20 2:15 PM, Roger Gammans wrote: > > Use: > >

Re: iterate through list

2020-02-14 Thread Kai Kobschätzki
Hi Roger: Thanks a lot! Such as easy :) Greetings bengoshi On 2/14/20 2:15 PM, Roger Gammans wrote: > Use: > > for data in Journal.objects.all(): > > > > > On Fri, 2020-02-14 at 14:13 +0100, Kai Kobschätzki wrote: >> Hi: >> >> I want to do something with the content of a table. Prob

Re: iterate through list

2020-02-14 Thread Roger Gammans
Use: for data in Journal.objects.all(): On Fri, 2020-02-14 at 14:13 +0100, Kai Kobschätzki wrote: > Hi: > > I want to do something with the content of a table. Problem is, that > the > IDs are not continuous. I tried: > > import .models from Journal > > last = Journal.obejects.l

Re: iterate a save in a form view based on a field value

2017-01-06 Thread roboslone
Hi! You probably want to use range() function for that. > On 6 Jan 2017, at 18:21, MikeKJ wrote: > > So I have a form of post values and one of the values is the number of > resources to be used, what I want to do is save multiple instances of the > form data based on the resource quantity to

Re: iterate

2015-01-26 Thread Lachlan Musicman
Of course, although it depends on what your definition of "earliest" is (most likely you mean from a data entry perspective), and what fields and field types you have. You could sort by date, if you have a creation date field, you could sort by ID/PK if you haven't changed that field on the table..

Re: Iterate forms with for loop

2014-08-21 Thread Daniel Roseman
On Thursday, 21 August 2014 10:33:11 UTC+1, Kamal Kaur wrote: > > I'm iterating multiple forms for all the instances of a table in the > template using for loop. > > But only the last form is being considered and it saves the data from > last form only. I'm not getting how to differentiate these

Re: Iterate over MultipleChoiceList in Template

2009-05-27 Thread Retro486
Bummer I'd have to resort to overloading the renderer, but I guess if that's what it would take. Personally I'll just fall back to the three manual checkboxes and putting the validation code in my clean method. Thanks again Richard, glad you found a solution. For those who wish to overload the

Re: Iterate over MultipleChoiceList in Template

2009-05-27 Thread Richard
Hey Retro, My boss managed to get this working so I can't take the credit but this works and it's pretty useful. Basically, he's overriding the widget renderer and making each "choice" a separate list item, giving each "choice" it's own ID, making it much easier to use CSS to format the choices i

Re: Iterate over MultipleChoiceList in Template

2009-05-25 Thread Retro486
Ok, well I took at look at the two links and they were pretty much the same thing; just access to the choice list as text, not the checkbox generator. I was able to generate the checkboxes manually, but they break the form system silently and just don't work (don't map to the usertype object for

Re: Iterate over MultipleChoiceList in Template

2009-05-25 Thread Retro486
Thanks, Richard. I'll take a look at the links you sent and see if I can't work something out. In the meantime I've dropped back to a MultipleChoiceField. :( I'll post my findings. -R On May 25, 9:03 am, Richard wrote: > Hey Retro, I'm struggling with the same thing. I've found two > interesti

Re: Iterate over MultipleChoiceList in Template

2009-05-25 Thread Richard
Hey Retro, I'm struggling with the same thing. I've found two interesting links which take two different approaches although I can't get either to quite work (I think the template is just not seeing the actual control but it's not complaining loudly). But it's quite possible that you'll be able to

Re: Iterate over model database fields

2009-01-09 Thread bruno desthuilliers
On 8 jan, 23:56, Matias Surdi wrote: > Great!! > > I think that the _meta attribute will be enough. I think that if I > define a method on the base model of all my models something like > get_fields() it could then return a list of the fields by accessing > self._meta.fields, and this get_field

Re: Iterate over model database fields

2009-01-08 Thread Matias Surdi
Great!! I think that the _meta attribute will be enough. I think that if I define a method on the base model of all my models something like get_fields() it could then return a list of the fields by accessing self._meta.fields, and this get_fields should be accessible from templates,shouldn't

Re: Iterate over model database fields

2009-01-08 Thread bruno desthuilliers
On 8 jan, 16:22, Matias Surdi wrote: > Is there any way to iterate over all the fields in a model instance on a > template? Not directly. The fields names are accessible thru the model_instance._meta attribute, and you cannot access '_protected' attributes in a template. > I'd like to have a "d

Re: iterate over alphabet in template

2008-06-18 Thread M.Ganesh
Ned Batchelder wrote: > If you wanted to keep the alphabet issue out of the view, you could > also do this: > > {% for letter in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" %} > > --Ned. > http://nedbatchelder.com > Super. I was just wondering how to do it. Thanks Ned Regards Ganesh --~--~-~--~~

Re: iterate over alphabet in template

2008-06-17 Thread Ned Batchelder
If you wanted to keep the alphabet issue out of the view, you could also do this: {% for letter in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" %} --Ned. http://nedbatchelder.com M.Ganesh wrote: > Joel Bernstein wrote: > >> For an easy (but locale-dependent) way to get a list of the uppercase >> characters

Re: iterate over alphabet in template

2008-06-17 Thread M.Ganesh
Joel Bernstein wrote: > For an easy (but locale-dependent) way to get a list of the uppercase > characters in Python, try string.uppercase > > http://www.python.org/doc/2.3/lib/module-string.html > > Just add that list to your context, and you should be ready to go. > > On Jun 17, 12:03 pm, "Richa

Re: iterate over alphabet in template

2008-06-17 Thread Joel Bernstein
For an easy (but locale-dependent) way to get a list of the uppercase characters in Python, try string.uppercase http://www.python.org/doc/2.3/lib/module-string.html Just add that list to your context, and you should be ready to go. On Jun 17, 12:03 pm, "Richard Dahl" <[EMAIL PROTECTED]> wrote:

Re: iterate over alphabet in template

2008-06-17 Thread Richard Dahl
I would probably just pass in a python list with all of the letters in the alphabet, then just {% for l in alphabet_list %} ... -richard On 6/17/08, M.Ganesh <[EMAIL PROTECTED]> wrote: > > > Hi All, > > I am relatively new to both python and django. Please help me to do this : > > {% for letter