0

procedure i followed while deploying my website on heroku are . created a Procfile

Contents of Procfile are

web: gunicorn website.wsgi:application --log-file -

then I have done some changes to my settings.py file

and here is the settings.Py file

"""
Django settings for website project.

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

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

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

from pathlib import Path
import os

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-j3t578bbmo+!bmmp27k3+d*nowwo%8y5k7-545j48_$)z0i#67'

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

ALLOWED_HOSTS = ['127.0.0.1','getmachine.herokuapp.com']


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'django_countries',
    'core',
    'crispy_forms',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleware',
    '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 = 'website.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR,"templates")],
        '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',
            ],
                    'libraries':{
            'cart_template_tags': 'core.templatestags.cart_template_tags',

            }
        },
    },
]

WSGI_APPLICATION = 'website.wsgi.application'


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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'Django_website',
        'USER': 'postgres',
        'PASSWORD': '***********',
        'HOST': 'localhost',
        'PORT': '5432',   
        }
}


# Password validation
# https://docs.djangoproject.com/en/3.2/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.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Kolkata'

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

STATIC_URL = '/static/'

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

#Authentication
AUTHENTICATION_BACKENDS = [
    'django.contrib.auth.backends.ModelBackend',
    'allauth.account.auth_backends.AuthenticationBackend',
]

SITE_ID = 1

LOGIN_REDIRECT_URL='/'

SOCIALACCOUNT_PROVIDERS = {
    'google': {
        # For each OAuth based provider, either add a ``SocialApp``
        # (``socialaccount`` app) containing the required client
        # credentials, or list them here:
        'APP': {
            'client_id': '123',
            'secret': '456',
            'key': ''
        }
    }
}

# Static files (CSS, JavaScript, Images)
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'Static files')]
STATIC_ROOT = os.path.join(BASE_DIR, 'assets')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media_root')

#crispy forms

CRISPY_TEMPLATE_PACK = 'bootstrap4'


EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

I have done some changes in my URLs.py file too here is the my URLs.py file

from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path, include
from django.views.static import serve
from django.conf.urls import url

urlpatterns = [
    path('admin/', admin.site.urls),
    path('accounts/', include('allauth.urls')),
    path('', include('core.urls')),

        url(r'^media/(?P<path>.*)$', serve,{'document_root':      settings.MEDIA_ROOT}), 
    url(r'^static/(?P<path>.*)$', serve,{'document_root': settings.STATIC_ROOT}), 

]

urlpatterns+=static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns+=static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

then I created a new heruko app and connected my repo with heroku and deployed it there were no errors when I was deploying it but when I tried to run it it just show Internal server error

I tried running heruko logs command so that I can find out what is wrong with my deployment but nothing is showing up

enter image description here

Naveen Singla
  • 76
  • 1
  • 8
  • [Please don't post screenshots of text](https://meta.stackoverflow.com/a/285557/354577). They can't be searched or copied, or even consumed by users of adaptive technologies like screen readers. Instead, paste the code as text directly into your question. If you select it and click the `{}` button or Ctrl+K the code block will be indented by four spaces, which will cause it to be rendered as code. – ChrisGPT was on strike Feb 03 '22 at 19:49
  • Have you [logged in with the CLI](https://devcenter.heroku.com/articles/heroku-cli-commands#heroku-auth-login)? – ChrisGPT was on strike Feb 03 '22 at 19:51
  • @Chris yes i have logged in with CLI – Naveen Singla Feb 03 '22 at 19:52
  • Something is wrong with your Heroku CLI. I suggest you reinstall it and / or try in another shell (e.g. PowerShell, the Bash shell that comes with Git for Windows, etc.) In the meantime, you can [check your logs via the Dashboard](https://devcenter.heroku.com/articles/logging#view-logs-with-the-heroku-dashboard). – ChrisGPT was on strike Feb 04 '22 at 12:38
  • @Chris there is nothing wrong with cli at first it was showing some errors and it was due Procfile and when I updated that procfile it stoped showing that errors and now nothing is getting displayed on my screen is there any right that I can follow to deploy my project – Naveen Singla Feb 04 '22 at 13:13
  • 1
    Then you should be getting logs when you run `heroku logs`. You said in this question that you have an internal server error. If you run `heroku logs --tail`, then load your page and get Internal Server Error, something should print out in the terminal. As I said in my last comment, I don't think your CLI is working properly. Try rebooting, another terminal, or reinstalling. And check your logs in the Dashboard. – ChrisGPT was on strike Feb 04 '22 at 13:16
  • `at=error code=H14 desc="No web processes running" method=GET path="/" host=getmachine.herokuapp.com request_id=11eb2681-ddef-4c4c-aeed-8d495fef7056 fwd="42.109.245.114" dyno= connect= service= status=503 bytes= protocol=https` see if you undo all the changes it is showing this error and i know what is the reason behind this error this is because of procfile and if i fix the procfile then it will again stop showing all the outputs – Naveen Singla Feb 04 '22 at 13:55
  • @Chris thankyou chris for all your support but I think there is some problem with heroku docs and I think there is currently there is no valid method to deploy my project for free – Naveen Singla Feb 04 '22 at 18:39
  • Don't get discouraged: `No web processes running` is progress. I've closed this as a duplicate of another question. Read through the answers there and see if any of them solve your problem. – ChrisGPT was on strike Feb 04 '22 at 21:47

0 Answers0