Sunday, February 19, 2012

Re: passing multiple query sets into a url pattern

Hi Stanwn,

try this:

def get_keyword():
   return Keyword.objects.all()

UserProfile_info = {
    "queryset" : UserProfile.objects.all(),
    "extra_context" : {"keyword_list" : get_keyword }
}


Now you can use the variable {{ keyword_list }} to populate the template.



Alfredo


2012/2/19 Stanwin Siow <stanwin.ktsiow@gmail.com>
Hi Alfredo,

My apologies for not making my question clear.

I want to pass two different querysets into the url pattern. Is it possible?

Best Regards,

Stanwin Siow



On Feb 19, 2012, at 2:01 AM, Alfredo Alessandrini wrote:

Hi,

I'm not sure that I've understand your question:

url(r'^profile/(?P<var_1>\d+)/(?P<var_2>\d+)$', ......)

and now you can use the variable var_1 and var_2 in your function.


Alfredo



2012/2/18 Stanwin Siow <stanwin.ktsiow@gmail.com>
Hello, 

I want to find out if there is anyway to pass two querysets into a url pattern.

i have this url pattern at the moment.

UserProfile_info = {
    "queryset" : UserProfile.objects.all(),
    "extra_context" : {"keyword_list" : Keyword.objects.all}
}

    url(r'^profile/$', list_detail.object_list, UserProfile_info),


I understand from http://www.djangobook.com/en/1.0/chapter09/ that the extra_context field is to defind another query set.

in my Userprofile.html i have the following code:

{% for userprofile in object_list %}
   {% if userprofile.username = user.username %}

that will give me the list of items in userprofile table in the database.

Is there a way to include the list of items from the keyword table as well?
    









Best Regards,

Stanwin Siow




--
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.



--
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate