Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Hello Linux: Virtual Environment in Working Directory
# Virtual Environment For Prod... -
Hello Linux
<div class='alert alert-warnin... -
Git Push Local Code to Live Linux Server
<div class='alert alert-succes... -
Webinar: Deploying Django—from zero to production in 20 minutes
I held this webinar two years ago—28 February 2017. We start from zero: no server, no DNS, only a Django project in development. In 20 minutes we have a Ubuntu server running our Django project with nginx, Gunicorn and SQLite. Even if you only know Windows, you will get a good feeling of these technologies and understand why deploying on GNU/Linux is usually the most cost-effective solution. We have some fun making requests altogether in order to see whether the server can take it, and we also see whether SQLite is up to the task. Less than 30 minutes of presentation and lots of Q&A (total duration one hour). These are questions that were asked and the times in the video in which I answer Different settings for development and production environment 27m30s Managing passwords and secret keys 31m35 Is /etc/opt a standard? I have seen other locations like /usr/local/etc 36m00s The FHS isn’t entirely clear. It says you can put third-party applications in /usr/local or /opt or /srv. If you choose to put everything (program files, data files, configuration files etc.) under a single directory it should be /srv. My impression from common practices and from discussing it is … -
5 Samsung Galaxy Fold Features That Enhance Mobile Functionality
Samsung's new Galaxy Fold provides consumers with a phone and tablet in one device. Although it is a costly phone, it could eliminate your need for other expensive devices. In this way, it takes mobile phones to the next level for consumers and businesses alike. The post 5 Samsung Galaxy Fold Features That Enhance Mobile Functionality appeared first on Distillery. -
Multiple Image/File Upload with Django, Ionic 4 and FormData
In this tutorial, you'll learn to implement multiple file upload with Ionic 4, Django and FormData. In a previous tutorial, we've created a django RESTful application for uploading files using Django REST framework and Ionic 4. Since the backend code will be the same as we only need an /upload endpoint that accepts POST requests we'll simply clone the previous and start our django REST API server using the following command: $ cd ~/demos $ mkdir ionic-file-upload $ cd ionic-file-upload $ git clone https://github.com/techiediaries/django-rest-file-upload.git backend Next, create and activate a virtual environment using the following commands: $ cd backend $ python3 -m venv .env $ source .env/bin/activate Next, install the Python packages used in the project: $ pip install -r requirements.txt You can then start the development server using: $ python manage.py makemigrations $ python manage.py migrate $ python manage.py runserver Your RESTful django server will be available from the 127.0.0.1:8000 address. Here is some information about our restful server: It exposes an /upload endpoint which accepts POST requests for uploading files. It has CORS enabled so you can send requests from different doamins without getting blocked by the Same Origin Policy. Prerequisites This tutorial makes use of Ionic 4 … -
Post Multipart Form Data in Python with Requests: Flask File Upload Example
In this tutorial we'll demonstrate how to upload a file from a Python server to another server by sending a POST request with multipart/form-data using the Python requests library. We'll be using two servers. The server that receives the file doesn't need to be a Python server but since we'he previously created one with Django in this tutorial, let's use it instead of re-inventing the wheel. Note: Typically we upload files from a client to a server but in this tutorial, we'll see how we can upload files from a server to another web server using Python and the Requests library. Open a new terminal and create and activate a virtual environment: $ python3 -m venv .env $ source .env/bin/activate Next, clone the GitHub repository and install the dependencies: $ git clone https://github.com/techiediaries/django-rest-file-upload.git server2 $ cd server2 $ pip install -r requirments.txt Next, run the server using the following commands: $ python manage.py makemigrations $ python manage.py migrate $ python manage.py runserver The server will be available from the 127.0.0.1:8000 and will expose an /upload endpoint that accepts a POST request. Note: This server has also CORS enabled which means it can accept requests from different domains so make sure … -
Multiple File Image/Upload with Django, Angular 7 and FormData
In the previous tutorial we have seen how to implement file uploading in Django and Angular 7. In this tutorial, we'll see how to implement multiple file uploading. It's recommended that you start from the previous tutorial to see detailed steps of how to create a django project, how to install Angular CLI and generate a new Angular 7 project along with services and components as we won't cover those basics in this part. If you don't want to follow the steps from the previous part, you first need to get the project we've built. Open a new terminal and run the following command: $ git clone https://github.com/techiediaries/django-angular-file-upload-example.git Next, navigate inside the project's folder and install the npm dependencies using the following command: $ cd django-angular-file-upload-example $ npm install Next, start the development server using: $ ng serve Your Angular application will be available from the 127.0.0.1:4200 address. Open a new terminal window and create a virtual environment using the following command: $ python3 -m venv .env Next, activate the virtual environment using: $ source .env/bin/activate Next, navigate to the backend project and install the Python packages using: $ cd django-angular-file-upload-example/backend $ pip install -r requirements.txt Finally, start the development … -
Django REST Framework Image File Upload Tutorial & Example [FormData & Angular 7 UI]
Throughout this tutorial, we'll see how you can implement file upload in Django and Django REST Framework with a step by step example. Our application will expose an /upload endpoint that accepts POST requests that contain the file posted with a multipart/form-data content type using FormData. For the frontend, we'll be using Angular 7 to create a simple interface that allows the user to select a file and upload it to the server via a POST request and FormData. These tutorials is divided in two parts: In the first part we'll create the Django application and make a REST API client to make sure it properly work. In the second part, we'll proceed to create a frontend with Angular 7. Let's get started! Prerequisites For this tutorial, you will need to have a few prerequisites such as: Python and pip installed on your system. We'll be using Python 3.7, Familiarity with Python and Django. Node.js and NPM installed on your system. These are required by Angular CLI. Familiarity with TypeScript. Creating a Virtual Environment & Installing Django If you have Python and pip installed on your system, let's get started by creating a new virtual environment for our project's dependencies. … -
Why We Love Wagtail (and You Should, Too)
New clients regularly ask us if we build WordPress sites. When we dig deeper, we generally learn that they’re looking for a user-friendly content management system (CMS) that will allow them to effortlessly publish and curate their site content. As we’ve written about previously, WordPress can be a good fit for simple sites. However, the majority of our clients need a more robust technical solution with customizable content management tools. For the Python-driven web applications that we develop, we love to work with Wagtail. What is Wagtail? Wagtail is a Python-driven CMS built on the Django web framework. It has all the features you’d expect from a quality CMS: intuitive navigation and architecture user-friendly content editing tools painless image uploading and editing capabilities straightforward and rapid installation What Makes Wagtail Different? From the user’s perspective, Wagtail’s content editor is what sets it apart, and it’s why we really love it. Most content management systems use a single WYSIWYG (“what you see is what you get”) HTML editor for page content. While Wagtail includes a WYSIWYG editor — the RichTextField — it also has the Streamfield, which provides an interface that allows you to create and intermix custom content modules, each … -
Why We Love Wagtail (and You Will, Too)
New clients regularly ask us if we build WordPress sites. When we dig deeper, we generally learn that they’re looking for a user-friendly content management system (CMS) that will allow them to effortlessly publish and curate their site content. As we’ve written about previously, WordPress can be a good fit for simple sites. However, the majority of our clients need a more robust technical solution with customizable content management tools. For the Python-driven web applications that we develop, we love to work with Wagtail. -
DjangoChat Podcast
Launching a new podcast with Carlton Gibson focused on Django. -
The Benefits of Design Systems: Cutting Costs and Creating Competitive Advantage
A design system is far more than a UI kit. A design system is a continuously evolving single source of truth that establishes rules of visual narration and interaction. It must be comprehensive, combining components, behaviors, and branding. The post The Benefits of Design Systems: Cutting Costs and Creating Competitive Advantage appeared first on Distillery. -
My involvement in the Python community
An article about me and my involvement in the Python community (mainly Django) as a Free Software developer, GNU/Linux user and tech conference speaker. -
My involvement in the Python community
An article about me and my involvement in the Python community (mainly Django) as a Free Software developer, GNU/Linux user and tech conference speaker. -
Django: Recommended Reading
Pictured: Our library of reference books at Caktus cover topics including Django and Python, as well as project management and Agile methodologies. At Caktus, we believe in continued learning (and teaching). It's important to read up on the latest industry trends and technologies to stay current in order to address our clients' challenges. We even maintain a library in our office for staff use, and we add references frequently. Our team enjoys sharing what they've learned by contributing to online resources, such as the Django Documentation and the Mozilla Developer Network Web Docs. Below is a list (in alphabetical order) of the books, blogs, and other documents that we’ve found to be the most accurate, helpful, and practical for Django development. Django Documentation Authors: Various Recommended by Developer Dmitriy Chukhin Overview: When Dmitriy first began learning about Django, he went through the official Django tutorial. Then, as a developer, he read through other pieces of documentation that are relevant to his work. A Valuable Lesson: Dmitriy learned that detailed documentation makes working with a framework significantly easier than trying to figure it out on his own or from other developers’ posts about their errors. The documentation is readable, uses understandable … -
Django: Recommended Reading
Pictured: Our library of reference books at Caktus cover topics including Django and Python, as well as project management and Agile methodologies. -
Django Tips & Tricks #12 - Automatically Set CSRF Token in Postman
Introduction Django has inbuilt CSRF protection mechanism for requests via unsafe methods to prevent Cross Site Request Forgeries. When CSRF protection is enabled on AJAX POST methods, X-CSRFToken header should be sent in the request. Postman is one of the widely used tool for testing APIs. In this article, we will see how to set csrf token and update it automatically in Postman. CSRF Token In Postman Django sets csrftoken cookie on login. After logging in, we can see the csrf token from cookies in the Postman. We can grab this token and set it in headers manually. But this token has to be manually changed when it expires. This process becomes tedious to do it on an expiration basis. Instead, we can use Postman scripting feature to extract token from cookie and set it to an environment variable. In Test section of postman, add these lines. var xsrfCookie = postman.getResponseCookie("csrftoken"); postman.setEnvironmentVariable('csrftoken', xsrfCookie.value); This extracts csrf token and sets it to an evironment variable called csrftoken in the current environment. Now in our requests, we can use this variable to set the header. When the token expires, we just need to login again and csrf token gets updated automatically. Conclusion … -
Django Tips & Tricks #12 - Automatically Set CSRF Token in Postman
Introduction Django has inbuilt CSRF protection mechanism for requests via unsafe methods to prevent Cross Site Request Forgeries. When CSRF protection is enabled on AJAX POST methods, X-CSRFToken header should be sent in the request. Postman is one of the widely used tool for testing APIs. In this article, we will see how to set csrf token and update it automatically in Postman. CSRF Token In Postman Django sets csrftoken cookie on login. After logging in, we can see the csrf token from cookies in the Postman. We can grab this token and set it in headers manually. But this token has to be manually changed when it expires. This process becomes tedious to do it on an expiration basis. Instead, we can use Postman scripting feature to extract token from cookie and set it to an environment variable. In Test section of postman, add these lines. var xsrfCookie = postman.getResponseCookie("csrftoken"); postman.setEnvironmentVariable('csrftoken', xsrfCookie.value); This extracts csrf token and sets it to an evironment variable called csrftoken in the current environment. Now in our requests, we can use this variable to set the header. When the token expires, we just need to login again and csrf token gets updated automatically. Conclusion … -
How 5G Network Development Will Go Global In 2019
The next generation of mobile internet connection is just around the corner. Carriers, manufacturers, vendors and companies are preparing for the introduction of 5G. If you don’t know what is 5G already, it is the 5th generation of mobile networking technology that promises to bring even faster and more reliable wireless connections across the globe. With testing and small market launches already in progress, we expect to see rapid adoption of the 5G network in 2019. Here are the anticipated 5G network developments coming up in the next year. The post How 5G Network Development Will Go Global In 2019 appeared first on Distillery. -
Sorry I seemed to have missed this!
Sorry I seemed to have missed this! The @next label is used for anything that doesnt have a due date, but can be worked on anytime. That way my filters have a list of things that are due that day (@waiting-for & today) as well as items I can start working on anytime (@next) -
You are right, if I mentioned @wait-for I meant @waiting-for, Ill look over the article and see if…
You are right, if I mentioned @wait-for I meant @waiting-for, Ill look over the article and see if I can fix that issue.The @next label is used for anything that doesnt have a due date, but can be worked on anytime. That way my filters have a list of things that are due that day (@waiting-for & today) as well as items I can start working on anytime (@next) -
Django ORM optimization story on selecting the least possible
This an optimization story that should not surprise anyone using the Django ORM. But I thought I'd share because I have numbers now! The origin of this came from a real requirement. For a given parent model, I'd like to extract the value of the name column of all its child models, and the turn all these name strings into 1 MD5 checksum string. Variants The first attempted looked like this: artist = Artist.objects.get(name="Bad Religion") names = [] for song in Song.objects.filter(artist=artist): names.append(song.name) return hashlib.md5("".join(names).encode("utf-8")).hexdigest() The SQL used to generate this is as follows: SELECT "main_song"."id", "main_song"."artist_id", "main_song"."name", "main_song"."text", "main_song"."language", "main_song"."key_phrases", "main_song"."popularity", "main_song"."text_length", "main_song"."metadata", "main_song"."created", "main_song"."modified", "main_song"."has_lastfm_listeners", "main_song"."has_spotify_popularity" FROM "main_song" WHERE "main_song"."artist_id" = 22729; Clearly, I don't need anything but just the name column, version 2: artist = Artist.objects.get(name="Bad Religion") names = [] for song in Song.objects.filter(artist=artist).only("name"): names.append(song.name) return hashlib.md5("".join(names).encode("utf-8")).hexdigest() Now, the SQL used is: SELECT "main_song"."id", "main_song"."name" FROM "main_song" WHERE "main_song"."artist_id" = 22729; But still, since I don't really need instances of model class Song I can use the .values() method which gives back a list of dictionaries. This is version 3: names = [] for song in Song.objects.filter(artist=a).values("name"): names.append(song["name"]) return hashlib.md5("".join(names).encode("utf-8")).hexdigest() This time Django figures it doesn't even … -
Adding custom filters to Django admin is easy!
I'm building a backend for a scraping tool that has two simple models Website and Page, where Website can have many pages. In a simplified form it looks like: class Website(models.Model): url = models.URLField(unique=True) class Page(models.Model): website = models.ForeignKey( 'Website', on_delete=models.CASCADE ... Read now -
Guide to Ansible/NGINX/uWSGI/Django, Part 2: Getting uWSGI Working with NGINX and Django
In Part 1 of this post, I described the trials, tribulations and ultimate success of running Ansible to provision a cloud server, which we do often here at Imaginary Landscape. Part 2 concludes the post by describing the process for getting uWSGI working with NGINX and Django. When I first tested the deployed website after doing the provisioning with Ansible, it failed with a not-very-descriptive "bad gateway" error. Luckily, uWSGI's own documentation provides an excellent tutorial on how to configure uWSGI, NGINX, and Django. Given the average quality of documentation one usually finds online, it's almost shocking how clear and thorough this tutorial is. It shows you step-by-step how to test each component until you get your Django app working with uWSGI and NGINX. It's great. The only downside is that because the tutorial is so thorough and because it assumes that you are setting up uWSGI, NGINX and Django from scratch (i.e., not with an Ansible script), working through it takes time. Nevertheless, when all three of those tools are in play, tracking down the cause of errors can be very difficult. Stripping the system down and checking each component in isolation, as the tutorial describes, might still be the best way forward. …