Hello,

Your views have a 'name' attribute. You can also give a name to an app
in the urls.py file of the app, right above your urlpatterns list:

app_name = "myappname"

urlpatterns = [
    path('', views.index, name='index'), path('about', views.about, 
name='about'), path('blog', views.blog, name='blog'), ]


Then, when you need to put a link to a another page in your template,
use the following syntax:

<li><a href="{% url 'myappname:index' %}">Home</a></li> <li><a href="{% url 
'myappname:about' %}">About Us</a></li>

Regards,

Red

On 25/10/2019 21:01, 'Amitesh Sahay' via Django users wrote:
> Hello Team,
>
> I am kind of new to software development, and trying to find my feat.
> I have a queries which could be quite dumb to most of you, but I need
> to know.
>  
> As far as I know, we need Jija templates in the HTML files, so that we
> can assign correct path of the static files.
>
> Its a general practice to create base.html and extend this in other
> HTML files. Since, I am new to development, so I want to do things in
> a stupid way, I have a HTML templates, and I do not wish to create
> base.html for now. Therefore, if I want to render the html page, I
> need to create views.py , urls.py, and modify the HTML pages to use
> 'static' any where required. Below are the snippet of my test environment.
>
> views.py
>
> from django.shortcuts import render, get_object_or_404
>
>
> def index(request):
>     return render(request, 'index.html')
>
>
> def blog(request):
>     return render(request, 'blog.html')
>
>
> def about(request):
>     return render(request, 'about.html')
> project/urls.py
>
> from django.contrib import admin
> from django.urls import path, include
> from django.conf import settings
> from django.conf.urls.static import static
>
> urlpatterns = [
>     path('admin/', admin.site.urls), path('blog/', include('BLOG.urls'))
> ]
>
> if settings.DEBUG:
>    urlpatterns += static(settings.STATIC_URL, 
> document_root=settings.STATIC_ROOT)
> APP/urls.py
>
> from django.urls import path
> from django.conf import settings
> from . import views
>
> urlpatterns = [
>     path('', views.index, name='index'), path('about', views.about, 
> name='about'), path('blog', views.blog, name='blog'), ]
> below is the HTML(index.html) file, which I modified as per my limited
> understanding.
>
> {% load staticfiles %}
> {% block content %}
> <!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> --> <html
> xmlns="http://www.w3.org/1999/xhtml";> <head> <meta
> http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Orange 
> Theme - Free Website Template</title> <meta name="keywords" content="" /> 
> <meta name="description"
> content="" /> <!-- Template 2025 Orange
> http://www.tooplate.com/view/2025-orange --> <link href="{% static
> 'CSS/tooplate_style.css' %}" rel="stylesheet" type="text/css" />
> <script type="text/javascript" src="{% static 'js/swfobject.js'
> %}"></script> <script type="text/javascript"> var flashvars = {};
>    flashvars.xml_file = "photo_list.xml";
>    var params = {};
>    params.wmode = "transparent";
>    var attributes = {};
>    attributes.id = "slider";
>    swfobject.embedSWF("flash_slider.swf", "flash_grid_slider", "440", "220", 
> "9.0.0", false, flashvars, params, attributes);
> </script> <link rel="stylesheet" type="text/css" href="{% static
> 'CSS/ddsmoothmenu.css' %}" /> <script type="text/javascript" src="{%
> static 'js/jquery.min.js' %}"></script> <script type="text/javascript"
> src="{% static 'js/ddsmoothmenu.js' %}"> 
> /***********************************************
> * Smooth Navigational Menu- (c) Dynamic Drive DHTML code library 
> (www.dynamicdrive.com)
> * This notice MUST stay intact for legal use
> * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
> ***********************************************/
>
> </script> <script type="text/javascript"> ddsmoothmenu.init({
>    mainmenuid: "tooplate_menu", //menu DIV id
>    orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
>    classname: 'ddsmoothmenu', //class added to menu's outer DIV
>    //customtheme: ["#1c5a80", "#18374a"],
>    contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
> })
>
> </script> </head> <body> <div id="tooplate_wrapper"> <div
> id="tooplate_header"> <div id="site_title"><h1><a href="#">Orange HTML 
> Template</a></h1></div> <div id="tooplate_menu" class="ddsmoothmenu"> <ul>
> <li><a href="{% 'index.html' %}" class="selected">Home</a></li> <li><a 
> href="{% 'about.html' %}">About Us</a> <ul> <li><a href="#">History</a></li> 
> <li><a href="#">Our Team</a></li> <li><a href="#">Vision and Mission</a></li> 
> </ul> </li> <li><a href="{% 'portfolio.html' %}">Portfolio</a> <ul> <li><a 
> href="#">Website Templates</a></li> <li><a href="#">Web Design</a></li> 
> <li><a href="#">Free Templates</a></li> <li><a href="#">HTML CSS 
> Layouts</a></li> <li><a href="#">Web Development</a></li> </ul> </li> <li><a 
> href="{% 'blog.html' %}">Blog</a></li> <li><a href="{% 'contact.html' 
> %}">Contact</a></li> </ul> <br style="clear: left" /> </div> <!-- end of 
> tooplate_menu --> </div> <div
> id="tooplate_social"> <a href="#"><img src="{% static
> 'img/facebook.png' %}" alt="facebook" /></a> <a href="#"><img src="{%
> static 'img/stumbleupon.png' %}" alt="stumbleupon" /></a> <a
> href="#"><img src="{% static 'img/feed.png' %}" alt="feed" /></a> <a
> href="#"><img src="{% static 'img/twitter.png' %}" alt="twitter"
> /></a> </div> <div id="tooplate_middle"> <div id="mid_slider"> <div
> id="flash_grid_slider"> <a rel="nofollow"
> href="http://www.adobe.com/go/getflashplayer";> <img
> src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif";
> alt="Get Adobe Flash player" /> </a> </div> </div> <div id="mid_left">
> <div id="mid_title"> Website Template
>           </div> <p>Aliquam in odio ut ipsum mollis facilisis. Integer est 
> sem, dignissim quis auctor vel, dapibus vel massa. Curabitur vulputate ligula 
> vel mi semper tempus.</p> <div id="learn_more"><a href="#"></a></div> </div> 
> <div
> class="cleaner"></div> </div> <!-- end of tooplate_middle --> <div
> id="tooplate_main_top"></div> <div id="tooplate_main"> <div
> class="col_fw"> <div class="col_allw270 fp_service_box"> <h3>New 
> Standard</h3> <img src="{% static 'img/tick-48px.png' %}" alt="Image Tick" /> 
> <p> Vivamus a velit. Vivamus leo velit, convallis id, ultrices sit amet, 
> validate <a href="http://validator.w3.org/check?uri=referer";
> rel="nofollow"><strong>XHTML</strong></a> and <a 
> href="http://jigsaw.w3.org/css-validator/check/referer";
> rel="nofollow"><strong>CSS</strong></a>. </p> <a class="more" 
> href="#">Detail</a> </div> <div class="col_allw270 fp_service_box"> <h3>High 
> Quality</h3> <img src="{% static 'img/post-it-48px.png' %}" alt="Post Image"
> /> <p>Donec pharetra orci id tortor cursus eu ultricies velit vehicula. 
> Phasellus eu ante tellus.</p> <a class="more" href="#">Detail</a> </div> <div 
> class="col_allw270 fp_service_box col_last"> <h3>Solid Platform</h3> <img 
> src="{% static 'img/rosette-48px.png' %}" alt="Rosette" /> <p>Curabitur sed 
> lectus id erat viverra consectetur nec in sapien. Etiam vitae tortor mi.</p> 
> <a class="more" href="#">Detail</a> </div> <div class="cleaner"></div> </div> 
> <div
> class="cleaner"></div> </div> <div id="tooplate_main_bottom"></div>
> <div id="tooplate_bottom"> <div class="col_allw270"> <h4>Pages</h4> <ul 
> class="bottom_list"> <li><a href="{% 'index.html' %}">Home</a></li> <li><a 
> href="{% 'about.html' %}">About Us</a></li> <li><a href="{% 'portfolio.html' 
> %}">Portfolio</a></li> <li><a href="{% 'blog.html' %}">Blog</a></li> <li><a 
> href="{% 'contact.html' %}">Contact</a></li> </ul> </div> <div 
> class="col_allw270"> <h4>Blog Posts</h4> <ul class="bottom_list"> <li><a 
> href="#">Donec placerat odio at leo suscipit hendrerit</a></li> <li><a 
> href="#">Proin vitae magna eget sem mattis imperdie</a></li> <li><a 
> href="#">Nunc ac nunc ut erat consectetur rutrum</a></li> <li><a 
> href="#">Phasellus cursus nulla in risus condimentum </a></li> <li><a 
> href="#">Fusce euismod odio sed mauris hendrerit</a></li> </ul> </div> <div 
> class="col_allw270 col_last"> <h4>About Us</h4> <p><em>Donec vehicula mauris 
> sed arcu fermentum ornare. Aliquam erat volutpat.</em></p> <p>Orange is one 
> of the <a href="http://www.tooplate.com/free-templates";>free templates</a> by 
> tooplate. Credits go to <a href="http://www.photovaco.com";>Free Photos</a> 
> for photos and <a href="http://www.thewebdesignblog.co.uk";>The Web Design 
> Blog</a> for icons.</p> </div> <div class="cleaner"></div> </div> <div 
> id="tooplate_footer"> Copyright © 2048 <a href="#">Company Name</a> </div> 
> </div> </body> </html> {% endblock %}
> So, my question is, if my understanding about the static files and its
> usage in the HTML page is right, then how to go about mentioning the
> correct path for the HTML pages in all the HTML files?
>
> As of now I do not have any DB connection. Below is my project structure.
>
> Inline image
>
> I am sorry for long email. But I need to know.
>
> Regards,
> Amitesh
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com
> <mailto:django-users+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1812324006.1119283.1572030107612%40mail.yahoo.com
> <https://groups.google.com/d/msgid/django-users/1812324006.1119283.1572030107612%40mail.yahoo.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7e0f2b83-f3ad-8183-3951-45d07de522ab%40riseup.net.

Reply via email to