コード例 #1
0
class ArticleCreateView(CreateView):
    page_title = _("Create Article")
    # fields = ['title', 'description', 'tags', 'category', 'published']
    model = Article
    inlines = [ImagesInline]
    form_class = ArticleForm
    permission_required = "add_article"
    layout = OrderedDict([
        (_c('Basic Details'),
            ['title', ['category|4', 'tags']]),
        (_c('Body|Extra Information for this fieldset', True),
            ['description']),
        (_('Extended Details'),
            [['published|4', 'updated_at']])])

    def get_success_url(self):
        return reverse('articles:detail', args=(self.object.pk,))
コード例 #2
0
class ArticleCreateView(CreateView):
    page_title = _("Create Article")
    # fields = ['title', 'description', 'tags', 'category', 'published']
    model = Article
    inlines = [ImagesInline]
    form_class = ArticleForm
    permission_required = "add_article"
    layout = OrderedDict([
        (_c("Basic Details"), ["title", ["category|4", "tags"]]),
        (
            _c("Body|Extra Information for this fieldset", True),
            ["description"],
        ),
        (_("Extended Details"), [["published|4", "updated_at"]]),
    ])

    def get_success_url(self):
        return reverse("articles:detail", args=(self.object.pk, ))
コード例 #3
0
class ArticleUpdateView(UpdateView):
    page_title = _("Edit Article")
    permission_required = "change_article"
    model = Article
    # success_url = reverse_lazy('articles:list')
    inlines = [ImagesInline]
    inline_sort_field = "order"
    form_class = ArticleForm
    actions = [(_("Cancel"), "cancel"), (_("Save"), "submit")]
    layout = OrderedDict([
        (_c("Basic Details"), ["title", ["category|4", "tags"]]),
        (
            _c("Body|Extra Information for this fieldset", True),
            ["description"],
        ),
        (_("Extended Details"), [["published|4", "updated_at"]]),
    ])

    def get_success_url(self):
        return reverse("articles:detail", args=(self.object.pk, ))
コード例 #4
0
class ArticleUpdateView(UpdateView):
    page_title = _("Edit Article")
    permission_required = "change_article"
    model = Article
    # success_url = reverse_lazy('articles:list')
    inlines = [ImagesInline]
    form_class = ArticleForm
    actions = [
        (_('Cancel'), 'cancel'),
        (_('Save'), 'submit'),
    ]
    layout = OrderedDict([
        (_c('Basic Details'),
            ['title', ['category|4', 'tags']]),
        (_c('Body|Extra Information for this fieldset', True),
            ['description']),
        (_('Extended Details'),
            [['published|4', 'updated_at']])])

    def get_success_url(self):
        return reverse('articles:detail', args=(self.object.pk,))