Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
How to Create a Fancy Range-Slider Filter in Django
Introduction In this tutorial, we are going to create a nice crispy range slider using django-crispy-forms for an integer filter provided by django-filters. The tutorial can be split into four sections. In the first or prerequisite section, we will i... -
Fluent in Django: Improving your application
This is the second part of Fluent in Django series. We're going to upgrade the code we created in Part 1. You can find the finished code from the first part here. Prerequisites Python Basics of Django (Creating a project, Model, View, Templates, Fo... -
Django Architecture
Ok you have decided to create your website using Django as the backend and so it will be a smart move to know how Django actually do the work underground when requests are being sent to it from the front end. Django is said to be made of three layers... -
Embrace the Grind
Sometimes, programming feels like magic: you chant some arcane incantation and a fleet of robots do your bidding. But sometimes, magic is mundane. If you’re willing to embrace the grind, you pull off the impossible. -
HTML Over WebSockets
This article looks at a new approach for achieving a Single-page Application (SPA) -- HTML over WebSockets. -
Django Admin tip: Auto-generated slug content
<![CDATA[ Django Admin tip: Auto-generated slug content In this post I want to share super quick tip that can help you a lot, assuming you use Django Admin and at least some slug fields. Slugs are these human readable parts of an URL, that also let you identify a piece of content. For example this URL: https://nemecek.be/blog/79/working-with-django-imagefield. The last part is a slug based on the post title "Working with Django ImageField". The motivation for slugs is that URLs cannot contain spaces (among other characters) so we use process which is called "slugify" to turn a piece of text into valid slug. Django offers a SlugField which will automatically validate its input to allow only slugs and you can use these as part of the URL. And now we can finally move to the tip. Django ModelAdmin has setting called prepopulated_fields which is mainly there for automatic slug creation. We can use an example from the official docs: class ArticleAdmin(admin.ModelAdmin): prepopulated_fields = {"slug": ("title",)} This will monitor the value of title input and automatically create slugified version with the help of JavaScript. Django also makes sure to not automatically update this slug later on, because you probably don't want your … -
Django at a glance 😋
Welcome developer, in this tutorial we are going to look into what Django web framework is at a glance. By the end of this tutorial you should be comfortable with the following Websites and Webpages Web frameworks and Type of web frameworks Djang... -
What is Werkzeug?
This article explains what Werkzeug is and how Flask uses it for its core HTTP functionality. -
Django 3.2 - News on compressed fixtures and fixtures compression
In the Django 3.2 version just released I contributed with new features related to compressed fixtures and fixtures compression. In this article I have explored into the topic and produced some sample benchmarks. -
Django 3.2 - News on compressed fixtures and fixtures compression
In the Django 3.2 version just released I contributed with new features related to compressed fixtures and fixtures compression. In this article I have explored the topic and produced some sample benchmarks. -
Guest Post: Django Crispy Forms Advanced Usage Example
This is a guest post by Serhii Kushchenko, Python/Django developer and data analyst. He is skillful in SQL, Python, Django, RESTful APIs, statistics, and machine learning. This post aims to demonstrate the creation and processing of the large and complex form in Django using django-crispy-forms. The form contains several buttons that require executing different actions during the processing phase. Also, in the form, the number of rows and columns is not static but varies depending on some conditions. In our case, the set of rows and columns changes depending on the number of instances (columns) associated with the main object (data schema) in a many-to-one relationship. The django-crispy-forms documentation includes a page Updating layouts on the go. That page is quite helpful. However, it does not contain any detailed example of a working project. IMHO such an example is much needed. I hope my project serves as a helpful addition to the official Django Crispy Forms documentation. Feel free to copy-paste the pieces of code that you find applicable. Please see the full codebase here. It is ready for Heroku deployment. Task Suppose we have a database with information about people: name, surname, phone numbers, place of work, companies owned, … -
FYP-DevLog-004
Progress Highlights Finalised Table of Comparison on Related Works on Detecting Mental Health on Bilingual Twitter Posts with supervisor (the most stressful task of this week since my supervisor demands more information to be included) Attended se... -
Python, Django, and React Development on Apple Silicon
Last year, Apple announced that they would transition their entire Mac line from Intel processors to their ARM64 Apple Silicon chip called the M1. Several weeks ago, I started testing development on MacBook Air with the Apple M1 chip (pictured above). Is development possible on the M1? Yes. Is it easy and straightforward? Not always, but if you can live with a few workarounds, you can make it work. While many software packages now natively support Apple Silicon (see Does it ARM?), the development space is still in the process of rolling out support, like Docker. This post will likely age quite quickly! Many software packages have received Apple Silicon-related updates over the past few weeks. My Development Environment At a high level, I'm currently running the following on the M1: Python and Django (Homebrew and Xcode) JavaScript and React (Homebrew and nvm) PostgreSQL (Homebrew) Docker (Apple M1 Tech Preview) Visual Studio Code (Insiders) Other packages are used to help achieve this development environment, from iTerm2 to direnv, so M1 support looks good here. The areas I'm still having issues with or haven't had time to dig into yet are: Python 3.7 under Rosetta 2 Building and running certain Docker … -
Django News - Get PyCharm, Support Django, Django 3.2 release is soon - Apr 2nd 2021
News Get PyCharm, Support Django Until April 29, you can purchase PyCharm at 30% off and the full purchase price will be donated to the Django Software Foundation. jetbrains.com Django 3.2 release and security releases for 3.1.8, 3.0.14, and 2.2.20 On April 6th, Django 3.2 is scheduled to be released along with new security releases for 3.1.8, 3.0.14, and 2.2.20. djangoproject.com PyCon US Schedule Posted! Head over to the PyCon website to see the lineup for Tutorials, Talks, Charlas, Summits and Sponsor Workshops. blogspot.com Events DjangoCongress JP 2021 運営ミーティング5月 - connpass connpass.com Sponsored Link Django Full-text Search with Postgres and Elasticsearch Learn how to leverage the native search capabilities offered by Postgres to add full text-search to Django. Use React, Docker, and Cypress to create a full-stack application with Test-driven Development. Swap out Postgres with Elasticsearch to provide comparable functionality. testdriven.io Articles The Python Handbook From FreeCodeCamp, a very detailed introduction to Python and its functions intended for newcomers. freecodecamp.org In Pursuit of PostgreSQL Performance by Ken Whitesell Or: How someone who doesn’t really know what they’re doing manages to improve the performance of lengthy queries. dev.to Shooting yourself in a foot with Django and recovering from it A great … -
Django User Profile - Learn to code in Django - Themesberg Blog
This article explains how to code a Django User Profile available for authenticated users outside of the admin module. The content might help beginners to learn new things about Django and code a real project with commercial value. For newcomers, Dja... -
Django modify_settings and receivers
Sometimes, tests expose weird behaviour. In this instance, I have a `Makefile` command that calls a `cookiecutter` command to create a new integration with a payroll system. We'd noticed that over time, this infrequntly used code had become slightly less than perfect. So, I wrote a test that runs this code. Not directly using the `make new-payroll-system` command, but rather using a test case from within Django. This worked great in development. I was able to have code that was generated, some tests on that code were run (including generating migrations for the new app), and then the code was removed. {% highlight python %} def test_cookie_cutter(self): from cookiecutter.main import cookiecutter try: cookiecutter( 'integrations/__template__', extra_context={'system_name': 'new_thing'}, output_dir='integrations/systems', no_input=True, ) with modify_settings(INSTALLED_APPS={'append': 'integrations.systems.new_thing'}): call_command('makemigrations', 'new_thing', no_input=True, verbosity=0) finally: shutil.rmtree('integrations/systems/new_thing') {% endhighlight %} But this failed in CI. Turns out that our Codeship-based testing infrastructure doesn't allow for writing the files in the expected location. Never mind, we can use `tempfile.TemporaryDirectory()` instead. That will handle the cleanup for us, which is better than removing files ourselves: {% highlight python %} def test_cookie_cutter(self): from cookiecutter.main import cookiecutter with tempfile.TemporaryDirectory() as dirname: # Put our new temporary directory on the PYTHONPATH. sys.path.insert(0, dirname) cookiecutter( … -
Django modify_settings and receivers
Sometimes, tests expose weird behaviour. In this instance, I have a `Makefile` command that calls a `cookiecutter` command to create a new integration with a payroll system. We'd noticed that over time, this infrequntly used code had become slightly less than perfect. So, I wrote a test that runs this code. Not directly using the `make new-payroll-system` command, but rather using a test case from within Django. This worked great in development. I was able to have code that was generated, some tests on that code were run (including generating migrations for the new app), and then the code was removed. {% highlight python %} def test_cookie_cutter(self): from cookiecutter.main import cookiecutter try: cookiecutter( 'integrations/__template__', extra_context={'system_name': 'new_thing'}, output_dir='integrations/systems', no_input=True, ) with modify_settings(INSTALLED_APPS={'append': 'integrations.systems.new_thing'}): call_command('makemigrations', 'new_thing', no_input=True, verbosity=0) finally: shutil.rmtree('integrations/systems/new_thing') {% endhighlight %} But this failed in CI. Turns out that our Codeship-based testing infrastructure doesn't allow for writing the files in the expected location. Never mind, we can use `tempfile.TemporaryDirectory()` instead. That will handle the cleanup for us, which is better than removing files ourselves: {% highlight python %} def test_cookie_cutter(self): from cookiecutter.main import cookiecutter with tempfile.TemporaryDirectory() as dirname: # Put our new temporary directory on the PYTHONPATH. sys.path.insert(0, dirname) cookiecutter( … -
PyCharm - Paul Everett & Aleksei Kniazev
PyCharmPyCharm Issue TrackerDjangoProject.comSupport the ShowThis podcast is a labor of love and does not have any ads or sponsors. To support the show, please consider recommending a book from LearnDjango.com, signing up for the free weekly Django News newsletter, or learning more about Button, a simpler deployment story for Django. -
Why use Django for complex WebApps?
Django - A great framework ? Django is a high-level Python web framework that enables the rapid development of secure and maintainable websites. Built by experienced developers, Django takes care of much of the hassle of web development, so you can f... -
Rapid Prototyping with Django, htmx, and Tailwind CSS
This tutorial looks at how to add htmx and Tailwind CSS to Django to reduce the amount of time it takes to create and style an interactive front-end. -
How to upload images in Django without 504 Gateway Timeout
Have you ever tried uploading images in Django and encountered 504 Gateway Timeout? Then this blog is for you. What we will implement in this tutorial is an image uploader in Django with crop option. The upload is done asynchronously using AJAX funct... -
Adapting Interview Questions for Junior Candidates
Sébastien asks: “Would you say that your questions are equally applicable to junior and senior positions?” -
Setup PyCharm to use a Django project in docker
To be sure every developer work with the same controlled development environment, more and more teams use docker. That way every developer will work on the same environment, regardless of their operating system. Using docker as a development environm... -
Weeknotes (2021 week 12)
Weeknotes (2021 week 12) Not much open source work this week. The final thesis and presentation for the CAS in Interaction Design was due. I learned a lot but for now I’m just glad that it’s over. I’m looking forward to relearning how to do “nothing” on weekends. FeinCMS 1.20 Some FeinCMS 1.x ItemEditor element attributes clashed with new IDs introduced in Django 3.1. The new version of FeinCMS fixes this. feincms3 Fixed a few problems in the new inline CKEditor widget for the Django admin. An oversight made it impossible to add CKEditor instances with different configurations. Luckily enough this only affected beta/preview releases :-) -
“Fair” Doesn't Mean “Equal”
Some conversations about my previous piece brought me back to one of the earliest lessons I learned in my management career. It’s a realization that’s embarrassingly obvious in hindsight: treating people fairly doesn’t mean treating everyone the same.