mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[1.7.x] Fixed #22770 -- Removed create_superuser from post_migrate signals.
Moved logic to syncdb command for backwards compatibility.
Backport of 93d05536fd from master
			
			
This commit is contained in:
		| @@ -206,40 +206,7 @@ The :djadmin:`migrate` command looks at the :setting:`INSTALLED_APPS` setting | ||||
| and creates any necessary database tables according to the database settings | ||||
| in your :file:`mysite/settings.py` file and the database migrations shipped | ||||
| with the app (we'll cover those later). You'll see a message for each | ||||
| migration it applies, and you'll get a prompt asking you if you'd like to | ||||
| create a superuser account for the authentication system. | ||||
|  | ||||
| First, you'll be asked if you would like to create a superuser. Type the word | ||||
| ``yes`` and hit enter. | ||||
|  | ||||
| .. code-block:: text | ||||
|  | ||||
|     You have installed Django's auth system, and don't have any superusers defined. | ||||
|     Would you like to create one now? (yes/no): yes | ||||
|  | ||||
| Next, enter a username. By default, this will be your system username. Enter | ||||
| your desired username and press enter. | ||||
|  | ||||
| .. code-block:: text | ||||
|  | ||||
|     Username (leave blank to use 'your_username'): admin | ||||
|  | ||||
| You will then be prompted for your desired email address: | ||||
|  | ||||
| .. code-block:: text | ||||
|  | ||||
|     Email address: admin@example.com | ||||
|  | ||||
| The final step is to enter your password. You will be asked to enter your | ||||
| password twice, the second time as a confirmation of the first. | ||||
|  | ||||
| .. code-block:: text | ||||
|  | ||||
|     Password: ********** | ||||
|     Password (again): ********* | ||||
|     Superuser created successfully. | ||||
|  | ||||
| With that done, if you're interested, run the command-line client for your | ||||
| migration it applies. If you're interested, run the command-line client for your | ||||
| database and type ``\dt`` (PostgreSQL), ``SHOW TABLES;`` (MySQL), or | ||||
| ``.schema`` (SQLite) to display the tables Django created. | ||||
|  | ||||
|   | ||||
| @@ -21,6 +21,37 @@ automatically-generated admin site. | ||||
|     The admin isn't intended to be used by site visitors. It's for site | ||||
|     managers. | ||||
|  | ||||
| Creating an admin user | ||||
| ====================== | ||||
|  | ||||
| First we'll need to create a user who can login to the admin site. Run the | ||||
| following command: | ||||
|  | ||||
| .. code-block:: bash | ||||
|  | ||||
|     $ python manage.py createsuperuser | ||||
|  | ||||
| Enter your desired username and press enter. | ||||
|  | ||||
| .. code-block:: text | ||||
|  | ||||
|     Username: admin | ||||
|  | ||||
| You will then be prompted for your desired email address: | ||||
|  | ||||
| .. code-block:: text | ||||
|  | ||||
|     Email address: admin@example.com | ||||
|  | ||||
| The final step is to enter your password. You will be asked to enter your | ||||
| password twice, the second time as a confirmation of the first. | ||||
|  | ||||
| .. code-block:: text | ||||
|  | ||||
|     Password: ********** | ||||
|     Password (again): ********* | ||||
|     Superuser created successfully. | ||||
|  | ||||
| Start the development server | ||||
| ============================ | ||||
|  | ||||
| @@ -59,10 +90,7 @@ browser's settings and on whether Django has a translation for this language. | ||||
| Enter the admin site | ||||
| ==================== | ||||
|  | ||||
| Now, try logging in. You created a superuser account in the first part of this | ||||
| tutorial, remember?  If you didn't create one or forgot the password you can | ||||
| :ref:`create another one <topics-auth-creating-superusers>`. | ||||
|  | ||||
| Now, try logging in with the superuser account you created in the previous step. | ||||
| You should see the Django admin index page: | ||||
|  | ||||
| .. image:: _images/admin02.png | ||||
|   | ||||
| @@ -1420,9 +1420,8 @@ This command is only available if Django's :doc:`authentication system | ||||
| </topics/auth/index>` (``django.contrib.auth``) is installed. | ||||
|  | ||||
| Creates a superuser account (a user who has all permissions). This is | ||||
| useful if you need to create an initial superuser account but did not | ||||
| do so during the first :djadmin:`migrate`, or if you need to programmatically | ||||
| generate superuser accounts for your site(s). | ||||
| useful if you need to create an initial superuser account or if you need to | ||||
| programmatically generate superuser accounts for your site(s). | ||||
|  | ||||
| When run interactively, this command will prompt for a password for | ||||
| the new superuser account. When run non-interactively, no password | ||||
|   | ||||
| @@ -66,9 +66,7 @@ interactively <auth-admin>`. | ||||
| Creating superusers | ||||
| ------------------- | ||||
|  | ||||
| :djadmin:`manage.py migrate <migrate>` prompts you to create a superuser the | ||||
| first time you run it with ``'django.contrib.auth'`` installed. If you need to | ||||
| create a superuser at a later date, you can use a command line utility:: | ||||
| Create superusers using the :djadmin:`createsuperuser` command:: | ||||
|  | ||||
|     $ python manage.py createsuperuser --username=joe --email=joe@example.com | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user