Категория: Технология программирования

Кол-во просмотров: 677

Теги: #python #django #html+css #javascript


django calendar из админки

В forms создаем новый класс

from django import forms
from widgets import AdminSplitDateTime
from schedule.models import Schedule


class ScheduleForm(forms.ModelForm):
    def __init__(self, *args, **kwargs):
        super(ScheduleForm, self).__init__(*args, **kwargs)
        self.fields['slug'].widget.attrs['readonly']='readonly'
        # activating calendar
        self.fields['begins_at'].widget = AdminSplitDateTime()
        self.fields['ends_at'].widget = AdminSplitDateTime()

    class Meta:
        model = Schedule
        exclude = ('user', )

 

В стили html добавляем 

{% load i18n %}


<script type="text/javascript">window.__admin_media_prefix__ = "/static/admin/";</script>
<script type="text/javascript">window.__admin_utc_offset__ = "10800";</script>
<script type="text/javascript" src="/admin/jsi18n/js/jsi18n.js"></script>
<script type="text/javascript" src="/static/admin/js/core.js"></script>
<script type="text/javascript" src="/static/admin/js/admin/RelatedObjectLookups.js"></script>
<script type="text/javascript" src="/static/admin/js/calendar.js"></script>
<script type="text/javascript" src="/static/admin/js/admin/DateTimeShortcuts.js"></script>
<link rel="stylesheet" type="text/css" href="/static/admin/css/widgets.css"/>

 

В urls.py добавляем

url(r'^admin/jsi18n', 'django.views.i18n.javascript_catalog'),

 

Категория: Технология программирования

Кол-во просмотров: 677

Дата создания: 12 ноября 2015 г.

Теги: #python #django #html+css #javascript

captcha
Joshuadus

http://cialisnnq.com - buy cialis <a href="http://cialisnnq.com">buy cialis</a> http://cialisrrr.com - buy cialis <a href="http://cialisrrr.com">buy cialis</a> http://cialisnnq.com - buy cialis online <a href="http://cialisnnq.com">buy cialis online</a> http://cialisrrr.com - buy cialis online <a href="http://cialisrrr.com">buy cialis online</a>

Robertrow

The best fitness tip for building up your arms is to work opposite muscles in opposite sets of each other. The best example would be to work the triceps and then the biceps. Each has the opportunity to rest while the other is being worked. This minimizes your time and maximizes your workout. <a href=https://www.acheterviagrafr24.com/>https://www.acheterviagrafr24.com/</a>