- Add the provided Django authentication views to the project's URLconf.
- Test
/accounts/login
in your browser --- see if you can log in using usernameadmin
and passworddjangopony
. - In
base.html
, hide theNew Page
andLog Out
buttons for unauthenticated users. - When a user clicks
Log Out
, they are logged out of the system, and returned to the homepage. - When a user clicks
Log In
, they are navigated to the Login page. - Replace
Hello, USERNAME
text with the username of the logged-in user, and only show it when the user is logged in.
- Create a new app named
accounts
. Add it to theINSTALLED_APPS
list insettings.py
. - Create a view for signing up:
- Must subclass
django.views.generic.CreateView
. - Set
form_class
todjango.auth.forms.UserCreationForm
. - Render the
registration/signup.html
template.
- Must subclass
- In
accounts/urls.py
, linkSignupView
to a URL namedsignup
. - Add
accounts.urls
to the project's URLconf. - When a user clicks
Sign Up
, they are presented with a form to create an account, and can submit it successfully.
- Add a
Forgot Password
link to the Log in page.
- Uncomment the
path()
for thewiki
app below. Use it to direct any request (except/admin
URLs) to the thewiki
app's URL configuration. Use the above docstring to guide you if you feel stuck. - Make sure Django doesn't give you any warnings or errors when you execute
python manage.py runserver
.
PageListView
:
- On
GET
, display a homepage that shows all Pages in your wiki. - Replace the CHALLENGE text with a descriptive docstring for
PageListView
. - Replace
pass
below with the code to render a template namedlist.html
.
- Refactor the URL named
wiki-list-page
and point it to the root route (/
).- Make sure Django doesn't give you any warnings or errors when you execute
python manage.py runserver
. - Test by visiting http://127.0.0.1:8000/.
- Make sure Django doesn't give you any warnings or errors when you execute
- Refactor the URL named
wiki-details-page
to show theDetailsView
for anyPage
that exists. - Use theslug
field in thePage
model to accomplish this. - DO NOT CHANGE thename
argument. - Test by visiting http://127.0.0.1:8000/title-slug in your browser.
-
📓 Pages
: Replace#
with theurl
template tag.
-
Add time zone support for
created
andmodified
dates if you're receiving the warning below:RuntimeWarning: DateTimeField received a naive datetime (YYYY-MM-DD HH:MM:SS) while time zone support is active
-
Add the ability to update the slug when the Page is edited.
- Import the
PageForm
class fromforms.py
.- This
ModelForm
enables editing of an existingPage
object in the database.
- This
- On
GET
, render an edit form below the page details. - On
POST
, check if the data in the form is valid.- If
True
, save the data, and redirect back to theDetailsView
. - If
False
, display all the errors in the template, above the form fields.
- If
- Instead of hard-coding the path to redirect to, use the
reverse
function to return the path. - After successfully editing a
Page
, use Django Messages to "flash" the user a success message: "REPLACE_WITH_PAGE_TITLE has been successfully updated."