Django has a lot of other big features like a URL router that can parse incoming requests and build new URLs from a router schema. As a whole, the Django framework is a pleasant experience and whenever you need help, just read the documentation.
Mistake #1: Using the Global System Python Environment for Project Dependencies
If you ask me, I prefer the
virtualenvPython package and Docker containers for project dependency isolation and management.
Mistake #2: Not Pinning Project Dependencies in a requirements.txt File
To be extra cautious, it’s a nice idea to back up your dependency source files too! Keep a copy in your file system, a Git-managed folder, S3 folder, FTP, SFTP—wherever, but have it on hand. There have been instances where a relatively minor package being unlisted broke a large number of packages on
npm. Pip helpfully provides the tool for downloading all required dependencies as source files, read more by running .
pip help download
Mistake #3: Using Old-style Python Functions Instead of Class-based Views
I built the package named Django Template Names, which standardizes template names for your views based on an application name and a view class name. I use it every day and it saves a lot of my time for inventing names. Simply put the mixin in your CBV—
class Detail(TemplateNames, DetailView):—and it will begin working! Of course, you can override my functions and add mobile responsive templates, different templates for user-agents, or anything else you want.
Mistake #4: Writing Fat Views and Skinny Models
Mistake #5: A Huge, Unmanageable Settings File
Check out the minimal configuration example:
Mistake #6: All-in-one Application, Bad Application Structure, and Incorrect Resource Placement
Here is example structure for a portal application which has a lot of resources and Python modules.
You’ll end up with a project structure like this:
Mistake #7: STATICFILES_DIRS and STATIC_ROOT Confuse Newbie Django Developers
Don’t forget to
run in your production environment!
Mistake #8: Default STATICFILES_STORAGE, Django Template Loaders in Production
Cached Django Template LoaderCheck out
python manage.py startapp
Mistake #9: Pure Python Scripts for Utilities or Scripts
Also, check out the Django Extensions package, which is a collection of custom extensions for Django. Maybe someone has already implemented your commands! There are already a lot a lot of common task commands.
Mistake #10: Reinventing the Wheel
It’s a ready-to-use Django Skeleton for your next project from scratch and will, hopefully, save you a lot of time by bootstrapping your project. Webpack has minimal basic configuration, but it also has SASS installed pre-configured to handle
Share your perspective
Share your achievement or new finding or bring a new tech idea to life. Your IT community is waiting!