N
N
NeFek2020-06-10 16:46:43
Django
NeFek, 2020-06-10 16:46:43

Have all the fields in Django Admin changed?

Created a Django project, filled in models.py and admin.py
A problem arises:

spoiler
8v6BkpB.png

models.py:
spoiler
from django.db import models

class users(models.Model):
  ban_chouse = (
    ('1', 'Заблокирован'),
    ('0', 'Не Заблокирован'),
  )

  admin_chouse = (
    ('1', 'Да'),
    ('0', 'Нет'),
  )
  userid = models.TextField(verbose_name = 'Ид'),
  username = models.TextField(verbose_name = '@username'),
  usernick = models.TextField(verbose_name = 'Имя'),
  usertag = models.TextField(verbose_name = 'Тег'),
  reps = models.CharField(verbose_name = 'Баланс'),
  date_reg = models.CharField(max_length = 3500,verbose_name = 'Дата регистрации'),
  questions = models.TextField(verbose_name = 'Ответы на вопросы'),
  status = models.TextField(verbose_name = 'Активирован',choices=admin_chouse, default='0'),
  ban = models.CharField(max_length = 3500,verbose_name = 'Блокировка',choices=ban_chouse, default='0')
  rank = models.TextField(verbose_name = 'Ранг'),
  domens = models.TextField(verbose_name = 'Домены'),
  user_nick = models.TextField(verbose_name = 'Пользовательский ник'),
  admin = models.CharField(max_length = 3500,verbose_name = 'Есть доступ к админке?',choices=admin_chouse, default='0'),
  strakes = models.CharField(max_length = 3500,verbose_name = 'Количество страйков')

  class Meta:
    verbose_name = 'Пользователь'
    verbose_name_plural = 'Пользователи'


admin.py:
spoiler
from django.contrib import admin
from .models import users
from django.forms import TextInput, Textarea
from django.db import models


@admin.register(users)
class ProfileAdmin(admin.ModelAdmin):
  list_display = ('id','userid','username','usernick','usertag','reps','date_reg','questions','status','ban','rank','domens','user_nick','admin','strakes')
  fields = ['userid','username','usernick','usertag','date_reg','questions','status','ban','rank','domens','user_nick','admin',('strakes','reps')]
  search_fields = ['userid','username','usernick','usertag','reps','date_reg','questions','status','ban','rank','domens','user_nick','admin','strakes']


How to fix?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rm root, 2020-06-10
@rm_root

try like this don't forget "admin.site.register(users, ProfileAdmin )" you have admin.register(users) and you need admin .site. register(users, ProfileAdmin )

class ProfileAdmin(admin.ModelAdmin):
  list_display = ('id','userid','username','usernick','usertag','reps','date_reg','questions','status','ban','rank','domens','user_nick','admin','strakes')
  fields = ['userid','username','usernick','usertag','date_reg','questions','status','ban','rank','domens','user_nick','admin',('strakes','reps')]
  search_fields = ['userid','username','usernick','usertag','reps','date_reg','questions','status','ban','rank','domens','user_nick','admin','strakes']

admin.site.register(users, ProfileAdmin )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question