I'm trying to run a Django admin page in PyCharm.
I've created a test project with an empty test app and a simple model.
class User(models.Model):
name = models.CharField(max_length=15)
email = models.EmailField()
As I open 127.0.0.1:8000/admin/
I can see the admin page. However, not only I don't know where the password is (I don't recall setting any password so far) but trying to login will crash the server with this error:
OperationalError at /admin/
no such table: auth_user
Exception Location: /Library/Python/2.7/site-packages/django/db/backends/sqlite3/base.py in execute, line 451
Why? And how can I set a password?
In a terminal, cd
into your project root and type ./manage.py syncdb
. This will create the initial tables.
When it gets around to creating the auth_user
table, it will ask you to create an admin user, and set a password on it. These are the credentials you need to log in to the admin interface.
Edit: For those using Django 1.7+, the correct command to sync your database initially is now ./manage.py migrate
. Keep in mind that this will not prompt you to create an admin user automatically. In order to bring up the prompt, run the command ./manage.py createsuperuser
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With