Python Forum
Django debug of templates and home.html
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Django debug of templates and home.html
#1
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:
Quote:
  1. Creating a Django App
  2. Open terminal and navigate to django project folder (where manage.py exists)
  3. django-admin startapp [app name] # use pluralised names, e.g. posts
  4. Navigate to new app folder.
  5. Create new subfolder called “templates”
  6. Navigate to new templates folder.
  7. Create new subfolder called same name as your app (e.g. posts)
  8. 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.
Reply
#2
I find this tremendously frustrating that I cannot edit my post to correct spelling and grammatical errors. The post is only 7 hours old. I read the forum rules and see that taking away the ability to edit is a measure in place to prevent people from changing their posts to avoid members confusing other members. I think this is a bad reason because other projects (like reddit, social networks and the Ubuntu forums) with vibrant online user communities allow members to edit their posts and don't have this problem. I am furious right now because my initial post has some silly grammar and spellings which I now cannot correct.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Lightbulb Hypertag. New language for HTML templating w/ Django support mwojnars 0 1,740 Apr-06-2021, 12:53 PM
Last Post: mwojnars
  HTML multi select HTML listbox with Flask/Python rfeyer 0 4,533 Mar-14-2021, 12:23 PM
Last Post: rfeyer
  Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to loop to next HTML/new CSV Row BrandonKastning 0 2,329 Mar-22-2020, 06:10 AM
Last Post: BrandonKastning
  Why use HTML in Django Template ift38375 2 2,773 Dec-09-2019, 02:28 AM
Last Post: snippsat
  Posting html values to views/models in Django Malt 1 2,128 Sep-04-2019, 01:44 PM
Last Post: fishhook
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,246 Jun-30-2019, 12:21 AM
Last Post: scidam
  convert html to pdf in django site shahpy 4 5,979 Aug-17-2018, 11:10 AM
Last Post: Larz60+
  Execute using Html, Save data into Database and Download in CSV in Django --Part 1 Prince_Bhatia 0 3,799 Jan-19-2018, 06:05 AM
Last Post: Prince_Bhatia
  Django field model for HTML parser? Drone4four 0 4,117 Nov-15-2017, 02:43 AM
Last Post: Drone4four
  read text file using python and display its output to html using django amit 0 18,262 Jul-23-2017, 06:14 AM
Last Post: amit

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020