3

I'm fairly new to django and I'm working on a project for some reason clicking on my links won't redirect me to the desired page, nothing happens, but i cant open it bu right click > open in new tab here is my template

index.html:

<ul class="list">
      {% for movie in all_movies %}
        <li>
          <img src="{{ movie.poster }}" alt="" class="cover" />
          <a href="{% url 'detail' movie.id %}"><p class="title">{{ movie.title }}</p></a>
          {% for genre in movie.genre.all %}
            <p class="genre">{{ genre.genre }} | </p>
          {% endfor %}
        </li>
      {% endfor %}
</ul>

views.py :

def detail(request, movie_id):
   movie = get_object_or_404(Movie, pk=movie_id)
   return render(request, 'movies/detail.html', {'movie': movie})

urls.py :

urlpatterns = [
   # /movies/
   url(r'^$', views.index, name='index'),
   # /movies/id/
   url(r'^(?P<movie_id>[0-9]+)/$', views.detail, name='detail'),
]

i can't find what's wrong with my code, any help would be appreciated!

mari
  • 325
  • 1
  • 5
  • 16

2 Answers2

1

This is most likely a JavaScript issue, this has nothing to do with Django. Your Django setup is working fine, I tested it is well.

There is an identical issue faced by someone else here, and it was revealed that JavaScript was the actual issue.

I can't think of any other issues that may cause this.

Community
  • 1
  • 1
almost a beginner
  • 1,622
  • 2
  • 20
  • 41
  • turns out it was from the JS file i just removed it all together and the links work fine, thank you! – mari Sep 09 '16 at 15:32
0

Hi I had exactly the same problem. More precise: Klicking didn't work, and also klicking the wheel didn't work.

I solved it finding out that around the NAV bar I had <header class="full-header">. Changing it to <header class="header"> made everything work. I have no full-header in my CSS, BTW.

But there is a smooth scrolling script, I discovered now, which was the real origin of the misbehaviour:

$(function() {
   $(".full-header nav a").click(function(e) {
     e.preventDefault();
     $('html,body').scrollTo(this.hash, this.hash);
   });
});