I am using OSQA as a secondary application and when clicked on the logo in the header, I want it to redirect to another url. I added this to forum/views/readers.py:

def indexhome(request):
    return HttpResponseRedirect("http://localhost:8000/")

and this to /forum/urls.py:

urlpatterns += patterns('',
                    url(r'^$', app.readers.index, name='index'),
                    url(r'^$', app.readers.indexhome, name='indexhome'),

however it still links to the osqa app's main site instead of localhost:8000

Would you please guide me about how can I make this change. I am new to Django, so excuse me if this is basic but I couln't find an answer on the net.

Thanks.

EDIT

I forgot to mention that I also edited forum/skins/templates/default/header.html

        <div id="logo">
            <a href="{% url indexhome %}">
                    ...
                    </a>
    </div>

asked 25 Dec '10, 07:23

erenay's gravatar image

erenay
2114
accept rate: 0%

edited 31 Dec '10, 11:12

rickross's gravatar image

rickross ♦♦
12.5k2914972


My lazy answer is you need to update the template. Actually your view function and url that you added are probably moot if you just update the template.

link

answered 25 Dec '10, 19:12

Justin%20Hamade's gravatar image

Justin Hamade
2243
accept rate: 17%

thank you, I forgot to add that to my question. I edited my question with the change I made to header.html. It seems like the change I make to the template does not take effect and it calls the index function instead of my indexhome function.

(26 Dec '10, 06:28) erenay

The regex for you url is the same for both urls. The regex for indexhome will never be used. Take a read though the url dispacther docs http://docs.djangoproject.com/en/dev/topics/http/urls/ "Django runs through each URL pattern, in order, and stops at the first one that matches the requested URL." Having a view with a redirect for a single link is pointless, just put the link directly in the template.

(27 Dec '10, 12:24) Justin Hamade
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×298
×44
×11
×11
×2

Asked: 25 Dec '10, 07:23

Seen: 451 times

Last updated: 31 Dec '10, 11:12

powered by OSQA