← Back to Django Course | Chapter 8: Django Admin | Lesson 2 of 8

Superuser बनाना

एक superuser master account है जो admin dashboard में login कर सकता है और सब कुछ manage कर सकता है।
Syntax
markup
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.

bash
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.

bash
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 होता है।

Note: अगर login page एक सही password reject करे, double-check करें कि उस user पर 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.

bash
python manage.py runserver

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. एक regular user account से /admin/ में login करने की कोशिश करना जिसे कभी staff या superuser status नहीं दिया गया।
  2. Superuser बनाने के ठीक बाद एक non-interactive script में password भूल जाना।
  3. मौजूदा superuser को reuse करने के बजाय हर बार एक नया superuser बनाना, कई admin accounts के साथ खत्म होना।
चैप्टर सारांश
  • python manage.py createsuperuser username, email, और password के लिए एक interactive prompt start करता है।
  • एक superuser अपने आप is_staff=True और is_superuser=True रखता है, पूरा admin access grant करते हुए।
  • Admin dashboard उपयोग करने योग्य होने से पहले आपको कम से कम एक superuser चाहिए।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.