I deployed my Django webapp in PythonAnywhere. Despite following every step, my webapp is displaying only 1 page. As soon as i click on a link to go to other pages, the webapp stops working and gives an error message saying something went wrong with no proper details. But everything works fine when using it on localhost. These are the nav and urls.py files:
<div class="topbar">
<header>
<li><a id="TOP_name" href="home"><img src="{%static 'prasant1.png' %}" height="50"></a></li>
</header>
<ul>
<li><a id="right" href="contact">CONTACT</a></li>
<li><a id="right" href="resume">RESUME</a></li>
<li><a id="right" href="work">WORK</a></li>
<li><a id="right" href="experience">EXPERIENCE</a></li>
<li><a id="right" href="education">EDUCATION</a></li>
</ul>
</div>
urlpatterns = [
path('', views.home),
path('home', views.home),
path('work', views.work),
path('resume', views.Resume),
path('education', views.education),
path('contact',views.contact),
path('experience',views.experience),
]
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('home.urls')),
]
I tried changing the "home" link with "work" link but that makes the condition worse as it doesn't even load 1 page now. So from my point of view the problem might be with other html files. Please help me out on how to solve this is PythonAnywhere.
You will need to supply name
attribute for your urls then use that in your link tags. Edit your code as below:
urlpatterns = [
path('', views.home, name='home'),
path('work', views.work, name='work'),
path('resume', views.Resume, name='resume'),
path('education', views.education, name='education'),
path('contact',views.contact, name='contact'),
path('experience',views.experience, name='experience'),
]
<div class="topbar">
<header>
<li><a id="TOP_name" href="home"><img src="{%static 'prasant1.png' %}" height="50"></a></li>
</header>
<ul>
<li><a id="right" href="{% url 'contact' %}">CONTACT</a></li>
<li><a id="right" href="{% url 'resume' %}">RESUME</a></li>
<li><a id="right" href="{% url 'work' %}">WORK</a></li>
<li><a id="right" href="{% url 'experience' %}">EXPERIENCE</a></li>
<li><a id="right" href="{% url 'education' %}">EDUCATION</a></li>
</ul>
</div>