hello all,  

i am  working on  project for learning purpose,  i have got stuck  on a 
small logic , i have tried lot to find the solution  , 
gone to url like 

http://www.sprklab.com/notes/13-passing-arguments-to-functions-in-django-template
http://www.tangowithdjango.com/book/chapters/ajax.html
and  many more 

unfortunately, i am not able find the solution, so require some hints from 
all of  u guys

so i m applying a logic under following

1) i m selecting a option form a select menu
2) on select the option eant to get the selected value
3) now this selected , i want to pass through a template tag  for query 
purpose from database.


my small part of logic is under 

#######################

<select onchange="change()" name="tclass" class="target">
                                <option value="-1">Select Class</option>
                                <option value="1">Class I</option>
                                <option value="2">Class II</option>
                               
 </select>


##############################################

<script>
$( ".target" ).change(function () {
    var id = $(this).val();
    var dataString = 'id='+ id;

    {% get_latest bookstoreapp.Book 5 as recent_posts %}    ====>>> i want 
to use above $id or id     instead of 5  here 

    })
</script>


 

for more info sending my templates/get_latest.py
#########################################################

from django.template import Library, Node
from django.db.models import get_model

register = Library()

class LatestContentNode(Node):

    def __init__(self, model, num, varname):
        self.num, self.varname = int(num), varname
        self.model = get_model(*model.split('.'))


    def render(self, context):
        context[self.varname] = self.model.objects.filter(pk = self.num)
        return ''


def get_latest(parser, token):
    bits = token.contents.split()

    if len(bits) != 5:
        raise TemplateSyntaxError, "get_latest tag takes exactly four 
arguments"

    if bits[3] != 'as':
        raise TemplateSyntaxError, "third argument to get_latest tag must 
be 'as'"
 
   return LatestContentNode(bits[1], bits[2], bits[4])


get_latest = register.tag(get_latest)

################3


please help guys...


 

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/8fd1a136-30d1-4ca8-a45d-45428e026b96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to