tag: unittest

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

Creating the official Django Polls app Part 5
Maria D. Campbell
This is the fifth installment in a series called Creating the official Django Polls app. Continue following this series with this fifth part. I walk through test-driven development in Django, finding and fixing a real bug in Question.recently_published(), and then build out view tests for the polls index and detail pages.
#fullstack development, #macOS, #fixing bugs, #identifying bugs, #series, #test client, #testing strategies, #tutorial, #unittest

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 and then fix them after submitting them for code review. In the process, I realize how important code reviews are and that I can't develop applications in a bubble.
#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 my Markdown, and add code formatting and highlighting to my Markdown. I create tests for the ProfileListView, protect the function-based profile view, and profile_detail view. I update accounts/tests/test_form_signup_test.py, fix the topic posts avatar issue, and explain the extended profile functionality.
#fullstack development, #macOS, #bootstrap, #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, and associated urls and templates. I also create the PostUpdateView, PostDeleteView, and PostDetailView tests, and debug the code and tests. Lastly, I 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, and add pagination to the associated templates. I 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 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, #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 and create related tests, and I discuss QuerySets and use them to improve the index/home view.
#fullstack development, #macOS, #django, #annotate, #login redirect, #protecting views, #python3, #queryset, #series, #tests, #unittest

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, #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 I 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 14
Maria D. Campbell
In this section, I build a NewTopicForm, view, and route. I also add NewTopicTests to boards/tests.py.
#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 would 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