The Dangers of Copy-Pasting Code: My Debugging Story

Image for post
Image for post
The workflow of a typical dev — search Stack Overflow for the answer…

Copying en masse

In my application, I wanted to implement basic user registration and sign-in, but enable customization of the forms and add email activation on registration.

Django NoReverseMatch: Reverse for ‘password_reset_confirm’ — my bug from hell

Unfortunately, I was copying from multiple sources, and eventually those sources conflicted to produce a bug:

Image for post
Image for post

Google can’t solve everything

Of course, I turned to Google to find an answer. Maybe somebody had experienced this exact issue on Stack Overflow?

Go back to basics

As I attempted to debug, I realized I didn’t exactly know what the error even meant or what was producing it.

Build a tiny test

I originally assumed my issue was with the way Django received parameters or routed the request.

Shifting focus

When debugging, ruling out possible causes is the best way to get to the root of an issue.

I found it!

As with most bugs, mine came from a single line.

<form method="post" action="{% url 'password_reset_confirm' %}">
<form method="post">

That bug was an opportunity

I realized that my copy-pasting spree led to a lot of other issues in my code.

Lessons learned

Online resources are amazing — and copy-pasting can be incredibly effective when coding. Don’t get me wrong!

About Bennett

I’m a software developer in New York City. I do web stuff in Python and JavaScript.

Top writer in Technology | Backend Web Developer | bennettgarner.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store