![]() |
|
|
|||||||
| Notices |
| Indonesia Membangun! Main Forum Description |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
Warga Forumku
Join Date: 16 Jul 2022
Userid: 9567
Posts: 2
Likes: 0
Liked 0 Times in 0 Posts
|
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. Which command is used to create a superuser in Django? | CodeProZone Code:
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
)
Code:
user@host> manage.py shell
>>> from django.contrib.auth.models import User
>>> user=User.objects.create_user('foo', password='bar')
>>> user.is_superuser=True
>>> user.is_staff=True
>>> user.save()
|
|
|
|
| Sponsored Links |
|
| Bookmarks |
| Tags |
| command, create, django, superuser, user |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Create Your own ERC20 Token | Jacob_Black | Cryptocurrency | 0 | 14th July 2022 06:32 PM |
| Linux Check Disk Space Command untuk melihat penggunaan Disk Sistem (df & du) | zylgwyn Lucas | Forumku Operating System | 0 | 14th June 2022 12:17 PM |
| Create your own trc20 token... | Jacob_Black | Cryptocurrency | 0 | 2nd June 2022 07:15 PM |
| Create your own TRC20 token?? | Jacob_Black | Cryptocurrency | 0 | 30th May 2022 07:41 PM |
| How to create and sell NFT art | Dwaynechrish | Blockchain and Cryptocurrency | 0 | 8th November 2021 05:01 PM |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
|
|