DEV Community

Cover image for Fast Forms With UpdateView - Building SaaS #44
Matt Layman
Matt Layman

Posted on • Originally published at mattlayman.com

1 1

Fast Forms With UpdateView - Building SaaS #44

In this episode, we worked on an edit view. We used Django's generic UpdateView to aid the process and test drove the creation of the view to verify things every step of the way.

We worked on a view to make it possible to edit the CourseTask model that are the actions that a student must complete for a course.

To complete the form quickly, I took advantage of Django's ModelForm views. These views are designed to make forms rapidly from existing models.

The first thing I did was create a test that would try to edit a course task from the URL where the task can be edited. The first test was a GET request to make sure that we can render a form for the given task.

We took a break to chat about other frameworks and philosophies around those choices.

On the new view, I used get_queryset to filter to the tasks associated with the user's school. To connect the view to the view's URL uuid parameter, we had to set slug_field and slug_url_kwarg to uuid. Finally, I set the fields that we want to edit on the model record.

After that was done, the view required the creation of a courses/coursetask_form.html template. We created an empty file and the initial test passed!

With the happy test done, I added more tests to check the other constraints that the view needs to have.

Before jumping into the template of the form, I modified the daily view that is supposed to link to this view to do the proper linking.

To finish the stream, I spent a bit of time adding initial styles and structure to the form view templates.

This article first appeared on mattlayman.com.

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay