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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:22:27+00:00 2026-05-20T14:22:27+00:00

Maybe this is a very silly question but I’m new using django. I have

  • 0

Maybe this is a very silly question but I’m new using django.
I have a certain django template with a set of properties that can be chosen. On an uploaded file I have to perform a different treatment depending on the chosen property, so I want to pass the chosen property value from the template to the view. Properies are hard coded in view.py and retrieved in the template by getJSON:

<script type="text/javascript">
$(function() {
    $.getJSON('available_properties', function(data) {
        var options = [];
        for(var i in data.properties)
        {
            var prop = data.properties[i];
            options.push('<option value="'+prop+'">'+prop+'</option>');         
        }
        $("#properties > select").html(options.join(''));
    }); 
});
</script>

Then an uploading file form trigger the action:

    <form onsubmit="return checkfile();" prop="return get_prop();" action="calculate/<property_value_goes_here>" enctype="multipart/form-data" method="POST">
        {% csrf_token %}
        <input type="file" id="uploadfile" name="uploadfile" size="30">
        <input type="submit" id="calculate" value="Calculate!">
    </form>

How can I pass the property value directly in the URL path that must be called on the submit form?

  • 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-20T14:22:28+00:00Added an answer on May 20, 2026 at 2:22 pm

    Actually you have two ways to solve that problem. One is parsing the url, the other one is passing the properities as request parameters.

    The first one can be implemented like this:

    urlpatterns = patterns('',
        (r'^/(?P<property>\*)/$', 'appname.viewname'),
    )  
    

    in your url, and:

    def your_view(request,property):
        #your view stuff here 
    

    in views.py of your app. This is documented in Part 3 of the django tutorial, as you can find it here: http://docs.djangoproject.com/en/1.2/intro/tutorial03/

    But for your problem the second solution is probably the better on. You can create a standard url-querystring (as your post suggests you know how to use js to do that) like this:

    /upload/?property=value&someotherproperty=othervalue  
    

    and get the passed values like this:

    def your_view(request):
        property = request.POST.get('property',None)
        someotherproperty = request.POST.get('someotherproperty',None)  
    

    where the get works as:
    request.POST.get(property_name,fallback_value)

    To put the querystring into request.POST, you have to configure your urls.py like this:

    urlpatters = patterns('',
        (r'^upload/$','appname.viewname'),
    )  
    

    That way everything after /upload/ will be passed to request.POST

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

Sidebar

Related Questions

No related questions found

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.