urls.py
from django.conf.urls import url, include
from django.contrib import admin
from design_engineer.views import *
from django.conf.urls.static import static
from django.conf import settings
from django.contrib.staticfiles import *
from django.views.generic import TemplateView, ListView
from django.contrib.auth.decorators import login_required, permission_required
urlpatterns = [
url(r'^projects/photo$', ProjectsPhotoView.as_view(), name='projects_photo'),
url(r'^django/tutorial/$', TemplateView.as_view(template_name='django_tutorial.html'), name='django_tutorial'),
url(r'^login/$', LoginView.as_view(), name='authenticate'),
url(r'^logout/', LogoutView.as_view(), name="log_aut"),
url(r'^project_create/$', NewProjectCreate.as_view(), name='new_project'),
url(r'^create/module/$', permission_required('Module.can_add_new_module')(ModuleCreateView.as_view()),
name='new_module'),
url(r'^create/$', TaskItemCreate.as_view(), name='create'),
url(r'^delete(?P<pk>\d+)-(?P<id>\d+)$', TaskItemDelete.as_view(), name='delete'),
url(r'^edit/(?P<pk>\d+)-(?P<id>\d+)$', TaskItemEdit.as_view(), name='edit'),
url(r'^test/$', TemplateView.as_view(template_name='index.html'), name='index'),
url(r'^module/project_objectives/(?P<pk>\w)/$', ProjectObjectivesView.as_view(), name='project_objectives'),
url(r'^projects/module/(?P<pk>\w)/photo$', ModulePhotoView.as_view(), name='project_module_photo'),
url(r'^projects/module/(?P<pk>\w)/$', ModuleView.as_view(), name='project_module'),
url(r'^basic/module/(?P<pk_old>\w)/(?P<pk>\w)/$', BasicModuleDetailsView.as_view(), name='basic_module_detail'),
url(r'^basic/module/(?P<pk>\w)/$', BasicModuleView.as_view(), name='basic_module'),
url(r'^admin/', admin.site.urls),
url(r'^rooms/(?P<pk>\w+)/$', RoomView.as_view(), name='rooms'),
url(r'^create/important-features/$', ImportantFeaturesCreate.as_view(), name='important_features_create'),
url(r'^projects/(?P<name>\w+)-(?P<pk>\d+)/$', ProjectsView.as_view(), name='projects'),
url(r'^projects/all/$', login_required(ProjectsAllView.as_view()), name='projects_all'),
url(r'^executor/$', ExecutorView.as_view(), name='executor'),
url(r'^$', HomeView.as_view(), name='home'),
]
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
структура проекта
settings.py
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',
'django.template.context_processors.media',
],
},
},
]
WSGI_APPLICATION = 'workplace_site.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
# }
# }
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'jagrmi$workplace',
'HOST': 'jagrmi.mysql.pythonanywhere-services.com',
'PORT': '3306',
'USER': 'jagrmi',
'PASSWORD': 'faust098',
'OPTIONS': {
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
}
}
}
# Password validation
# https://docs.djangoproject.com/en/1.10/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/1.10/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/1.10/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
LOGIN_URL = 'authenticate'
SITE_ID = 1
try:
from workplace_site.local_settings import *
except ImportError:
pass
пример html-кода из шаблона
<!DOCTYPE html>
{% load static %}
{% load staticfiles %}
<html lang="en">
<head>
{% block title%}
<title>Home</title>
{% endblock %}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link href="{% static 'css/layout.css' %}" rel="stylesheet" type="text/css" media="all">
</head>
<body id="top">
<!-- Top Background Image Wrapper -->
{#<a href="{% static %}"></a>#}
<div class="bgded overlay" style="background-image:url('{% static 'images/backgrounds/01_2.png' %}');">
<div class="wrapper row0">
<div id="topbar" class="hoc clear">
<div class="fl_left">
<ul class="nospace">
<li><a href="#"><i class="fa fa-lg fa-home"></i></a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
{% if request.user.is_authenticated %}
<li>Hello <strong>{{ request.user }}</strong></li>
<li><a href={% url 'log_aut' %}>Logaut</a></li>
{% else %}
<li><a href={% url 'authenticate' %}>Login</a></li>
<li><a href="#">Register</a></li>
{% endif %}
</ul>
</div>
<div class="fl_right">
<ul class="nospace">
<li><i class="fa fa-phone"></i> +375298888132</li>
<li><i class="fa fa-envelope-o"></i> a.ramanchyk@gmail.com</li>
</ul>
</div>
</div>
</div>
Ранние ссылка на url и static работают, новые не хотят.
В чем я сделал ошибку?