tag: tests

AbstractUser vs AbstractBaseUser vs User extended profile in Django Part 2
Maria D. Campbell
A step-by-step walkthrough of building a custom Django user model using AbstractUser, including a custom manager, tests-first setup, migrations, and admin configuration.
#fullstack development, #macOS, #django, #python3, #abstractuser, #admin, #forms, #model manager, #tests, #unittest, #user model, #schema, #series, #superuser

AbstractUser vs AbstractBaseUser vs User extended profile in Django Table of Contents
Maria D. Campbell
A table of contents for my series on Django's AbstractUser, AbstractBaseUser, and extended User profile approaches — covering custom user models, migrations, forms, admin configuration, and testing.
#fullstack development, #macOS, #django, #python3, #abstractuser, #abstractbaseuser, #admin, #forms, #model manager, #tests, #unittest, #user model, #schema, #series, #superuser

AbstractUser vs AbstractBaseUser vs User extended profile in Django Part 1
Maria D. Campbell
A test-driven walkthrough of building a custom user model with AbstractBaseUser in Django, including the model manager, migrations, forms, and admin configuration.
#fullstack development, #macOS, #django, #python3, #abstractbaseuser, #admin, #forms, #model manager, #tests, #unittest, #user model, #schema, #series, #superuser

How to create a fullstack application using Django and Python Part 29
Maria D. Campbell
In this section, I create tests for the like_post view.
#fullstack development, #macOS, #django, #python3, #like post, #series, #tests, #unittest

How to create a fullstack application using Django and Python Part 27
Maria D. Campbell
In this section, I make some adjustments to existing functionalities, sanitize our Markdown, add code formatting and highlighting to our Markdown, create tests for the ProfileListView, protected function based profile view, and profile_detail view, update accounts/tests/test_form_signup_test.py, fix the topic posts avatar issue, and explain the extended profile functionality.
#fullstack development, #macOS, #django, #python3, #code refactoring, #markdown, #nh3, #sanitization, #fenced code, #code highlighting, #pygments, #series, #tests, #unittest

How to create a fullstack application using Django and Python Part 23
Maria D. Campbell
In this section, I create a generic class based view called UserUpdateView (My Account view), associated tests, a URL, and template.
#fullstack development, #macOS, #django, #generic class based views, #python3, #series, #tests, #unittest

How to create a fullstack application using Django and Python Part 21
Maria D. Campbell
In this section, I create a generic class-based (GCBV) PostUpdateView, PostDeleteView, and PostDetailView, create the associated urls and templates, create PostUpdateView, PostDeleteView, and PostDetailView tests, debug the code and tests, and check the test coverage of the django_boards project code.
#fullstack development, #macOS, #coverage, #context, #dispatch, #django, #python3, #generic class based views, #method decorators, #series, #tests, #unittest

How to create a fullstack application using Django and Python Part 22
Maria D. Campbell
In this section, I implement a Generic Class Based view and pagination to the index/home view, add pagination to the topics view and topic_posts view, add pagination to the associated templates, refactor the associated urls in urls.py, and refactor the associated tests. I also add a copy link button to copy the link to a topic's replies, a scroll top and scroll bottom button using JavaScript to enable their functionality, and add JavaScript code to make the scrollbar return to the bottom of the page when a pagination item is clicked.
#fullstack development, #macOS, #django, #bootstrap pagination, #code refactoring, #clipboard api, #generic class based views, #python3, #scroll behavior, #series, #tests, #unittest

How to create a fullstack application using Django and Python Part 20
Maria D. Campbell
In this section, I re-organize the accounts and boards tests content, refactor password reset-related django_boards/urls.py, fix the password reset-related accounts tests failures, add the password_change URL to templates/base.html, fix the 302 redirect-related failure in the boards.tests.test_view_reply_topic_tests, and add the reply_topic URL to templates/topic_posts.html.
#fullstack development, #macOS, #django, #django 5.1, #python3, #authentication, #code refactoring, #code restructure, #debug code, #default password reset, #fix urls, #fix redirects, #resolve, #reverse, #security, #series, #tests, #unittest

