No bother, I have found the solution. Simply use the ContextProcessor.

On May 7, 10:27 pm, Stephen Cheng <stephenchengm...@gmail.com> wrote:
> I have got a case like this: I have a drop down list of value of 8
> cities which requires a db query every time when every page loads. The
> problem is when the url is diverted to django-registration module,
> then I don't know how to properly pass the citylist as a context value
> to django-registration.
>
> I have got two solutions here:
> 1) For the view directly in registration module, I can just invoke my
> post-processed response,
> eg: in stead of using:
>                 return render_to_response(template_name,
>                                                                   { 'form': 
> form },
>                                                                   
> context_instance=context)
>    I will hack it to:
>         return mysiteresp(request,template_name,
>                                                           { 'form': form },
>                                                           
> context_instance=context)
>
> then in mysiteresp: I will add the context varible:cityList to the
> dictionary.
>
> I really don't like to intrude to third party's module, but this is a
> way to do it.
>
> However when the url is login, then it requires to use django's auth
> view
>
>                        url(r'^login/$',
>                            auth_views.login,
>                            {'template_name': 'registration/
> login.html'},
>                            name='auth_login'),
>
> then I can't do anything at all, I can't touch the system level
> functions. So how do I do? Any suggestion.
>
> 2) The other thought I got is to just hard code the city list in to
> the base.html template. eg:
>
>         <select name="categoryid" class="nav_sel" >
>                                                                         
> <option
>                                                                         
> value="10">AAA</option>
>                                                                         
> <option
>                                                                         
> value="11">BBB</option>
>                                                        
> ..........................................
>                                                                 </select>
>
> but I know that I am hesitated to do this.
>
> Any suggestion is appreciated.
>
> Stephen
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to