Superuser बनाना
In this page:
python manage.py createsuperuser
`createsuperuser` Run करना
createsuperuser management command आपको एक username, email, और password set करने के through guide करता है, फिर पूरे admin rights वाली एक User row save करता है।
उदाहरण: Running createsuperuser
This starts the interactive prompt; answer the username/email/password questions to finish.
python manage.py createsuperuser
⚠️ Run this in your own terminal or Node.js environment.
एक Account को Superuser क्या बनाता है
Behind the scenes, createsuperuser बस User model पर दो boolean flags set करता है: is_staff account को /admin/ में login करने देता है, और is_superuser individual permissions assign किए बिना हर permission grant करता है।
उदाहरण: What Makes an Account a Superuser
Inspecting the created user in the shell confirms both flags were set to True.
python manage.py shell
>>> from django.contrib.auth.models import User
>>> u = User.objects.get(username='admin')
>>> u.is_staff, u.is_superuser
(True, True)
⚠️ Run this in your own terminal or Node.js environment.
Login करना और Access Confirm करना
एक बार superuser मौजूद हो, dev server start करें और उन credentials के साथ /admin/ पर login करें यह confirm करने के लिए कि dashboard load होता है।
is_active True है।उदाहरण: Logging In and Confirming Access
Starts the dev server so you can visit http://127.0.0.1:8000/admin/ and log in.
python manage.py runserver
⚠️ Run this in your own terminal or Node.js environment.
- एक regular user account से
/admin/में login करने की कोशिश करना जिसे कभी staff या superuser status नहीं दिया गया। - Superuser बनाने के ठीक बाद एक non-interactive script में password भूल जाना।
- मौजूदा superuser को reuse करने के बजाय हर बार एक नया superuser बनाना, कई admin accounts के साथ खत्म होना।
python manage.py createsuperuserusername, email, और password के लिए एक interactive prompt start करता है।- एक superuser अपने आप
is_staff=Trueऔरis_superuser=Trueरखता है, पूरा admin access grant करते हुए। - Admin dashboard उपयोग करने योग्य होने से पहले आपको कम से कम एक superuser चाहिए।
Chapter Quiz — Complete all 8 topics to unlock
0/8 topics done
Complete these topics first: