Heyy there, i have for example a view function like this:
def profile_view(request, id):
u = UserProfile.objects.get(pk=id)
return render_to_response('profile/publicProfile.html', {
'object_list': u,
},
context_instance=RequestContext(request))
and the url: url(r'^profile_view/(?P\d+)/$', profile_view, name='profile_view'),
my problem is that i want to use the function's url in another template too, for example in the search in blog template, where people see the posts of some persons, and they want to navigate to their profile. the search view may look like that:
def searchn(request):
query = request.GET.get('q', '')
if query:
qset = (
Q(post__iexact=query)
)
results = New.objects.filter(qset).distinct()
else:
results = []
return render_to_response('news/searchn.html',{
'results': results,
'query': query},
context_instance=RequestContext(request))
and the template:
{% if query %}
Results for "{{ query|escape }}":
{% if results %}
<ul>
{% for object in results %}
<li>{{ object.post }} <a href='../../accounts/profile_view/{{object.id}}/'> {{ object.created_by }} </a> {{object.date}} </li>
{% endfor %}
</ul>
{% else %}
<p>No posts found</p>
{% endif %}
{% endif %}
there, in created_by, i'd like to put a link to my user profile, but the user profile view doesn't 'point' to this template. What shoul i do? Thanks!