M
M
Mistadrumma2016-03-26 18:49:19
Django
Mistadrumma, 2016-03-26 18:49:19

Why swears at the argument?

Hello! I can't figure out why django is crashing. Please help a newbie.
There is a registration of the Articles model with the configuration ArticleAdmin
admin.site.register(Articles, ArticleAdmin)
When I substitute ArticleAdmin as an argument, it fails. Well without it works accordingly. On python 3.5 I also ran it on a local server, it worked.
On python 2.7 , it fails with an error
There is an admin.py file

# coding=utf-8
from getpass import getuser

from django.contrib import admin

# Register your models here.

# Register your models here.
from castshop import models
from castshop.models import Articles, Comments





def make_published(modeladmin, request, queryset):
    queryset.update(article_status='p')
    queryset.update(article_published=getuser())
    queryset.update(article_status_ok=True)
    # make_published.short_description = 'Опублиовать'

def close_published(modeladmin,request,queryset):
    queryset.update(article_status='w')
    queryset.update(article_status_ok=False)
    # make_published.short_description = 'Снять с публикации'

#Опции отображения полей ситатей в админке



class ArticleAdmin(admin.ModelAdmin):
        fields = ('article_title', 'article_text', 'article_date','article_user')
        inlines = [ArticleComments]
        list_filter = ['article_date', 'article_status_ok']
        actions = [make_published, close_published]
        list_display = ['article_title','article_date', 'article_status','article_published','article_status_ok']
        # list_editable = ['article_title', 'article_status']
        save_on_top = True
        search_fields = ['article_title','article_published' ]


class ArticleComments (admin.StackedInline):
    model = Comments
    extra = 2


admin.site.register(Articles, ArticleAdmin)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sazhyk, 2016-04-01
@sazhyk

Mistadrumma : isn't it?
# -*- coding: utf-8 -*-

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question