[Fixed]-Django- how to copy elements from one view to another?

1πŸ‘

The problem you describe – duplicated code – is one of many common problems addressed by refactoring. The refactoring action to apply here is called Extract Method.

For shared code, extract the common code to a separate function and call that function from all the different places that need it.

For shared template content, extract the common content to a separate template file and {% include … %} that template from all the different places that need it.

πŸ‘€bignose

Leave a comment