articles/models/article.py:
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
class Article(models.Model):
title = models.CharField(max_lenght=32, verbose_name=_('name'))
articles/views/article.py:
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.views import generic
class ArticleMixin(object):
fields = ['title']
model = Article
paginate_by = 30
def get_success_url(self):
return reverse('articles_article_index')
class Index(ArticleMixin, generic.ListView):
template_name = 'articles/index.html'
class Create(ArticleMixin, generic.CreateView):
template_name = 'articles/create.html'
class Update(ArticleMixin, generic.UpdateView):
template_name = 'articles/update.html'
class Delete(ArticleMixin, generic.DeleteView):
template_name = 'articles/delete.html'
index = Index.as_view()
create = Create.as_view()
update = Update.as_view()
delete = Delete.as_view()
articles/urls.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.conf.urls import url
from django.conf.urls import patterns
from articles.views import article
urlpatterns = patterns('',
url(r'^$', article.index, name='articles_article_index'),
url(r'^update/(?P<pk>[\w-]+)/$', article.update, name='articles_article_update'),
url(r'^delete/(?P<pk>[\w-]+)/$', article.delete, name='articles_article_delete'),
url(r'^create/$', article.create, name='articles_article_create'),
)
queryset = Patient.objects.filter(id=1)
def get_context_data(self, **kwargs):
context = super(PatientDetailView, self).get_context_data(**kwargs)
context['patient'] = Patient.objects.get(id=id)
return context
def signup(request):
user_form = UserCreateForm(data=request.POST)
if request.method == 'POST':
if user_form.is_valid():
model = user_form.save()
user = authenticate(username=model.username, password=model.password)
login(request, user)
return redirect('/edit')
else:
return index(request, user_form=user_form)
return redirect('/edit')
url(r'^category/(?P<pk1>\d+)/(?P<pk2>\d+)/(?P<pk3>\d+)/$', views.index, name='category'),
class Index(generic.ListView):
model = Category
paginate_by = 3
ordering = '-id'
template_name = 'articles/index.html'
def get_queryset(self):
return Category.objects.filter(id__in=(self.kwargs('pk1'), self.kwargs('pk2'), self.kwargs('pk3')))
index = Index.as_view()
assets/AppAsset.php
ADMINS = (('Your nam.', 'mailfor_error@gmail.com'),)
...
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.yandex.ru' # or google
EMAIL_HOST_PASSWORD = 'password'
EMAIL_HOST_USER = 'login'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = DEFAULT_FROM_EMAIL
EMAIL_PORT = 465
EMAIL_USE_SSL = True
...
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s '
'%(process)d %(thread)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'null': {
'level': 'DEBUG',
'class': 'django.utils.log.NullHandler',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
'include_html': True,
}
},
'loggers': {
'django': {
'handlers': ['console'],
'propagate': True,
'level': 'INFO',
},
'django.db': {
'level': 'DEBUG',
'handlers': ['console'],
'propagate': True,
},
'django.request': {
'handlers': ['mail_admins', 'console'],
'level': 'ERROR',
'propagate': False,
},
}
}