1

sometime simplest things are so complex!

I have some javascript which works fine. I decided to put it in a seperate javascript file that I want to link to my template. I have put it in folder scripts/a_ajax.js off the root of the application. Whatever folder structure I've tried has not worked. I've also read something about that I must put a reference in urlpatterns but I'm not sure what I had to do.

Can anyone help tell me what I have to do to embed this code as a file?

thx

1 Answer 1

1

If your Django version is 1.3+: https://docs.djangoproject.com/en/dev/howto/static-files/

If your Django version 1.2.* or lower: https://docs.djangoproject.com/en/1.2/howto/static-files/

Sign up to request clarification or add additional context in comments.

2 Comments

wow - this is complex logic - I'm having a hard time following it from documentations - I'm using ver 1.3 I've put my javascript file in /static - 1) I added django.contrib.staticfiles in INSTALLED_APPS - I've updated STATICFILES_DIRS = ... /static - based on myunderstanding of instructions I should be done - but I get the following error: You're using the staticfiles app without having set the required STATIC_URL setting - An example would be helpful for this section -
I have learned google app engine has a different method by updating app.yaml file which is much simpler than the native method offered by Django. I have used extensions /js/jquery.js - GAE maps /js/ to specific directory for static files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.