Django settings for dynamicRatingSystem project.
Generated by 'django-admin startproject' using Django 3.0.4.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.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/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'z%alyt$v^pz7atj*=_r@m_obeeob(km$1og*mu9-_skx%4zov3'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'movies.apps.MoviesConfig',
'home.apps.HomeConfig',
'crispy_forms',
'users.apps.UsersConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
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 = 'dynamicRatingSystem.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 = 'dynamicRatingSystem.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'dynamicRatingSystem',
'USER':'postgres',
'PASSWORD':'java@processing',
'HOST':'localhost',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.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/3.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/3.0/howto/static-files/
STATIC_URL = '/static/'
MEDIA_ROOT=os.path.join(BASE_DIR,'media')
MEDIA_URL='/media/'
CRISPY_TEMPLATE_PACK='bootstrap4'
LOGIN_REDIRECT_URL='home-home'
LOGIN_URL='login'
{% if messages %} {% for m in messages %} {%endfor%} {% endif%} {% block content %}{% endblock %}
from . import views
urlpatterns = [
path('', views.result,name='movie-result'),
path('<int:movie_id>/detail/', views.details, name='movie-detail'),
]from django.shortcuts import render
from django.http import HttpResponse
from imdb import IMDb
imdb=IMDb()
# Create your views here.
def result(request):
b=request.GET['movieSearch']
a=imdb.search_movie(b)
return render(request,'movies/results.html',{'a':a,'title':b})
# def details(request, **kwargs):
# movie=imdb.get_movie(kwargs['movie_id'])
# return render(request,'movies/details.html',{'movie':movie,'title':movie['title']})
# return HttpResponse('<h1>'+str(kwargs['movie_id'])+'</h1>')
def details(request, movie_id):
movie=imdb.get_movie(movie_id)
return render(request,'movies/details.html',{'movie':movie,'title':movie['title']}){% extends 'home/base.html' %} {% block content %}
{{title|capfirst}}
{{movie.items}}
LOGIN TO rate
{% endif %} {% endblock content %}{% extends 'home/base.html'%} {% block content %}{{title|upper}}
{% for b in a %}
Rate & More... {% endfor %}
{{b.title}}
{% ifnotequal b|get_item:"kind" "movie" %}{{b|get_item:"episode of"}}
{% endifnotequal %}Year : {{b.year}}
Kind : {{b|get_item:"kind"}}
{% ifnotequal b|get_item:"kind" "movie" %}Season : {{b|get_item:"season"}}
Episode : {{b|get_item:"episode"}}
{% endifnotequal %}A really strange error is occurring in my project
-- normally when a user or superuser is logged in every page is happily accessible but as soon as the user is logged out '/result/<int:movie_id>/detail' start showing NoReverseMatch error pointing to line 8 of template base.html
As It is working one way I;e while any user is logged in, I can assure you that there is no view or URL related error in my code and also no decorators like @login_required or anything similar to that is being used please help me .....
I have attached important files If you would like to see them..
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f5c89ed6-0ce5-4ce3-b6b7-0d88543e5330%40googlegroups.com.


No comments:
Post a Comment