Urgent.News

What's breaking now, across hundreds of outlets.

Tech

5 Django Mistakes Beginners Make Again and Again (and How to Fix Them)

Hi DEV! 👋 I'm Mehedi Alam, a Python & Django developer and trainer from Bangladesh. I teach Python, Django, and MySQL to batches of 24+ trainees, and I help them build job-ready portfolio projects. When you teach the same framework many times, you start noticing the same stumbling blocks. This post covers five of the most common Django mistakes beginners make, why they matter, and a simple fix…

In this aggregator brief, we cover five common Django mistakes that beginners often make and how to fix them. The first mistake is skipping virtual environments, which can lead to conflicts between projects with different Django versions. The recommended fix is to create an isolated environment for each project and record dependencies using pip freeze to create a requirements.txt file.

The second mistake is committing secrets and leaving DEBUG = True in the settings.py file, which can expose sensitive information and pose security risks. The fix involves using environment variables for sensitive values and keeping local values in a .env file, which should be added to .gitignore. The third mistake is "fixing" migration errors by deleting the database and migrations folders, which can destroy data and break teammates' databases.

The fix is to follow the basic migration workflow of running makemigrations, migrate, and showmigrations in that order, and commit migration files to Git. Lastly, beginners often hit the database inside loops, causing the N+1 problem, where multiple queries are made for each object in a loop. The fix is to use Django's built-in methods for retrieving related objects, such as select_related or prefetch_related, to reduce the number of queries and improve performance.

Brief written by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Adding LocalBusiness Schema (JSON-LD) to the Corporate Website: A Step-by-Step Guide

One of the most frequently overlooked tasks after a business website goes live is structured data. Google tries to extract what you are talking about on your page from the text; with JSON-LD, you tell…

  • "ProfessionalService" şeması tercih edilir, özel bir altyapı için değiştirilebilir
  • JSON-LD şeması sayfanın head bölümünde ya da sonunda yer alır
  • Şemada NAP bilgilerinin tüm sayfada ve dizin kayıtlarında uyumlu olduğundan emin olun

China Telecom Open-Sourced a 285B Model. No Nvidia Inside

China Telecom Open-Sourced a 285B Model. No Nvidia Inside China Telecom open-sourced the weights of Xing4.1-Preview today, and the headline number is the least interesting part.

  • China Telecom open-sources 285B-parameter Xing4.1-Preview model
  • Model runs on Huawei Ascend 910C chips, uses MindSpore framework
  • Released under Apache 2.0, no commercial-use thresholds

Why Every Small Business Website Should Be Fast, Simple, And Mobile-First

Every small business today needs a website. But having a website is not enough. If the website is slow, confusing, or does not work well on mobile, people will leave in a few seconds.

  • Speed is critical; pages over 3 seconds lose visitors
  • Simplicity matters; answer key questions within 5 seconds
  • Mobile-first design essential for modern users

What's New in Imazeo: Website Screenshots, Document Previews, and Dynamic QR Codes

A web application can end up needing a surprising number of media features. Product thumbnails, PDF previews, screenshots of public pages, images of presentation slides, QR codes on printed…

  • Imazeo adds website screenshot tool with four capture modes.
  • Office documents convert to image previews in PNG/JPEG/WebP.
  • Dynamic QR codes enable changing destinations without new images.

More from Monday 23 November →