template not exist error snap in attechment

23 views
Skip to first unread message

tribhuvan kishor

unread,
Jan 11, 2019, 6:13:34 AM1/11/19
to django...@googlegroups.com
URL
 path('<int:year>/<slug:post>/',views.post_detail, name='post_detail'),
VIEW
def post_detail(request, year,  post):
post = get_object_or_404(Post, slug=post,
status='published',
publish__year=year,)
     return render(request,
'blog/post/detail.html',
{'post': post})

TEMPLATE
{% extends "blog/base.html" %}
{% block title %}{{ post.title }}{% endblock %}{% block content %}
<h1>{{ post.title }}</h1>
<p class="date">
Published {{ post.publish }} by {{ post.author }}
</p>
{{ post.body|linebreaks }}
{% endblock %}
Canonical URL

def get_absolute_url(self):
return reverse('blog:post_detail', args=[self.publish.year, self.slug]

TEMplate DIrectory 
PROJECT/APP/template/blog/detail.html
--
regards 
Tribhuvan Kishor Bhaskar
Screenshot from 2019-01-11 16-42-08.png

NAveeN Kumar Reddy

unread,
Jan 11, 2019, 7:16:53 AM1/11/19
to django...@googlegroups.com
Check the link before pattern in path function

--
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/CACiphSX2LQ-oL0OwktHhLqCFwqqPwVwFagCaGX2rNTiBdxOa%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

shiva kumar

unread,
Jan 11, 2019, 7:53:47 AM1/11/19
to django...@googlegroups.com
Can you put your project file structure. 

Martin K

unread,
Jan 11, 2019, 10:49:28 AM1/11/19
to Django users
TEMplate DIrectory 
PROJECT/APP/template/blog/detail.html


You see directly in the error that template should be located in  PROJECT/APP/template/blog/post/detail.html

tribhuvan kishor

unread,
Jan 12, 2019, 12:46:14 AM1/12/19
to django...@googlegroups.com
this is my directory structure

--
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.

For more options, visit https://groups.google.com/d/optout.
Screenshot from 2019-01-12 11-14-25.png

shiva kumar

unread,
Jan 12, 2019, 1:03:20 AM1/12/19
to django...@googlegroups.com
once post your setting.py file content . i will try to figure it out.


tribhuvan kishor

unread,
Jan 12, 2019, 2:11:46 AM1/12/19
to django...@googlegroups.com
"""
Django settings for mysite project.

Generated by 'django-admin startproject' using Django 2.0.5.

For more information on this file, see
https://docs.djangoproject.com/en/2.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.0/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'po3(*jzn*8yzi$765qqcke+ewdc()g6xbwvx(g64i^bw28ulc@'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'mysite.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'mysite.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases

DATABASES = {
'default': {
'NAME': 'mysite',
'ENGINE': 'django.db.backends.mysql',
'HOST': 'localhost',
'PORT':'3306',
'USER': 'root',
'PASSWORD': 'root',
}
}


# Password validation
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/2.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/

STATIC_URL = '/static/'


For more options, visit https://groups.google.com/d/optout.

tribhuvan kishor

unread,
Jan 12, 2019, 2:12:59 AM1/12/19
to django...@googlegroups.com
even list.html is in the same place and its accessible . i am not getting why showing problem with details.html

shiva kumar

unread,
Jan 12, 2019, 3:02:35 AM1/12/19
to django...@googlegroups.com
It's not detail it's details.html

tribhuvan kishor

unread,
Jan 12, 2019, 3:45:23 AM1/12/19
to django...@googlegroups.com
thanks, Shiva I think its matter of lack of concentration from my side thanks buddy, 


For more options, visit https://groups.google.com/d/optout.

tribhuvan kishor

unread,
Jan 14, 2019, 1:03:13 PM1/14/19
to django...@googlegroups.com
thanks shiva . thanks alot i think a lack of concentration 

On Sat, Jan 12, 2019 at 1:32 PM shiva kumar <kannamshi...@gmail.com> wrote:

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages