Ответ
Опции темы Опции просмотра
Непрочитано 16.07.2022, 13:39   #1
citay44929
Новичок
 

Город: sdasdv
Регистрация: 16.07.2022
Сообщений: 2

По умолчанию Which command is used to create a superuser in Django?

Which command is used to create a superuser in Django?

If you're planning on publishing something on your server, you're going to want to create a superuser. This superuser has access to all your installed apps and can run management commands remotely. Here's how you do it with the Django command-line utility. The create user command is used to create a new user in Django.

Код:
from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth.models import User

class Command(BaseCommand):

    def handle(self, *args, **options):

        # The magic line
        User.objects.create_user(username= 'rmx',
                                email='superuser@super.com',
                                password='rmx55',
                                is_staff=True,
                                is_active=True,
                                is_superuser=True
        )
citay44929 вне форума   Ответить с цитированием
Ответ

Метки
programing

Опции темы
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.

Быстрый переход