Setting Up Your Django App
To learn to more about the concepts covered this lesson, you can check out:
00:00 Setting Up the Django Project. This course uses Django 4.0.2 and Python 3.10. It focuses on user management, so you won’t use any advanced or responsive styling.
00:15 It also doesn’t deal with groups and permissions, only creating and managing user accounts. It’s a good idea to use a virtual environment when working with Python projects.
00:26 That way you can always be sure that the Python command points to the right version of Python and that the modules required by your project have the correct versions. To learn more about this, check out this Real Python course.
00:42 To create a virtual environment, run the following command. On Linux and macOS, this is the command you’ll need to activate the virtual environment.
01:02 On Windows, this is the command you’ll need to activate the virtual environment.
01:12
These next two lines upgrade pip
and install the correct version of Django.
01:30 Now that the environment is ready, you can create a new project and an application to store all your user management code.
01:52
In this example, your application is called users
. To install it, you need to modify settings.py
and add it to the list of installed apps, as seen on-screen.
02:09 The next step is to apply the migrations and run the server. This will create all user-related models in the database and start the application at the address seen on-screen.
02:28 In this course, you’ll be using Django’s built-in user model. In practice, you would more likely create a custom user model extending the functionality offered by Django.
02:38 You can read more about customizing the default user model in Django’s documentation. There’s one more thing you should do for this setup. By default, Django enforces strong passwords to make user accounts less prone to attacks, but you’ll be changing passwords often during the course of this course, and figuring out a strong password each time would be inconvenient.
03:01
You can solve this issue by disabling password validators in settings. Just comment them out, leaving an empty list, as seen on-screen. Now Django will allow you to set passwords like password
or even pass
, making your work with the user management system much easier.
03:23 But remember, the validators should be left enabled in any actual application. For this course, it will also be useful to have access to the admin panel so you can track newly created users and their passwords.
03:38 Go ahead and create a superuser, as seen on-screen.
03:50 With the password validators disabled, you can use any password you like. In the next section of the course, you’ll get started with the project proper by creating a dashboard view.
Become a Member to join the conversation.