Django debug of templates and home.html

25 views
Skip to first unread message

drone4four

unread,
Nov 15, 2017, 8:17:10 PM11/15/17
to Django users
I am having fun trying to initiate a django project with some apps. I am taking an awesome course on udemy called, The Ultimate Beginner's Guide to Django. I was able to follow along and I have a basic blog up and running. Now I am back tracking a little by starting over, this time using a supplementary Django cheat sheet. I encountered a number of issues and resolved them but now I find myself stuck. 

When I try navigating to my new homepage, Django provides me with this debug traceback. Django is telling me here that the templates directory doesn’t exist, when it clearly does. Here is a screenshot of Atom so you can see my project’s file tree. As you can see my directory tree for my project, there is an folder which is called, blogitems. and within the blogitems folder is a sub-folder called, templates, then blogitems again and finally my file, home.html

It’s rather confusing. I don’t like the redundancy and the recursive nature of all the app files and directory names. Maybe this is my problem. Can any of your make sense of my debug output to explain why I am getting the error? Can anyone please provide some clarity here?

Here is the cheat sheet:

Creating a Django App

1. Open terminal and navigate to django project folder (where manage.py exists)
2. django-admin startapp [app name] # use pluralised names, e.g. posts
3. Navigate to new app folder.
4. Create new subfolder called “templates”
5. Navigate to new templates folder.
6. Create new subfolder called same name as your app (e.g. posts)
7. Go back to project folder
9. Open project urls.py and add “from [appname] import views”. Then add url path for new view.
     e.g. url(r’^$’, views.home, name=‘home’)
10.Open views.py and add:
def home(request):
   
return render(request, posts/home.html’)


11. Navigate to projectfolder\appfolder\templates\appfolder
12.  Create new file ‘home.html’
13.  Go to project folder and open settings.py. Scroll down to INSTALLED_APPs and add ‘appname’, to the end of the list of apps.

It's this last step where I encounter the error. 

Here are the contents of urls.py:
from django.conf.urls import url
from django.contrib import admin
from blogitems import views

urlpatterns
= [
   
#initialization admin interface:
    url
(r'^admin/', admin.site.urls),
    url
(r’^$’, views.home, name=‘home’),
]



I added the app into the settings.py:
INSTALLED_APPS = [
   
'django.contrib.admin',
   
'django.contrib.auth',
   
'django.contrib.contenttypes',
   
'django.contrib.sessions',
   
'django.contrib.messages',
   
'django.contrib.staticfiles',
   
'blogitems',
]

Is there any other information I could provide?

Thanks for your attention.

Amitesh Sahay

unread,
Nov 15, 2017, 10:35:20 PM11/15/17
to Django users, drone4four
Hello, 

In the settings.py please give the full path to your appsclass as mentioned in app.py. That should be the standard. 

Please share the HTML code here, then it should be clear for further suggestion.

Regards,
Amitesh Sahay

primary :: 91-907 529 6235



--
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...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/770a99c0-3824-4e73-914e-f380fd5f48f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

drone4four

unread,
Nov 15, 2017, 11:51:23 PM11/15/17
to Django users
Hello Amitesh.  Thank you for your reply.

The contents of my apps.py reads:

# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.apps import AppConfig


class BlogitemsConfig(AppConfig):
    name
= 'blogitems'

There is no instance of 'BlogitemsConfig' or 'AppConfig' inside settings.py. Could that be my issue?  

Here is some sample HTML that I am trying to experiment with:

...at Dundas Square in Toronto.  Here is my report:

<em>abstract</em> Sed a lorem est. Maecenas faucibus sollicitudin velit, sit amet lacinia orci tempor eu. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In placerat leo vel nisl venenatis, ut tincidunt nulla <a href="#">placerat. Aliquam vehicula, justo nec lobortis dignissim, sapien</a> ex rhoncus mi, ut pretium tortor elit eget sapien. Pellentesque at enim dignissim, imperdiet urna et, molestie massa. Nam posuere, tortor ac dignissim scelerisque, tellus est varius enim, egestas vehicula felis augue ac nisl. Nulla facilisi. Mauris vitae turpis at tortor pulvinar egestas eu vel risus. Duis tincidunt rhoncus aliquet. Duis hendrerit posuere diam, sed eleifend neque vehicula quis. Nulla molestie est est, quis varius metus viverra sit amet. </div>
<hr />

<p>Sed et ipsum porta turpis consequat efficitur. Suspendisse congue, tellus ac aliquam molestie, tellus tortor fringilla dolor, sit amet faucibus risus lacus sed nunc. Ut enim leo, viverra ut orci a, dignissim fermentum diam. Phasellus dignissim auguet est dignissim, vel euismod leo molestie. Fusce erat massa, cursus eget nibh eget, rhoncus fermentum enim. Praesent interdum aliquam volutpat. Aenean ut iaculis augue. Sed metus tortor, dignissim sit amet feugiat nec, lacinia vitae nisi. Sed eu facilisis augue. Nulla sagittis, ante nec commodo tincidunt, purus sapien vehicula est, ut vulputate lorem lacus vitae mi. Morbi non nibh pretium, molestie magna ac, auctor ante. Proin quis sapien sed dui feugiat egestas auctor condimentum diam. Pellentesque vulputate lorem massa, non feugiat leo eleifend placerat. Donec semper arcu vitae molestie pretium. </p>

<br />



  <h5>Introduction</h5>
<p>Suspendisse ac metus varius, scelerisque dolor a, lacinia sem. Aliquam at enim a dui aliquam condimentum et ut mauris. Cras facilisis tortor sit amet consectetur pellentesque. Nullam eget pellentesque augue, non iaculis mauris. In hac habitasse platea dictumst. Quisque ullamcorper volutpat ornare. Cras ornare vestibulum ornare. </p>




drone4four

unread,
Nov 16, 2017, 12:28:09 AM11/16/17
to Django users
Amitesh, here are the contents of my home.html:

<!doctype html>
<html lang="en">
  <head>
    <title>J. R. Dobb's Blog!</title>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
  </head>
  <body>
    <nav class="navbar navbar-default">
      <div class="container">
        <div class="navbar-header">
          <a class="navbar-brand" href="#">Dobbs' Clearing House</a>
        </div>
      </div>
    </nav>
    <h1>Hello, world!</h1>
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script> -->
    
  </body>
</html>
<h1>Dobbs' Homepage Test</h1>
<h2> Latest News and Updates</h2>
{% for post in posts.all %}
<a href="{% url 'post_details' post.id %}">{{ post.title }}</a>
<br>
{{ post.pub_date_pretty }}
<br>
<img src="{{ post.image.url }}">
<br>
{{ post.summary }}
<br>
<br>
{% endfor %}

Sorry if I confused you with the lorem ipsum non sense.  Please disregard that last post of mine.  

Thanks again,

Drone4four

On Wednesday, November 15, 2017 at 10:35:20 PM UTC-5, Amitesh Sahay wrote:
Reply all
Reply to author
Forward
0 new messages