Forums

CNAME and DNS

Hello! I am very beginner in web, please help me! 1) I have domen on reg.ru - mur-remont.ru 2) reg.ru said: "Looks like mur-remont.ru is not connected to the site To connect a domain to a site, you must specify DNS servers AND add resource records." 3) They asc 2 DNS servers OR 1 IP but I do not know this information 4) I put my CNAME and free DNS (picture 1) , but it still not working.

Please, help me

"https://ibb.co/m0zbbsj"

"https://ibb.co/jgR2byD"

It doesn't look like it worked:

$ dig www.mur-remont.ru

; <<>> DiG 9.16.1-Ubuntu <<>> www.mur-remont.ru
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 20123
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;www.mur-remont.ru.             IN      A

;; Query time: 123 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Mon Sep 19 09:02:07 UTC 2022
;; MSG SIZE  rcvd: 46

Maybe you should contact your DNS provider and ask how to set the CNAME.

Yes, thay helps me to solve this problem. But now have another problem log: 2022-09-19 10:23:03,864: Error running WSGI application 2022-09-19 10:23:03,864: Error running WSGI application ModuleNotFoundError: No module named 'murremont.settings' 2022-09-19 10:23:03,929: File "/var/www/www_mur-remont_ru_wsgi.py", line 92, in <module> 2022-09-19 10:23:03,929: ModuleNotFoundError: No module named 'murremont.settings' 2022-09-19 10:23:03,930: File "/var/www/www_mur-remont_ru_wsgi.py", line 92, in <module> 2022-09-19 10:23:03,931: application = get_wsgi_application()

But - I have file murremont/settings

'https://ibb.co/p08kpxb'

'wsgi'

import os import sys from dotenv import load_dotenv path = '/home/LabJournal/mysite' if path not in sys.path: sys.path.append(path) os.environ['DJANGO_SETTINGS_MODULE'] = 'murremont.settings' load_dotenv(os.path.join(path, '.env')) from django.core.wsgi import get_wsgi_application application = get_wsgi_application()

'settings' import os from pathlib import Path from dotenv import load_dotenv

load_dotenv()

BASE_DIR = Path(file).resolve().parent.parent

SECRET_KEY = os.getenv('SECRET_KEY')

DEBUG = os.getenv('DEBUG') == 'True'

ALLOWED_HOSTS = [host.strip() for host in os.getenv('ALLOWED_HOSTS').split(',')]

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

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 = 'murremont.urls'

TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [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', ], }, }, ]

WSGI_APPLICATION = 'murremont.wsgi.application'

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', } }

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', }, ]

LANGUAGE_CODE = 'ru'

TIME_ZONE = 'Europe/Moscow'

USE_I18N = True

USE_TZ = True

USE_L10N = False

STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static')

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

LOGIN_REDIRECT_URL = 'profile' LOGIN_URL = 'user'

MEDIA_URL = '/pictures/' MEDIA_ROOT = os.path.join(BASE_DIR, 'pictures')

SHORT_DATE_FORMAT = ' j . m. Y'

TOOLBAR_DEBUG = False

if TOOLBAR_DEBUG: try: from murremont import local_settings

    INSTALLED_APPS += local_settings.INSTALLED_APPS
    MIDDLEWARE = local_settings.MIDDLEWARE + MIDDLEWARE

    INTERNAL_IPS = local_settings.INTERNAL_IPS
except ImportError as e:
    import logging

    logger = logging.getLogger(__name__)
    logger.warning(f"Ошибка импорта. {e}")

if DEBUG: import mimetypes

mimetypes.add_type("application/javascript", ".js", True)

STATIC_URL = 'static/'

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

Something went wrong :-( Something went wrong while trying to load this website; please try again later.

If it is your site, you should check your logs to determine what the problem is.

There was an error loading your PythonAnywhere-hosted site. There may be a bug in your code.

Error code: Unhandled Exception

Did you check the logs, as the message suggested?

Yes. And you can see it in one of my previous post .

We have a help page on debugging import errors here: https://help.pythonanywhere.com/pages/DebuggingImportError/

Yes, I saw it, but it did not help :(

OK, try reading through this paragraph only.

Oh, thank You! I did change and now import os import sys

from dotenv import load_dotenv

path = '/home/LabJournal/murremont' if path not in sys.path: sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'murremont.settings' load_dotenv(os.path.join(path, '.env'))

from django.core.wsgi import get_wsgi_application application = get_wsgi_application()

But here is another problem: Bad Request (400)

after change ALLOWED_HOSTS = "mur-remont.ru" -> ALLOWED_HOSTS = "www.mur-remont.ru" it working

now I have problem with static files - pictures do not load I did collectstatic and STATIC_ROOT = os.path.join(BASE_DIR, 'static') but it did not help

Did you also set up the static file mappings on the "Web" page? See this help page.

Problem was with .PNG and .png On local server .PNG == .png Here .PNG != .png Now it is working. Now, if the user types in the address bar 'mur-remont.ru' it do not work. It is nesessary to type 'www.mur-remont.ru' Is there any way to fix it?

Yes, if you want to set up a working naked domain, you need extra steps, see this help page.