Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
django-debreach + DRF = sadness
I sunk 4 hours of my life into this problem yesterday so I thought I might post it here for future frustrated nerds like myself. If you're using django-debreach and Django REST Framework, you're going to run into all kinds of headaches regarding CSRF. DRF will complain with CSRF Failed: CSRF token missing or incorrect. and if you're like me, you'll be pretty confused since I knew there was nothing wrong with the request. My token was being sent, but it appeared longer than it should be. So here's what was happening and how I fixed it. Hopefully it'll be useful to others. Django-debreach encrypts the csrf token, which is normally just fine because it does so as part of the chain of middleware layers in every request. However, DRF doesn't respect the csrf portion of that chain. Instead it sets csrf_exempt() on all of its views and then relies on SessionAuthentication to explicitly call CSRFCheck().process_view(). Normally this is ok, but with a not-yet-decrypted csrf token, this process will always fail. So to fix it all, I had to implement my own authentication class and use that in all of my views. Basically all this does is override SessionAuthentication's enforce_csrf() … -
Build GraphQL Web APIs with Django Graphene
On the previous tutorial we have introduced GraphQL to build Web APIs .In this tutorial we are going to build a real world example web application with Django ,which makes use of GraphQL and its Python implementation ,Graphene . Tutorial Parts : Building Better Django WEB APIs with GraphQL Tutorial Build GraphQL Web APIs with Django Graphene Lets start by creating a new virtual environment and install required packages including django , Head over to your terminal and enter : virtualenv graphqlenv source graphqlenv/bin/activate This will create a new virtual environment and activate it . Next install django and graphene packages with pip pip install django pip install graphene_django You can also install graphiql_django which provides a user interface for testing GraphQL queries against your server . pip install graphiql_django Next lets create a Django project with a single application : python django-admin.py startproject inventory . cd inventory python manage.py startapp inventory Open settings.py and add inventory and graphenedjango to installedapps array : INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'graphene_django', 'inventory' ] Then create your database : python manage.py migrate Create models Open inventory/models.py then add : # -*- coding: utf-8 -*- from __future__ import unicode_literals from … -
Build GraphQL Web APIs with Django Graphene
In this tutorial part we will see a real world example of how to build a GraphQL API with Django Graphene -
Setup Git & A Github Repo
Git is a version control syste... -
Our Tech
This is what drives our busine... -
Building Better Django WEB APIs with GraphQL : Tutorial Part 1
GraphQL is a new technology of building APIs created and open sourced ,in February 2015 ,by Facebook so how does it differ from the old way of building HTTP Rest APIs ? GraphQL allows you to query your server for the exact data that you want ,no less no more ,sending just one request even for multiple related models . So the first difference ,when using the classic Rest APIs ,in many situations you either get less data ,in this case you will need to send more requests to retrieve all data you need ,or you get more data than what you actually need ,which consumes your server and your network resources . The second difference ,when requesting some model data from a Rest endpoint ,if you need the related models data you usually end up with more requests to multiple endpoints . Thanks to GraphQL ,the client can describe and define exactly the requested data in a JSON format and the server takes care of sending the data in the same format . Lets take a simple example to understand how GraphQL works . Suppose we have a Django web application with two models ,products and families : class … -
How To Exclude node_modules Directory When Running collectstatic Command in Django
If you use npm or yarn to install frontend packages inside your Django project, you may notice, that when you run python manage.py collectstatic command, it ends up collecting huge amounts of files. That's because by default, collectstatic grabs all content of static directories inside the project, including thousands of ... Read now -
django-cabinet – A media library for Django
django-cabinet – A media library for Django django-cabinet is a media library for Django implemented while trying to write as little code as possible to keep maintenance at a minimum. At the time of writing the projects consists of less than 1000 lines of code (excluding tests), but still offers hierarchical folders, downloads, images with primary point of interest (courtesy of django-versatileimagefield) and drag-drop uploading of files directly into the folder view. You’ll find more details and screenshots at Github and Read the Docs. -
Django Kullanıcıları Yasaklama – DjangoBan
Django’da kayıtlı kullanıcıları yasaklamak için DjangoBan paketini kullanabiliriz. Uyumluluk Django 1.9+ Python 3.x + Kurulum pip install DjangoBan Ayarlar Django settings.py girip, INSTALLED_APPS bölümüden ban app’ını ekleyin. #settings.py INSTALLED_APPS = [ ... 'ban', ] Django settings.py girip Middleware bölümüne ban.middleware.BanManagement katmanını ekleyin. MIDDLEWARE = [ ... 'ban.middleware.BanManagement', ] Database İşlemleri python manage.py makemigrations python manage.py migrate Örnek Banlanmış Kullanıcı Kullanımı Admin panel üzerinden, basit şekilde kullanıcıyı yasaklayabilirsiniz. Django Ban – Template Template sayfasını özelleştirmek için, uygulamanızının templates klasörüne “ban.html” oluşturup değişiklik yapar iseniz o değişiklik yansıyacaktır. -
Making a Rails App Move Faster: A Tale of Lessons Learned
my experience, most performance improvement tasks take the following form: “This request is working too slow. We have to make it faster.” Sound familiar? In general, to find and remove all mistakes and nonsense parts in the program code, the request itself and all related actions must be thoroughly examined. On this occasion, however, we had to come up with a completely different approach. The post Making a Rails App Move Faster: A Tale of Lessons Learned appeared first on Distillery. -
Create First Project and Start Development Server
Now that we have installed required development tools including Django framework ,it's time for the first real step to start building our real estate app while learning Django essentials from scratch . Django framework includes a bunch of very useful utilities to create and manage projects that can be accessed from a Python file called django-admin.py that becomes available when we first installed Django . In this section we are going to see how to : Create a new project Setup and create the project database Start the development server Create a new Django project Creating a new Django project is easy and quick so open your terminal or command prompt then enter : $ django-admin.py startproject django_realestate This command will take care of creating a bunch of necessary files for the project . Executing the tree command in the root of our created project will show us the files that were created . . ├── django_realestate │ ├── __init__.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py └── manage.py init is the just the Python way to mark the containing folder as a Python package which means a Django project is a Python package . settings.py is the … -
Create First Project and Start Development Server
Now that we have installed required development tools including Django framework ,it's time for the first real step to start building our real estate app while learning Django essentials from scratch . Django framework includes a bunch of very useful utilities to create and manage projects that can be accessed from a Python file called django-admin.py that becomes available when we first installed Django . In this section we are going to see how to : Create a new project Setup and create the project database Start the development server Create a new Django project Creating a new Django project is easy and quick so open your terminal or command prompt then enter : $ django-admin.py startproject django_realestate This command will take care of creating a bunch of necessary files for the project . Executing the tree command in the root of our created project will show us the files that were created . . ├── django_realestate │ ├── __init__.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py └── manage.py init is the just the Python way to mark the containing folder as a Python package which means a Django project is a Python package . settings.py is the … -
Encodings — part 1
Has a UnicodeEncodeError ever got on your nerves? I think it has happened to pretty much everyone. I thought it’s a good time to start demystifying this mystery, and to have fun while doing it. You are probably familiar with the famous hello program, which does nothing but print “Hello, world!” Now we are going to create the bon program, which prints “Bon appétit!” Here it is, but don’t type it in or copy/paste it: import sys sys.stdout.write("Bon appétit!\n") We could have written it with a single print statement, but for several reasons I prefer this version. Now, I told you to not type in this program or copy/paste it. Instead, we are going to create it by writing down the bytes that comprise it. The file bon.py, like any file, is a series of bytes. These bytes represent the characters in the file. The first character is “i”, which is represented by the byte 105; the second one is “m”, represented by 109; and so on. You can find the table for all characters (except é) at Wikipedia. In order to create the file, we will use another Python program. Here it is. You can copy and paste that … -
Why Your Dockerized Application Isn’t Receiving Signals
Proper cleanup when terminating your application isn’t less important when it’s running inside of a Docker container. Although it only comes down to making sure signals reach your application and handling them, there’s a bunch of things that can go wrong. -
Introduction to Django Framework
Django is an open source Python based web framework for building web applications quickly and effortlessely .It's a pragmatic framework designed for developers working on projects with dead lines .It's perfect for quickly creating prototypes and then continue building them after clients approval . Django uses Python language , a general purpose ,powerful , feature rich programming language ,and follows a Model View Controller (MVC) design pattern .But what is MVC ? What is MVC ? MVC is a software architectural design pattern which encourages separation of concerns and seamless cooperation between designers and developers when working on the same project .It basically divides or separates your app into three parts : The Model , the View and the Controller . The Model is responsible for data storage and management . The View is responsible of representing and rendering the user interface or view . The Controller is responsible for handling logic to control the user interface and work with data model. Thanks to MVC you as a developers can work with controller to handle model data without being concerned about the user interface which is left to designers so if anything changes on the side of designers on the … -
Installing Development Environment On Windows ,Linux and MAC
Python is a portable programming language that can be used anywhere its runtime environment is installed . Django is a Python framework which can be installed on any system which supports Python language . In this tutorial part we are going to see how to install Python and Django on major available operating systems i.e Windows , Linux and MAC . Installing Python Depending on your operating system you may need or may not need to install Python .In Linux and MAC OS Python is included by default ,you may only need to update it if the installed version is outdated . Installing Python On Windows Python is not installed by default on Windows so you'll need to grab the official installer from the official Python website at http://www.python.org/download/ . Launch the installer and follow the wizard to install Python just like any other Windows program . Also make sure to add Python root folder to system path environment variable so you can execute the Python executable from any directory using the command prompt . Next open a command prompt and type python .You should be presented with a Python Interactive Shell printing the current version of Python and prompting … -
Learn Django From Scratch By Building A Real Estate Web Application
Throughout this beginner's tutorial we are going to learn how to build web applications with Python and Django framework .This tutorial assumes no prior experience with Django so we will be covering the the basic concepts and elements of Django by emphasizing essential theory with practice .Basically we are going to learn Django fundamental concepts while building a real world real estate web application starting from the idea to database design to full project implementation and deployment . This tutorial doesn't only cover fundamental basics of Django but also advanced concepts such as how to use and integrate Django with modern front end frameworks like Angular 2+ and React . -
Introduction to Django Framework
Django is an open source Python based web framework for building web applications quickly and effortlessely .It's a pragmatic framework designed for developers working on projects with dead lines .It's perfect for quickly creating prototypes and then continue building them after clients approval . Django uses Python language , a general purpose ,powerful , feature rich programming language ,and follows a Model View Controller (MVC) design pattern .But what is MVC ? What is MVC ? MVC is a software architectural design pattern which encourages separation of concerns and seamless cooperation between designers and developers when working on the same project .It basically divides or separates your app into three parts : The Model , the View and the Controller . The Model is responsible for data storage and management . The View is responsible of representing and rendering the user interface or view . The Controller is responsible for handling logic to control the user interface and work with data model. Thanks to MVC you as a developers can work with controller to handle model data without being concerned about the user interface which is left to designers so if anything changes on the side of designers on the … -
Installing Development Environment On Windows ,Linux and MAC
Python is a portable programming language that can be used anywhere its runtime environment is installed . Django is a Python framework which can be installed on any system which supports Python language . In this tutorial part we are going to see how to install Python and Django on major available operating systems i.e Windows , Linux and MAC . Installing Python Depending on your operating system you may need or may not need to install Python .In Linux and MAC OS Python is included by default ,you may only need to update it if the installed version is outdated . Installing Python On Windows Python is not installed by default on Windows so you'll need to grab the official installer from the official Python website at http://www.python.org/download/ . Launch the installer and follow the wizard to install Python just like any other Windows program . Also make sure to add Python root folder to system path environment variable so you can execute the Python executable from any directory using the command prompt . Next open a command prompt and type python .You should be presented with a Python Interactive Shell printing the current version of Python and prompting … -
Introduction to Django Framework
Django is an open source Python based web framework for building web applications quickly and effortlessely .It's a pragmatic framework designed for developers working on projects with dead lines .It's perfect for quickly creating prototypes and then continue building them after clients approval . Django uses Python language , a general purpose ,powerful , feature rich programming language ,and follows a Model View Controller (MVC) design pattern .But what is MVC ? What is MVC ? MVC is a software architectural design pattern which encourages separation of concerns and seamless cooperation between designers and developers when working on the same project .It basically divides or separates your app into three parts : The Model , the View and the Controller . The Model is responsible for data storage and management . The View is responsible of representing and rendering the user interface or view . The Controller is responsible for handling logic to control the user interface and work with data model. Thanks to MVC you as a developers can work with controller to handle model data without being concerned about the user interface which is left to designers so if anything changes on the side of designers on the … -
Installing Development Environment On Windows ,Linux and MAC
Python is a portable programming language that can be used anywhere its runtime environment is installed . Django is a Python framework which can be installed on any system which supports Python language . In this tutorial part we are going to see how to install Python and Django on major available operating systems i.e Windows , Linux and MAC . Installing Python Depending on your operating system you may need or may not need to install Python .In Linux and MAC OS Python is included by default ,you may only need to update it if the installed version is outdated . Installing Python On Windows Python is not installed by default on Windows so you'll need to grab the official installer from the official Python website at http://www.python.org/download/ . Launch the installer and follow the wizard to install Python just like any other Windows program . Also make sure to add Python root folder to system path environment variable so you can execute the Python executable from any directory using the command prompt . Next open a command prompt and type python .You should be presented with a Python Interactive Shell printing the current version of Python and prompting … -
Learn Django From Scratch By Building A Real Estate Web Application
Throughout this beginner's tutorial we are going to learn how to build web applications with Python and Django framework .This tutorial assumes no prior experience with Django so we will be covering the the basic concepts and elements of Django by emphasizing essential theory with practice .Basically we are going to learn Django fundamental concepts while building a real world real estate web application starting from the idea to database design to full project implementation and deployment . This tutorial doesn't only cover fundamental basics of Django but also advanced concepts such as how to use and integrate Django with modern front end frameworks like Angular 2+ and React . -
Angular Error: "No Provider for Module..."
The error "No Provider for Mod... -
Angular 2+ with Django Rest Framework tutorial (Part 3): Create database models
This is part 3 of our tutorial series to learn how to use Django Rest Framework with Angular 2+ by building a simple product inventory manager . Django REST framework (DRF) with Angular 2+ tutorial (Part 1) Django REST framework (DRF) with Angular 2+ tutorial (Part 2) Django REST framework (DRF) with Angular 2+ tutorial (Part 3) On the first part we have installed Django and created the server side project . On the second part we have installed Angular 2+ and created the client side project . In this part we are going to create a Django app and database models . Creating the Django app Lets start by creating a Django app so head over to your terminal and enter : cd ProductInventoryManager python manage.py startapp core Then open your project settings.py and add this app to the list of installed apps INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'core' ] Now we are ready to add database models . Open core/models.py and get ready to add models . Creating database models Users can create products ,families ,locations and add transactions .A product belongs to a family of products and has a location .To move … -
Angular 2+ with Django Rest Framework tutorial (Part 3): Create database models
This is part 3 of our tutorial series to learn how to use Django Rest Framework with Angular 2+ by building a simple product inventory manager . Django REST framework (DRF) with Angular 2+ tutorial (Part 1) Django REST framework (DRF) with Angular 2+ tutorial (Part 2) Django REST framework (DRF) with Angular 2+ tutorial (Part 3) On the first part we have installed Django and created the server side project . On the second part we have installed Angular 2+ and created the client side project . In this part we are going to create a Django app and database models . Creating the Django app Lets start by creating a Django app so head over to your terminal and enter : cd ProductInventoryManager python manage.py startapp core Then open your project settings.py and add this app to the list of installed apps INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'core' ] Now we are ready to add database models . Open core/models.py and get ready to add models . Creating database models Users can create products ,families ,locations and add transactions .A product belongs to a family of products and has a location .To move …