How to create a fullstack application using Django and Python Part 19
Maria D. Campbell
In this section, I implement protecting views, I configure the Login next redirect, I create @login_required tests, I update the topic posts view, create the topic_posts.html template and related tests, update the reply post (reply_topic) view and create related tests, discuss QuerySets and use them to improve the index/home view, improve the topics view, update the board_topics view, update the topics.html template, and add a new field to the Topic model.
#fullstack development, #macOS, #django, #annotate, #next, #protecting views, #python3, #queryset, #series, #tests, #unittest

How to measure test coverage in Django
Maria D. Campbell
Coverage.py is the go-to tool for measuring how much of your Django application your tests actually exercise. Here's how to install it, run it against a real project, and interpret the results.
#command line, #terminal, #fullstack development, #macOS, #django, #python3, #tests, #coverage, #coverage.py

How to create a fullstack application using Django and Python Part 18
Maria D. Campbell
In this section, I create the password_reset routes, views, tests, and templates. The results of the password reset process are output to the Terminal console. I debug the password_reset_confirm_tests tests to find out what the actual csrf token is and hard code it into the test_csrf (function) test. I re-use the Beautiful Soup 4 and Soup Sieve packages to refactor the test_form_inputs (function) test.
#fullstack development, #django, #macOS, #python3, #password reset, #security, #series, #beautifulsoup4, #html5lib, #html parser, #soupsieve, #coverage.py, #test coverage, #tests, #unittest

How to create a fullstack application using Django and Python Part 17
Maria D. Campbell
In this section, I improve signup.html template design, add a logout view and route, create a dropdown menu for logged in users, create a login.html template, url, and redirect, create a reusable template, add non-field errors to login.html, create custom template tags to use in form.html, and test the template tags.
#fullstack development, #macOS, #django, #bootstrap 5, #custom template tags, #python3, #series, #tests, #unittest

How to create a fullstack application using Django and Python Part 16
Maria D. Campbell
In this section, I demonstrate an alternative to the original test_form_inputs test in which we used the .assertContains() method to verify the existence of specific inputs residing in the signup form. I install Beautiful Soup 4 and Soup Sieve along with the html5lib HTML parser, and then re-create the test_form_inputs test using those packages. The test is much shorter, and my approach to discovering the ids of the inputs I want to grab by inspecting the signup form element in the browser is quicker and much easier to read!
#fullstack development, #macOS, #django, #beautifulsoup4, #soupsieve, #html5lib, #html parser, #python3, #series, #tests, #unittest

How to create a fullstack application using Django and Python Part 15
Maria D. Campbell
In this section, we create an accounts app where everything related to user accounts resides.
#fullstack development, #macOS, #user authentication, #django, #python3, #tests, #code modularization, #series, #unittest

How to create a fullstack application using Django and Python Part 14
Maria D. Campbell
In this section, I build a NewTopicForm.
#fullstack development, #macOS, #django, #django forms api, #bootstrap, #csrf token, #django-widget-tweaks, #python3, #response context attribute, #security, #series, #tests, #unittest

How to create a fullstack application using Django and Python Part 12
Maria D. Campbell
In this section, I add the IndexTests class to boards/tests.py, update templates/index.html to make a failed test pass, write a test for linking back to the index/home page from the single Board page, update templates/topics.html to link back to the index/home page, and update templates/topics.html so a failed test will pass.
#fullstack development, #macOS, #django, #dynamic urls, #python3, #series, #tests, #unittest

How to create a fullstack application using Django and Python Part 11
Maria D. Campbell
In this section, I update the class models in boards/models.py to include PostLike, migrate the updated models, add the dynamic path for a single board in django_boards/urls.py, create the board_topics view inside boards/views.py, create the topics.html template inside the templates directory, and create/run tests for BoardTopics.
#fullstack development, #macOS, #django, #django shortcuts, #dynamic urls, #python3, #series, #tests, #unittest

How to create a fullstack application using Django and Python Part 8
Maria D. Campbell
In this section, I add an index.html template to a directory called static, test the index (home) page, set up the static files, download Bootstrap, configure the static directory in settings.py, discuss the collectstatic command, load the Bootstrap CSS file in index.html, and edit index.html to include Bootstrap styling.
#macOS, #django, #fullstack development, #python3, #python3 shell, #bootstrap, #static, #collectstatic, #series, #tests