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

  • Home
  • SEARCH
  • 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 8825559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:54:29+00:00 2026-06-14T06:54:29+00:00

I have a view like this : def myview(request): print A some_function() return HttpResponse(This

  • 0

I have a view like this :

  def myview(request):
      print "A"

      some_function()

      return HttpResponse("This should not appear")

  def some_function():
      return render_to_response("templ.html", {}, context_instance=RequestContext(request))

Here, the function renders template if i call the function like this :

    return some_function()

But it always expect the function to return, but i want the function to return only at certain times. I can use some logic in the view whether to return or not, but i am asking it is possible to do everything in the view so i can simply call the function ?

  • 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-06-14T06:54:31+00:00Added an answer on June 14, 2026 at 6:54 am

    You can render a response from a function, but what you need is return some_function() not some_function() alone,
    in your case some_function() does execute, but the return value is not passed on as the return value of your view myview()

    So the execution flow continues and reaches return HttpResponse("This should not appear"),
    so that is the response you will get in your view.

    If you had some_function() alone (and without return), then your view would return with no response (myview() being a function that returns nothing),
    and Django would complain.

    You can use logic to control the flow ofcourse, provided you use return on the called functions, e.g. :

    def my_view(request):
    
        if request['x'] == 'a':
            return function_a()
        elif request['x'] == 'b':
            return function_b()
    
        return some_other_response()
    

    Just make function_x() return a valid response.

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

Sidebar

Related Questions

In one of my views I'm saving a few sessions like this: def myview(request):
I have a view like this in my Flex mobile Application: <s:View xmlns:fx=http://ns.adobe.com/mxml/2009 xmlns:s=library://ns.adobe.com/flex/spark
I have a block of code in my view like this: <% @map[value].each do
I have a mvc2 application with a view like this <% using (Ajax.BeginForm(UserApprove, new
I have a view model that looks like this public class ViewModelRound2 { public
I have a View that is basically setup like this: <Grid> <ViewBox> <Grid> <ItemsControl
I have a View that renders something like this: Item 1 and Item 2
I have a view with a ComboBox like this <ComboBox Name=cmbPurpose DisplayMemberPath=@value SelectedValuePath=@key ItemsSource={Binding
I have added a UILabel to my view programmatically like this: myLabel = [[UILabel
I have a view model coming from the server as json like this {

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.