/etc/apache2//etc/nginx/- sites
+ project_name_one
- env (тут окружение)
- tmp
- logs
- source (тут весь код)
+ project_name_two
- env (тут окружение)
- tmp
- logs
- source (тут весь код)python manage.py makemigrations
python manage.py migrate«Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живёте» © Стив Макконнелл
queryset.filter(**params).only('dates', 'type_date').select_related(*select_rel).order_by('-dates', '-create')
queryset.values('dates').annotate(count=Count('dates')).order_by() # Сбросил сортировкуSELECT `dates`, COUNT(`dates`) AS `count`
FROM `gigdate_dateall`
WHERE (`dates` IN (2015-08-31, 2015-09-01, 2015-09-02, 2015-09-03) AND `type_date` = 0)
GROUP BY `dates` ORDER BY NULLdates = models.DateField(_(u'Дата календаря'), blank=False)
...
class Meta:
ordering = ['-dates', '-create']SELECT `dates`, COUNT(`dates`) AS `count`
FROM `gigdate_dateall`
WHERE (`dates` IN (2015-08-31, 2015-09-01, 2015-09-02, 2015-09-03) AND `type_date` = 0)
GROUP BY `dates`, `create` ORDER BY `dates` DESC, `create` DESC from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
class ValidLogin(object):
def process_request(request):
if not request.user.is_authenticated():
return HttpResponseRedirect(reverse('signin'))
return NoneMIDDLEWARE_CLASSES = (
'project.middleware.ValidLogin',
)from django.conf.urls import patterns, url
from django.contrib.auth.decorators import user_passes_test
urlpatterns = patterns('crm.views',
url(r'^$',
user_passes_test(lambda u: u.is_superuser or u.is_moderator)(HomeCRM.as_view()),
name='home'),
)from django.contrib.auth.decorators import login_required
urlpatterns = patterns('crm.views',
url(r'^$',
login_required(HomeCRM.as_view()),
name='home'),
)zigen: Разобрался
class MyClassDetailView(DetailView):
model = User
slug_field = 'username'[04/Jul/2015 14:33:31]"GET /?page=2&querystring_key=page HTTP/1.1" 500 160329
[04/Jul/2015 14:33:42]"GET /?page=2&querystring_key=page HTTP/1.1" 200 6458RemovedInDjango19Warning: `request.REQUEST` is deprecated, use `request.GET` or `request.POST` instead.
#-*- coding:utf-8 -*-
from django.utils.translation import ugettext_lazy as _
class Registration(models.Model):
...
create = models.DateTimeField(_(u"#Создано"), auto_now_add=True, blank=True, null=True)
class Meta:
verbose_name = _(u'#Регистрация')
verbose_name_plural = _(u'#Подтверждение регистрации')