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 8507701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:56:40+00:00 2026-06-11T02:56:40+00:00

I am trying to pass data from a model into a XML file. I

  • 0

I am trying to pass data from a model into a XML file. I do this like I would with a normal .html template:

def getGroups(request):
    groups = SpeciesGroup.objects.all().order_by('id')
    return render_to_response(
        'groups.xml',
        {'groups':groups},
        context_instance = RequestContext(request)
    )

in my groups.xml file:

<?xml version="1.0" encoding="UTF-8"?>

<Groups>
    {% for g in groups %}
    <group_id>{{g.id}}</group_id>
    <name>{{g.name}}</name> 
    <description>{{g.description}}</description>
    {% endfor %}
</Groups>

When loading the URL in the browser, I get a blank screen. But when I view source I get the correct data:

<?xml version="1.0" encoding="UTF-8"?>

<Groups>
    <group_id>1</group_id>
    <name>Small</name> 
    <description>Small</description>

    <group_id>2</group_id>
    <name>Medium</name> 
    <description>Medium</description>

    <group_id>3</group_id>
    <name>Large</name> 
    <description>Large</description>
</Groups>

I have validated the source XML and it’s fine. I’m assuming I have missed something or left something out in my view. I bet it’s something simple that I can’t find on a Monday morning!

  • 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-11T02:56:41+00:00Added an answer on June 11, 2026 at 2:56 am

    I figured it out myself! All I needed was to add the mimetype in my return:

    return render_to_response(
        'groups.xml',
        {'groups':groups},
        context_instance = RequestContext(request),
        mimetype='application/xml'
    ) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to pass data from one activity to another via Intent.putExtras like this:
I am trying to pass in mutliple data into AJAX .post(). This is what
I'm trying to use __doPostBack to pass some data from client to server side.
I am trying to pass some data into my Controller, but I'm getting a
I'm trying to use JQuery's $.getJSON to access Model data from the Controller, and
I'm trying to pass a C struct from C++ into python as a numpy
I'm trying to pass data from my table OpenCart version 1.5.1.3 to version 1.5.3.1.
I am trying to make an app that will pass data between two servers
I'm trying to make simple script using jquery $post function to pass data to
I'm trying to write my own protocol so that multiple servers can pass data

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.