Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4593570
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:42:12+00:00 2026-05-21T22:42:12+00:00

I have trouble of passing my get_profiles in the same template as r’^compose/$’ here.

  • 0

I have trouble of passing my get_profiles in the same template as r’^compose/$’ here. r’^users/$’ is what I’m using as a model and it works. “compose” is a function in my views.py.

from django.conf.urls.defaults import *
from django.views.generic.simple import redirect_to
from django.views.generic.simple import direct_to_template

from messages.views import *

from userprofile.views import get_profiles

urlpatterns = patterns('',
    url(r'^$', redirect_to, {'url': 'inbox/'}),
    url(r'^inbox/$', inbox, name='messages_inbox'),
    url(r'^outbox/$', outbox, name='messages_outbox'),
    url(r'^compose/$', compose, name='messages_compose'),
    url(r'^users/$', direct_to_template, {'extra_context': { 'profiles': get_profiles }, 'template': 'messages/users.html' }),
)
userprofile/views.py
def get_profiles():
    return Profile.objects.order_by("user")

I tried this:

url(r'^compose/$', compose, direct_to_template, {'extra_context': { 'profiles': get_profiles },  'template': 'messages/compose.html' }),

But I get a function object is not iterable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T22:42:13+00:00Added an answer on May 21, 2026 at 10:42 pm

    As others have said, you need to actually call the function, but if you do that in urls.py it will only be evaluated once per process. You don’t want to do that.

    You don’t show what get_profiles does, but I assume it’s some sort of utility function. I tend to think that those belong in a separate file, lib.py or utils.py, rather than views.py. (That is, assuming it’s not actually a view itself – if it is, then you’ll need to rethink your whole approach).

    However, what I think you actually need to do is to make a template tag instead. You can keep the logic in get_profiles if you like, then make a simple tag that calls that function. Then you don’t need to mess about with passing data in extra_context – just add the tag to your template.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am Rails newbie and having some trouble passing parameters to form. I have
Having some trouble with R's garbage collection, when passing objects to C++. We have
I have trouble parsing a HTML table using Nokogiri and Ruby. My HTML table
I have trouble doing this... You may want to get the same result as
I have trouble shooting at file download problem. In Chrome, the download works fine.
Having some trouble passing values from one class to another. I basically have a
I am having trouble with the Play! framework's mapping function. I have suspicion that
I'm using Django and I am having trouble passing variable information back to the
Im having some trouble with my MVC model in java. Im passing in an
I'm using BlazeDS to connect Flex with Java. I'm having trouble passing ArrayLists of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.