Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Best free and paid Python Django hosting
Python is a great programming language ,combined with many great tools and frameworks ,it will help you be a very productive developer . Personally i'm using Python for web development with the powerful open source Django framework . Django is a pragmatic web framework for perfectionists with deadlines which can help you build your web project prototype quickly and then build upon it to finish the final project at record time . OK that's cool but how about hosting ? A web project either if it is an ordinary website or a full fledged web application needs web hosting . Many new comers to Django and web developers looking for adopting Django as their web framework ,ask about hosting from the availability of good providers to service costs so in this post i'm going to list some of the best options for hosting Django projects either free and paid ones so I can help you choose the right solution for you but please pay attention . Choosing the right hosting provider depends heavily on your requirements .While many providers provide free Django hosting , you should only use it for testing purposes or for playing with the provider's infrastructure or … -
Django-REST Framework Object Level Permissions and User Level Permissions
Let us cosider the scenario of Authors, Books, Readers. Authors are only allowed to write the books Readers are only allowed to read the Books. models.py from django.utils.translation import ugettext_lazy as _ from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin class User(AbstractBaseUser, PermissionsMixin): USER_TYPES = ( ("Author", "Author"), ("Reader", "Reader"), ("Publisher", "Publisher") ) username = models.CharField(max_length=100, unique=True) first_name = models.CharField(_("first name"), max_length=30, blank=True, null=True) last_name = models.CharField(_("last name"), max_length=30, blank=True, null=True) email = models.EmailField(_("email address"), unique=True) is_staff = models.BooleanField(_("staff status"), default=False) is_active = models.BooleanField(_("active status"), default=True) user_type = models.CharField(choices=USER_TYPES) def __str__(self): return self.email class Book(models.Model): READ_OPTIONS = ( ('YES', 'YES'), ('NO', 'NO') ) name = models.CharField(max_length=300) pages = models.IntegerField() price = models.DecimalField(max_digits=10, decimal_places=2) rating = models.FloatField() is_allowed_to_read = models.CharField(choices=READ_OPTIONS) def __str__(self): return self.name permissions.py from rest_framework.permissions import BasePermission class IsAllowedToWrite(BasePermission): def has_permission(self, request, view): return request.user.user_type == "Author" class IsAllowedToRead(BasePermission): def has_object_permission(self, request, view, obj): return obj.is_allowed_to_read == "YES" views.py from rest_framework import generics from app.permissions import IsAllowedToWrite, IsAllowedToRead from app.serializers import WriteBookSerializer, class WriteBookView(generics.CreateAPIView): serializer_class = WriteBookSerializer permission_classes = (IsAllowedToWrite,) class ReadBookView(generics.RetrieveAPIView): serializer_class = ReadBookSerializer permission_classes = (IsAllowedToWrite,) Find our Django REST Framework … -
How to fix Django’s HTTPS redirects in nginx
You deploy with nginx and Gunicorn and your site uses HTTPS. If Django occasionally returns HttpResponseRedirect or similar, you may find that the redirect sends you back to HTTP. Here’s how to fix it. In the nginx configuration (inside the location block), specify this: proxy_redirect off; proxy_set_header X-Forwarded-Proto $scheme; The proxy_redirect off statement tells nginx that, if the backend returns an HTTP redirect, it should leave it as is. By default, nginx assumes the backend is stupid and tries to fix the response; if, for example, the backend returns an HTTP redirect that says “redirect to http://localhost:8000/somewhere”, nginx replaces it with something similar to “http://yourowndomain.com/somewhere”. But Django isn’t stupid (or it can be configured to not be stupid), and it will typically return a relative URL. If nginx attempts to “fix” the relative URL, it will likely break things. Instead, we use proxy_redirect off so that nginx merely passes the redirection as is. The second line is only necessary if your Django project ever uses request.is_secure() or similar. It’s a good idea to have it because even if it doesn’t today it will tomorrow, and it does no harm. Django does not know whether the request has been made through … -
Install Django on Mac
#### Install Django & Virtuale... -
Install Python & Django on Windows
### Install Python & Django on... -
Common Regular Expressions for Django URLs
Common Regular Expressions for... -
Python Cheat Sheet
A quick reference guide for us... -
My Equipment
### Computer Laptop: [http:... -
AngularJS vs jQuery
### AngularJS is a framework ... -
Django App Structure
To make your individual Django... -
Syncdb is ... gone?
Yup `python manage.py syncdb` ... -
A Fantastic Ted Talk
This is by far one of the most... -
Everything coming in 2017
Topics -
*args and **kwargs
So when you write any given fu... -
Testing Email in Django with send_mail
Sometimes you need to test tha... -
Which Version to Use?
When you watch or read tutoria... -
New URL Structure for Django
Django 1.10 has changed the re... -
post_save vs pre_save vs override save method
Which is better ... `post_save... -
TemplateDoesNotExist error
I see this error come up a lot... -
Hats off to you...
CFE Community! Hats off to ... -
Transcoding with AWS- part five
This is the last blog post in this series - the only thing that has to be done is telling the user that file he or she uploads is processed. It will be done by writing custom message application. Tabel of Contents: How message application should work Implementation in django Other blog posts in this series How message application should work From previous post I know that the last point of my application flow is to inform user that file is transcoded and ready to download. To do such thing I have to display message on every webpage that current user is. This message should have information about which file was processed. First I wanted to do this with existing django messaging framework but as it turns out is works only with request. As I decided to show message for different users as long as they dismiss this information I had to write my own small application. Implementation in django In my newly created application I created following model: from django.db import models from django.contrib.auth.models import User class Message(models.Model): text = models.CharField(max_length=250) read = models.BooleanField(default=False) def __str__(self): return self.text I decided to display my message only when it wasn't read. … -
Transcoding with AWS- part five
This is the last blog post in this series - the only thing that has to be done is telling the user that file he or she uploads is processed. It will be done by writing custom message application. Tabel of Contents: How message application should work Implementation in django Other … -
Integrate Django-Oscar-Accounts with Django-Oscar
Django Oscar Accounts is a package that provides the ability to manage accounts with fully managed account functionality to use with Django Oscar. * Django Oscar Accounts provides managed accounts using double-entry bookkeeping. * In this package every transaction is recorded twice(once for the source account and once for the destination account) by using double-entry bookkeeping. This make sure that books always balance and there exist full record of all transactions. Features - A user can have multiple accounts An account can be created with - no users assigned, a single primary user assigned or set of users can be assigned An account consists of start date and end date to restrict its usage in a limited time, also it can be restricted so that it can only be used to pay for a range of products. An account has a credit limit, by default it will be zero. Installation - * Install using pip: pip install django-oscar-accounts * Next, add "oscar_accounts" to INSTALLED_APPS in settings file. * After this apply migrations with "manage.py migrate oscar_accounts" command. This will create the appropriate database tables. * Next use "manage.py oscar_accounts_init" command to create core accounts and account-types. The names of these … -
Ship It Day Q1 2017
Last Friday, Caktus set aside client projects for our regular quarterly ShipIt Day. From gerrymandered districts to RPython and meetup planning, the team started off 2017 with another great ShipIt. -
How I Deploy Django Day-to-Day
There are a lot of ways to deploy Django so I think it is one of those topics people are really curious about how other people do it. Generally, in all deploys you need to get the latest code, run migrations, collect your static files and restart web server processes. How yo do those steps, that is the interesting part. In todays video I go over How I deploy Django day to day, followed by some other ways I have done it. This is definitely a topic you can make as easy or complicated as you want. Here is the link again: https://www.youtube.com/watch?v=43lIXCPMw_8?vq=hd720