[Tutor] Python Django Query

nitin chandra nitinchandra1 at gmail.com
Tue Apr 2 07:50:06 EDT 2019


Thanks Cameron,

Just got lucky yesterday and found a resource at my end to help me out.

Thank you

On Tue, 2 Apr 2019 at 04:31, Cameron Simpson <cs at cskk.id.au> wrote:
>
> On 29Mar2019 21:18, nitin chandra <nitinchandra1 at gmail.com> wrote:
> >Hi Everyone,
> >I need some guidance / corrections to my code.
> >I hosted a demo site on pythonanywhere.com and to test the initial
> >pages I wrote some test code.
> [...]
>
> Hi Nitin,
>
> I looks like nobody has replied; this probably means that nobody has the
> required specialty expertise to help you. (I don't.)
>
> >Good news, put in 10 hrs, tried so many suggestion given on the net,
> >yet non worked. So finally mailing the list.
>
> Might I suggest that you ask on the django-users mailing list, here:
>
>   https://www.djangoproject.com/community/
>
> You want the "Using Django" list there.
>
> There's a guideline to posting here:
>
>   https://code.djangoproject.com/wiki/UsingTheMailingList
>
> but your post looks fairly good on the face of it.
>
> Hoping this helps,
> Cameron Simpson <cs at cskk.id.au>
>
> >
> >Objective : display main page with multiple links to other pages. Use
> >jQuery plugins, click the link on main page and open other pages.
> >
> >The following path and pages are posted below.
> >
> >Thanks
> >
> >Nitin Chandra
> >
> >------------------------------------------------------------
> >ERROR
> >When I click on 'Table' link on 'home' page, the following error is displayed
> >
> >http://selftech.pythonanywhere.com/table.html
> >Page not found (404)
> >
> >Request Method:GET
> >Request URL:http://selftech.pythonanywhere.com/table.html
> >
> >Using the URLconf defined in eduinfra.urls, Django tried these URL
> >patterns, in this order:
> >
> >admin/
> >[name='home.html']
> >
> >The current path, table.html, didn't match any of these.
> >
> >You're seeing this error because you have DEBUG = True in your Django
> >settings file. Change that to False, and Django will display a
> >standard 404 page.
> >
> >+++++++++++++++++++++++++++++++++++
> >
> >/home/selfTech/edu/tech/
> >
> > __init__.py
> > admin.py
> > apps.py
> > models.py
> > tests.py
> > urls.py
> > views.py
> >
> >/home/selfTech/edu/tech/templates/
> >
> > base.html
> > home.html
> > table.html
> >*******************************************
> >our 'base.html' code below (test code, gets rendered correctly)
> >
> ><nav class="navbar navbar-expand-lg navbar-light bg-light">
> >  <a class="navbar-brand" href="#">Navbar</a>
> >  <button class="navbar-toggler" type="button" data-toggle="collapse"
> >data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02"
> >aria-expanded="false" aria-label="Toggle navigation">
> >    <span class="navbar-toggler-icon"></span>
> >  </button>
> >
> >  <div class="collapse navbar-collapse" id="navbarTogglerDemo02">
> >    <ul class="navbar-nav mr-auto mt-2 mt-lg-0">
> >      <li class="nav-item active">
> >        <a class="nav-link" href="#">Home <span
> >class="sr-only">(current)</span></a>
> >      </li>
> >      <li class="nav-item">
> >        <a class="nav-link" href="#">Link</a>
> >      </li>
> >      <li class="nav-item">
> >        <a class="nav-link" href="table.html">Table</a>
> >      </li>
> >      <li class="nav-item">
> >        <a class="nav-link disabled" href="#" tabindex="-1"
> >aria-disabled="true">Disabled</a>
> >      </li>
> >    </ul>
> >    <form class="form-inline my-2 my-lg-0">
> >      <input class="form-control mr-sm-2" type="search" placeholder="Search">
> >      <button class="btn btn-outline-success my-2 my-sm-0"
> >type="submit">Search</button>
> >    </form>
> >  </div>
> ></nav>
> >   *************************
> >home.html
> >
> >{% extends 'base.html' %}
> >
> >{% block content%}
> >Hello TEAM :)
> >{% endblock %}
> >*******************************
> >table.html (gives ERROR 404)
> >
> ><table class="table">
> >    <thead>
> >        <tr>
> >            <th>Name</th>
> >        </tr>
> >    </thead>
> ></table>
> >
> >*********************************************
> >/home/selfTech/edu/tech/
> >
> >urls.py
> >
> >from django.urls import path
> >from . import views
> >
> >urlpatterns = [
> >    path('', views.home, name='home'),
> >    path('table/', views.table, name='table') ## various combo did not work
> >   # path (' ', views.table, name='table') ## nope
> >   # path (' ', views.table, name='table.html') # nope
> >]
> >
> >*************************///////////////////////
> >views.py
> >
> >from django.shortcuts import render
> >from django.http import HttpResponse
> ># Create your views here.
> >
> >def home (request):      /// correctly renders
> >    return render (request, "home.html",{})
> >
> >def table (request):    //// gives error
> >    return HttpResponse ('<h1>This is a test Page</h1>')
> >    # Tried the below code, nada
> >    # return render (request, "table.html",{})
> >
> >*************************\\\\\\\\\\\\\\\\\\\\\\\\\
> >_______________________________________________
> >Tutor maillist  -  Tutor at python.org
> >To unsubscribe or change subscription options:
> >https://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list