Here is the link to the spot in the docs where it discusses this feature:
http://docs.djangoproject.com/en/dev/topics/http/urls/#naming-url-patterns
In essence, you would need to rewrite your URL pattern to look like the following:
url(r'^DHM_run/$', run_DHM, name="run_DHM")
Any time you use the {% url %} template tag it needs to map to a single named URL pattern.
Hope this helps.
joe_casper
On Thu, Sep 9, 2010 at 6:59 AM, Bradley Hintze <bradley.h@aggiemail.usu.edu> wrote:
Alec,
Thanks for your patience. The jquery tutorials have been frustrating.
Anyway, I do not have three 'views' as you suggested. I will try that.
But I need to understand a few things before I try that. How to call
run_DHM from my please_wait.html page. (I assume AJAX but I've tried
and tries what have been suggested with no success, most likely due to
my failed attempts at understanding AJAX) I assume after I run the
run_DHM view function I will somehow have run_DHM redirect it to the
display_DHM. My question is, how do I redirect AND pass the
request.session arguments, which is where the data from run_DHM will
be stored?
As requested, here is my full url.py:
from django.conf.urls.defaults import *
from MolProbity_Compare_test.views import *
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('',
(r'^home/$', home_view),#the 'index' or home or top page view
(r'^about/$', about_view),
(r'^log_out_confirm/$', log_out_confirm),
(r'^log_out/$', log_out),
(r'^upload/$', uploaded_PDBs),
(r'^rotamer_diff/$', rotamer_dif_frame),
(r'^side-by-side/$', side_by_side),
(r'^side-by-side-key/$', side_by_side_key),
(r'^side-by-side-frame/$', side_by_side_frame),
(r'^DHM_run/$', run_DHM),(r'^analyze/$', analyze_compare),
(r'^please_wait/', please_wait),
)
--
On Thu, Sep 9, 2010 at 9:22 AM, Alec Shaner <ashaner@chumpland.org> wrote:
> Could you post the full url.py file?
>
> And as Brian mentioned your javascript block should be separated. Plus you
> have an extra }); that's going to fail once you resolve this reverse error.
> It's also not clear what you intend to happen when run_DHM returns its
> response? It looks like your intent is to do a redirect and run_DHM will use
> session data to retrieve calculation results.
>
> Just to clarify, I think your plan is to:
>
> 1. Display a Please Wait page that fires off an AJAX call to some view that
> performs calculations => run_DHM. The results of the calculations are stored
> in the session.
> 2. run_DHM returns a simple response that will indicate sucess, e.g., "OK"
> 3. Redirect to a view to display the results, which are retrieved from the
> session => display_DHM
>
> I think you need three views here: please_wait, run_DHM, and display_DHM.
>
> On Thu, Sep 9, 2010 at 8:45 AM, Bradley Hintze <bradley.h@aggiemail.usu.edu>
> wrote:
>>
>> #url.py
>> ...
>> (r'^please_wait/', please_wait),
>> (r'^DHM_run/$', run_DHM),
>> ...
>>
>> #please_wait.html
>>
>> <script type="text/javascript"
>> src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js">
>> $.getJSON('{% url run_DHM %}')
>> });
>> </script>
>>
>> #view.py
>> def please_wait(request):
>> c = {'we_r_home':'yes'}
>> return render_to_response('please_wait.html', c)
>>
>> def run_DHM(request):
>> //put calculated data in request.session
>> return render_to_response('DHM_ran.html', request.session,
>> context_instance=RequestContext(request))
>>
>>
>> This is the django error
>>
>> Caught NoReverseMatch while rendering: Reverse for 'run_DHM' with
>> arguments '()' and keyword arguments '{}' not found.
>>
>> run_DHM takes 'request' as an argument. How do I pass it the argument??
>>
>> Bradley
>>
>> On Wed, Sep 8, 2010 at 9:34 PM, Brian Neal <bgneal@gmail.com> wrote:
>> > On Sep 8, 5:56 pm, Bradley Hintze <bradle...@aggiemail.usu.edu> wrote:
>> >> This is what I have in my please_wait.html
>> >>
>> >> <script type="text/javascript"
>> >> src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js">
>> >> $.getJSON('{% url run_DHM %}')});
>> >>
>> >> </script>
>> >
>> > I don't think that is right, is it? At least I've never seen it done
>> > that way. I think you need two script tags:
>> >
>> > <script type="text/javascript" src="http://ajax.googleapis.com/ajax/
>> > libs/jquery/1.4/jquery.min.js"></script>
>> > <script type="text/javascript">
>> > // Your javascript goes here...
>> > </script>
>> >
>> >>
>> >> This is the django error
>> >>
>> >> Caught NoReverseMatch while rendering: Reverse for 'run_DHM' with
>> >> arguments '()' and keyword arguments '{}' not found.
>> >>
>> >> run_DHM takes 'request' as an argument. How do I pass it the argument??
>> >>
>> >
>> > All views take request as a first argument. But that isn't the
>> > problem. Please post your urls.py that has your run_DHM view in it.
>> >
>> > Regards,
>> > BN
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscribe@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>> >
>>
>>
>>
>> --
>> Bradley J. Hintze
>> Graduate Student
>> Duke University
>> School of Medicine
>> 801-712-8799
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine
801-712-8799
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment