Re: Template Data

2016-11-18 Thread Vijay Khemlani
Test the "contact.contactnumber_set.all" in a shell, I'm not sure 100% sure on the syntax On Fri, Nov 18, 2016 at 11:51 AM, 'David Turner' via Django users < django-users@googlegroups.com> wrote: > Thankyou for this, although for some reason it does not work. > What other infromation would you ne

Re: Template Data

2016-11-18 Thread 'David Turner' via Django users
Thankyou for this, although for some reason it does not work. What other infromation would you need to further advise me. Thanks On 18 November 2016 at 13:42, Vijay Khemlani wrote: > In your model a contact may have multiple phone numbers (multiple > Contactnumber instances with foreign key to t

Re: Template Data

2016-11-18 Thread Vijay Khemlani
In your model a contact may have multiple phone numbers (multiple Contactnumber instances with foreign key to the same Contact instance) so your question is a bit vague. If you wanted to list all numbers for a given contact you could do somethinkg like {% for contact in practice.contacts.all %}

Template Data

2016-11-18 Thread 'dtdave' via Django users
As still learning django I have a simple issue. I have the following models: class Contactnumber(TimeStampedModel): phone_number = models.CharField(max_length=100, unique=True) contact = models.ForeignKey(‘contacts.Contact') class Contact(TimeStampedModel): contact = models.CharFi

Re: Returning template data from a ManyToMany model

2012-04-18 Thread LJ
emplate_data["parents"] = Parent.objects.filter(student=id) > >    return render_to_response( template, template_data, > > context_instance=RequestContext(request)) > > > The template data is returning the data in the format: > >   [ , ] > > > Instead, I need

Re: Returning template data from a ManyToMany model

2012-04-18 Thread LJ
urn u'Parent : %s %s' % (self.first_name, self.last_name) > > > The method in my view currently looks something like this: > > > def get_parents( request, template ) > >   id=request.GET['id'] > >   template_data["parents"] = Parent.ob

Re: Returning template data from a ManyToMany model

2012-04-17 Thread Daniel Roseman
>id=request.GET['id'] >template_data["parents"] = Parent.objects.filter(student=id) > return render_to_response( template, template_data, > context_instance=RequestContext(request)) > > The template data is returning the

Re: Returning template data from a ManyToMany model

2012-04-17 Thread Phang Mulianto
t; template_data["parents"] = Parent.objects.filter(student=id) > return render_to_response( template, template_data, > context_instance=RequestContext(request)) > > The template data is returning the data in the format: > [ , ] > > I think this because you return y

Returning template data from a ManyToMany model

2012-04-16 Thread LJ
self.last_name) The method in my view currently looks something like this: def get_parents( request, template ) id=request.GET['id'] template_data["parents"] = Parent.objects.filter(student=id) return render_to_response( template, template_data, context_instance=Reques

Re: help with view/template data

2006-05-13 Thread Luke Plant
On Friday 12 May 2006 10:32, Malcolm Tredinnick wrote: > Now, slicing on QuerySets is used to provide SQL's offset and limit > functionality. So evts[1:], which you have later on in the code > translates (approximately) to SELECT ... FROM ... WHERE ... OFFSET 1. > On the other hand, something lik

Re: help with view/template data

2006-05-12 Thread Ivan Sagalaev
Rob Hudson wrote: >What I'm not clear on is what ifchanged looks at. Does it look at the >for loop and "event", or does it look at what's in the body of >ifchanged? In this case the event.date_from? > > It looks at the string between {% ifchanged %} and {% endifchanged %} no matter how it

Re: help with view/template data

2006-05-12 Thread Rob Hudson
I actually went to the shell and looked at my evts with "dir(evts)" and it looked like a simple list so I thought slicing would be no problem. Thanks for explaining what was really going on. -Rob Malcolm Tredinnick wrote: > I suspect we might be seeing this sort of question a bit now. You have

Re: help with view/template data

2006-05-12 Thread Rob Hudson
My inclination was it could be done with a lot less code. Thanks for giving me this. The only thing I had to change was to put all() before order_by b/c I got some error about all() not being a method of the querySet (or something like that). What I'm not clear on is what ifchanged looks at.

Re: help with view/template data

2006-05-12 Thread Ivan Sagalaev
Rob Hudson wrote: >def list(request): >""" >Sets up a list of tuples: (month, list of events) >[("March", [, ]), ("April", [<>])] >""" > > Malcolm has answered your question but I want to add that with Django templates you can do this thing much simpler without two nested loops

Re: help with view/template data

2006-05-12 Thread Malcolm Tredinnick
On Fri, 2006-05-12 at 01:33 -0700, Rob Hudson wrote: > I think I'm making this harder than it should be. Could someone help > me out here please? The gist is that I'm trying to display a list of > events like the following. I'm getting the error "'offset' is not > allowed without 'limit'" which

help with view/template data

2006-05-12 Thread Rob Hudson
I think I'm making this harder than it should be. Could someone help me out here please? The gist is that I'm trying to display a list of events like the following. I'm getting the error "'offset' is not allowed without 'limit'" which doesn't seem right. I'm thinking someone will spot a much s