Code

Opened 5 years ago

Closed 5 years ago

#11361 closed (invalid)

Using javascript in Django

Reported by: WilsonOfCanada Owned by: nobody
Component: Forms Version: master
Severity: Keywords: Javascript, HTML
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Hello ppl,

I am trying to use javascript in the html for an "onChange" event; however, anything enclosed between the script tags are excluded. Now I am wondering if I am missing something or the path in url.py or Django does not support javascript at all.

Thanks

html

{% extends "Basic.html" %}

{% block body %}

<form action="/Results/" method ="post">

<div id="formSite">
	<div id="navBar">

	</div>

	<div id="mainCol">

		<script language="JavaScript" type="text/javascript" src="/site_media/js/foo.js">

			<label for="selectCountry">Select Country: </label>
			<select name="selectCountry" id="selectCountry" onChange="changeProvince()">
				<option value="Canada" selected="selected">Canada</option>

				<option value="US">United States</option>
				<option value="France">France</option>
			</select>

			<input type="submit" value="Select"><br/>
		</script>

	</div>

</div>

</form>

{% endblock %}

urls.py

(r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': 'C:\\ ... \\media\\'}),

(The images and css files work)

Attachments (0)

Change History (1)

comment:1 Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

Django is a server-side HTTP web application framework. It has nothing to do with Javascript on the client side. Django just serves the pages it is told to serve. If those pages contain Javascript, it is up to the client to interpret that code.

Furthermore, the Django ticket system is not for answering "how to" questions - it is for tracking bugs. If you have a question of usage, please ask on Django-users - although, in this case, it may be appropriate to find a forum with a Javascript focus.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.