1

I am somewhat new to both web development and new to the Django and Pyjamas frameworks. So I appreciate any patience offered to me as I learn.

I am setting up Django and Pyjamas to work together, JSONRPC Client/Server + Django templates.

I have the compiled Pyjamas my_project.html being served as Django templates. I have the Django template folder set to my Pyjamas project output folder.

Pyjamas compiles a bootstrap.js to the same output folder and I need proper referencing within the Django templates to these files as the current reference of:

<script language="javascript" src="bootstrap.js"></script>

Is not functioning.

The Django way of managing static files is not very obvious to me even after reading it's documentation. What is the best way to set this up in terms of folder hierarchy and Django settings?

What is the best way to reference my static files from within my Django templates?

I know I am likely asking obvious questions but after reading the available documentation I just can't seem to put this together. This is the last piece of the puzzle before I really start rolling so any help will be appreciated greatly!

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • Why do you want pyjamas to be served as django template? Usually they are separated from each other, and serving correct files is done by http server (nginx, lighttpd, apache, etc) – Daniel Kluev Jul 07 '11 at 13:57

1 Answers1

1

It won't let me comment but I am running into the same issue. To answer Daniel Kluev, our reason for serving the pyjamas page through django is because JSONRPC requests from pyjamas -> django run into the CSRF protections in django, resulting in a 403 error. The best solution (and maybe only?) that we have seen is to pass the token to pyjamas as a cookie (or form element), which can then be sent back to django during the RPCs. We have not been able to implement this due to the issues Shattered1113 mentioned in his question.

The only other option I've seen is to turn off the CSRF middleware, or exempt specific views from it using a decorator. This seems to be the solution everyone uses, however we require the csrf protection to be enabled so it will not work for us.

mmarklar
  • 11
  • 1