Hi Sahil, On Mon, Feb 3, 2014 at 8:32 AM, SAHIL SHEKHAWAT <[email protected]> wrote: > hey friends, > for some time now i have been working on implementing ipython notebook to > sympy_gamma.the main problem of ipython's json format is solved but i have > problem in using django!! please suggest! > > I am using the 'r' variable from the views.input view and rendering json > after parsing it to another url after the user click on the notebook's link > which then redirect to nbviewer > But as both views.input and json creator are both different views i am
Would you mind posting a PR with what you have? Let's have a look at the actual code and get it working in the PR. >From what you are saying, you have views.input: https://github.com/sympy/sympy_gamma/blob/master/app/views.py#L197 and then you created views.json_creator? And you are asking how to get the json created in views.input into views.json_creator? > having difficulty passing the variable between them. i have passed the > result from the result.html template using > > <a href="{% url app.views.json_creator %}?result={{ > result|safe }}"> > > to json_creator. it is working ( to some extend) but it is getting passed in > some weird format...this dictionary which is getting passed is full of > "%<some number>" and "\\" something like mathjax when the view is receiving. And you are trying to pass it using URL, correct? > and thus my view is not able to parse it because it is not a python > dictionary anymore..it will be nice if some django developer could suggest > somethings. > besides using GET request i know that i can create an invisible form and get > the 'r' from POST or i can use app engine datastore.. > with datastore it is very easy but storing and deleting datastore is not > free on app engine so i am preferring GET method else.. > Furthermore, i know that maximum length if url is somewhere around 2000 > characters but i dont think that json could be larger than that so thats why > i think this method is appropriate.. So I think the best way to pass data using URL is to use base64 url encoding: http://docs.python.org/2/library/base64.html#base64.urlsafe_b64encode So you encode it in views.input, and decode it in views.json_creator. But long URLs are not very convenient. One solution is to store it in the database, and only put the ID of the entry into the URL. The other solution is to simply emit the json into the html inside json.view. Save it to some hidden "div" or something. Then use javascript that would simply keep this hidden, but if a user clicks on a link "show notebook", it will show a text area with the notebook --- or possibly uploads it to gist (this will have to be done using ajax I guess, i.e. sending the json by http back to the server, which then uploads it). Maybe there are some other ways to do that. Ondrej -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
