Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
SSL/TLS Settings for Django
Let's make your Django project... -
S3 Static & Media Files for Django
Using Amazon Web Services (AWS... -
The luxury of a creative community
The last few months of Evennia development have mainly focused around a series of very nice pull requests from a growing cadre of contributors. I have myself mainly been working away in Evennia's 'devel' branch which will lead up to Evennia 0.7.Contributed goodnessPeople have put in a lot of good work to boost Evennia, both by improving fixing existing things and by adding new features (small selection). Thanks a lot everyone!Contrib: Turn-based combat system - this is a full, if intentionally bare-bones implementation of a combat system, meant as a template to put in your particular game system into.Contrib: Clothing sytem - a roleplaying mechanic where a character can 'wear' items and have this show in their descriptions. Worn items can also be layered to hide that underneath. Had plenty of opportunities for extensions to a given game.Contrib: An 'event' system is in the works, for allowing privileged builders to add dynamic code to objects that fires when particular events happen. The PR is not yet merged but promises the oft pondered feature of in-game coding without using softcode (and notably also without the security of softcode!). A lot of PRs, especially from one user, dealt with cleanup and adherence … -
Django Framework Nedir?
Web Programçılığı Web sayfalarının giderek yaygınlaşması ve kullanıcı ile etkileşmeye ihtiyacının olması nedeniyle CGI(Common Gateway Interface) ile başladığını söyleyebiliriz. CGI yönetemi ile etkileşimli web sayfaları üretmek oldukça pahalı bir iştir. Çünkü sunucuya CGI programının yapacağı her istek geldiğinde, program çalıştırılır. Dış program derlemeli bir dil ile yazılmış veya yorumlanabilir bir dil ile yazılmış olabilir. Yazılımın... Django Framework Nedir? yazısı ilk önce Python Türkiye üzerinde ortaya çıktı. -
Testing django template tags
In this blog post I will give you simple example how to test your template tags in django using django testing tools. Let's get started! How to test templatetags? Let say that you got this template tag under /templatetags/create_header.py in django: from django import template register = template.Library() @register.inclusion_tag('example.html', takes_context=True) def make_header(context): return { 'header_title': context['title'] } This make_header tag will take the title from context and pass it template tag. Right after that example.html will be rendered. If you want to test if this template tag works you can use this: from django.test import SimpleTestCase from django.template import Context, Template class CreateHeaderTemplateTagTest(SimpleTestCase): def test_rendered(self): context = Context({'title': 'my_title'}) template_to_render = Template( '{% load create_header %}' '{% make_header %}' ) rendered_template = template_to_render.render(context) self.assertInHTML('<h1>my_title</h1>', rendered_template) What is happening here? I setup Context instance with a proper variable that will be taken by templatetag. After that I create Template. I used the same syntax to include templatetags inside your html files - they are templates for Django. Below I render a template with context and check if my templatetag renders correctly. And that's all! I have my templatetag tested. Feel free to comment! Cover image from Unsplash under CC0. -
Testing django template tags
In this blog post I will give you simple example how to test your template tags in django using django testing tools. Let's get started! How to test templatetags? Let say that you got this template tag under /templatetags/create_header.py in django: from django import template register = template.Library … -
Release the GitKraken!
The world of information technology is constantly developing and expanding, forcing myself and many other developers to learn new technologies and read smart books on a regular basis. Some people say that a programmer is reaching maturity when he or she starts to learn a second programming language. The post Release the GitKraken! appeared first on Distillery. -
Django ORM operations compared with Peewee
I saw a post in my weekly Python newsletter showing Django users how to execute common queries using SQLAlchemy. Here's the Peewee version. Setup Assume we have a Django model that looks like the following: class Country(models.Model): name = models.CharField(max_length=255, unique=True) continent = models.CharField(max_length=50) In Peewee, our table definition looks almost identical: from peewee import * # Peewee defines __all__, so import * is common practice. class Country(Model): name = CharField(unique=True) # Default max_length of 255. continent = CharField(max_length=50) Because Peewee does not have a singleton, application-wide database configuration, we also need to associate our model with a database. A common convention, when working with more than one table, is to define a base Model class which configures the database. This will save you a lot of typing when you have more than one model: from peewee import * from playhouse.pool import PooledPostgresqlDatabase db = PooledPostgresqlDatabase('my_app') class BaseModel(Model): class Meta: database = db class Country(BaseModel): name = CharField(unique=True) # Default max_length of 255. continent = CharField(max_length=50) To create tables, call the db.create_tables() method, passing in a list of tables. Peewee will re-order the tables so that they are created in the correct order if you have foreign-keys. def create_tables(): db.connect() … -
Django Tips & Tricks #7 - Django Auth Plugin For HTTPie
HTTPie is an alternative to curl for interacting with web services from CLI. It provides a simple and intuitive interface and it is handy to send arbitrary HTTP requests while testing/debugging APIs. When working with web applications that require authentication, using httpie is difficult as authentication mechanism will be different for different applications. httpie has in built support for basic & digest authentication. To authenticate with Django apps, a user needs to make a GET request to login page. Django sends login form with a CSRF token. User can submit this form with valid credentials and a session will be initiated. Establish session manually is boring and it gets tedious when working with multiple apps in multiple environments(development, staging, production). I have written a plugin called httpie-django-auth which automates django authentication. It can be installed with pip pip install httpie-django-auth By default, it uses /admin/login to login. If you need to use some other URL for logging, set HTTPIE_DJANGO_AUTH_URL environment variable. export HTTPIE_DJANGO_AUTH_URL='/accounts/login/' Now you can send authenticated requests to any URL as http :8000/profile -A=django --auth='username:password' -
Python PIP local cache
PIP is the Python Package Manager that allows Python developers and users to easily install Python packages published on the pip remote register by other developers . If you are using the pip manager frequently then you may find this quick tip useful ,where I'll show how you can activate or enable the local cache of pip which is going to boost the download speed of pip packages . The idea behind the pip cache is simple ,when you install a Python package using pip for the first time ,it gets saved on the cache .If you try to download/install the same version of the package on a second time ,pip will just use the local cached copy instead of retrieving it from the remote register . Enabling the local cache of pip Enabling the local cache of pip is fairly simple so let's do it step by step . First open the pip configuration file located at ~/.pip/pip.conf with your preferred text editor . vim ~/.pip/pip.con On Windows %HOME%\pip\pip.ini The configuration file can be also located in ~/.config/pip/pip.conf or in /etc/pip.conf There also legacy per user config files for PIP which are located in : $HOME/.pip/pip.conf on Unix and … -
Python PIP local cache
PIP is the Python Package Manager that allows Python developers and users to easily install Python packages published on the pip remote register by other developers . If you are using the pip manager frequently then you may find this quick tip useful ,where I'll show how you can activate or enable the local cache of pip which is going to boost the download speed of pip packages . The idea behind the pip cache is simple ,when you install a Python package using pip for the first time ,it gets saved on the cache .If you try to download/install the same version of the package on a second time ,pip will just use the local cached copy instead of retrieving it from the remote register . Enabling the local cache of pip Enabling the local cache of pip is fairly simple so let's do it step by step . First open the pip configuration file located at ~/.pip/pip.conf with your preferred text editor . vim ~/.pip/pip.conf Then copy and add this [global] download-cache=/usr/local/pip/cache Next create the folder mkdir -p /usr/local/pip/cache Then give it write access chmod -R 755 /usr/local/pip/cache You can instead use your profile config file ~/.bash_profile So … -
Python and Django Beginner's Pack: books, tutorials, newsletters
I bet a fresh job offer will make anyone a bit happier and more self-confident. Still, most of us had at least a single denied CV or failed interview. If this is the case, consider it as a sort of new experience. This article is intended for a person who'd like to become an intern in a software development company. Here in Django Stars if a candidate fails to pass the interview due to the lack of knowledge, we always provide the list of useful tutorials and books, that can help him or her to improve the coding skills. You don’t need to pass every single course completely. It’s better to start from the very basic tutorials and do a lot of practice(little Python scripts and eventually a simple Django app). And one more very important note: whenever you learn a new concept, data type, class or function, don’t forget to check the official documentation. One day you won’t need anything than the documentation. So far it's a good idea to briefly look it through. So here is our top 10 books and tutorial we recommend for novice programmers or those seeking to become an intern or junior Python/Django Developer: … -
Recap of DjangoConEurope 2017
"DjangoCon, why is everybody wearing this t-shirt?" wondered the security guys in the airport of Florence, Italy, in the beginning of April. The reason for that was DjangoCon Europe 2017 happening there for a week, full of interesting talks in an exciting location. What I liked, was that the conference was not only about technical novelties in Django world, but also about human issues that programmers deal with in everyday life. Interesting Non-tech Topics According to a manifest, the conference had a goal to strengthen the Django community and to shape responsible attitude towards the works done with Django. Healthy and Successful Community We have to build stronger communities including everyone who wants to participate without discrimination. Although, at first, it might be difficult as people have biases, i.e. prejudices for or against one person or group; by being emphatic we can accept and include everyone no matter what is their gender identity or expression, sexual orientation, ethnicity, race, neurodiversity, age, religion, disabilities, geographical location, food diversities, body size, or family status. Valuing diversity and individual differences is the key for a healthy, positive and successful community, that empowers its members and helps them grow stronger and happier. Responsibility for … -
DjangoCon 2017
I love DjangoCon. I've been going to it almost every year since I arrived in Europe back in 2010. Sure, a considerable portion of my career has been based on Django, but it's more than that: the community is stuffed full of amazing people who genuinely want us all to succeed and that just makes the conference all the more exciting. This year we all converged on Florence for three days of talks in a historic old theatre at the heart of the city and like every year, the talks at this single-track event were hit-and-miss -- but that's ok! When the talks were less-than-useful we could always just pop out for gelato or catch up in the hallways with other developers. The Good Community From talks covering gender bias or autism, to the re-labelling of all bathrooms to be unisex, DjangoCon has long been a shining example of how to be inclusive in a software development community and it's something I'm proud to be a part of. This year, they even raised enough money to pay for flights and accommodation for a number of people from Zimbabwe who are trying to grow a local Django community. It feels good … -
DjangoCon 2017
I love DjangoCon. I've been going to it almost every year since I arrived in Europe back in 2010. Sure, a considerable portion of my career has been based on Django, but it's more than that: the community is stuffed full of amazing people who genuinely want us all to succeed and that just makes the conference all the more exciting. This year we all converged on Florence for three days of talks in a historic old theatre at the heart of the city and like every year, the talks at this single-track event were hit-and-miss -- but that's ok! When the talks were less-than-useful we could always just pop out for gelato or catch up in the hallways with other developers. The Good Community From talks covering gender bias or autism, to the re-labelling of all bathrooms to be unisex, DjangoCon has long been a shining example of how to be inclusive in a software development community and it's something I'm proud to be a part of. This year, they even raised enough money to pay for flights and accommodation for a number of people from Zimbabwe who are trying to grow a local Django community. It feels good … -
Using ProtoBuf for Huge Object Serialization
We at Distillery faced a problem that the size of Memcached objects is huge. We’ve come close to exceeding the Memcached server storage limit which can trigger eviction of objects, putting more load on the databases. The purpose of this investigation is to find a way to reduce the size of Memcached objects which will lead to less traffic from IIS to Memcached servers. The post Using ProtoBuf for Huge Object Serialization appeared first on Distillery. -
Python 3
Helping my company migrate everything to Python 3. Righteous! And we’ll update everything else, including Django, when we do it. If only an updated Python Essential Reference was available… I’d buy it for every developer. I can’t hassle David anymore since I left Twitter. ‘Tis a shame. I could send him email and text messages, but it wouldn’t be the same. Tagged: Django, Python, social networking -
How many Django developers deal with small sites?
I read blogs, I listen to podcasts, I look at conference talks, all about deployment, and the impression I’m getting is that everyone’s problem is how to serve one billion requests per nanosecond. What the heck, am I the only one who makes small sites? I suspected that the people who blog are usually the ones who achieve more impressive feats, and therefore that the blogs aren’t representative of the developer population. So I made a web survey and asked people whether their deployments serve more or less than ten requests per second on the busiest second of the day. I chose ten because usually you can easily serve ten requests per second from a single virtual server; but still, if you reach ten, you will start thinking at least about the possibility of needing to scale. Detailed results from 59 submissions of the web survey. One of the questions concerned the professional experience of the person, so I have categorized results by more than three years, fewer than three years, and having worked only on unpaid projects. A web survey is not, however, representative of the population; the sample consists only of people who chose to respond to the … -
Deploy your Django/Python app to PyPi
Learn how to deploy an app to ... -
Angular Setup Guide
This is a step-by-step setup g... -
A decent Elasticsearch search engine implementation
The title is a bit of an understatement because I think it's pretty good. It's not perfect and it's not guaranteed to scale, but it works pretty well. Especially on search term typos. This, my own blog, now has a search engine built with Elasticsearch using the Python library elasticsearch-dsl. The algorithm (if you can call it that) is my own afternoon hack invention. Before I explain how it works try out a couple of searches: Try a couple of searches: (each search appends &debug-search for extended output) corn - finds Cornwall, cron, Crontabber, crontab, corp etc. crown - finds crown, Crowne, crowded, crowds, crowd etc. react - finds create-react-app, React app, etc. jugg - finds Jung, juggling, judging, judged etc. pythn - finds Python, python2.4, python2.5 etc. Also, by default it uses Elasticsearch's match_phrase so when you search for a multi-word thing, it requires a match on each term. E.g. date format which finds Date formatting, date formats etc. But if you search for something where the whole phrase can't match, it splits up the search an uses a match operator instead (minus any stop words). Typo-focussed This solution is very much focussed on typos. One thing I really … -
Angular 4 Setup Guide
# This guide is still being de... -
Testing django mixins
You may read all these books and tutorials that tell you - test your code! This blog post is to help you test your django mixins. Table of Contents: Why is it worth to test mixins? How to test mixins? Why is it worth to test mixins? You come to django world and you discover mixins - at the beginning, you think it awesome! Let write more of those! So you write this self-contained mixin - right now there is a time to test it. It can assure that your piece of code works as expected and can save you a lot of trouble. Ok, you are ready to write some test. How to do it? How to test mixins? Imagine that you have this simple TemplateView with mixin: from django.views.generic import TemplateView class SomethingMixin(object): def get_context_data(self, **kwargs): context = super(SomethingMixin, self).get_context_data(**kwargs) context['has_something'] = True return context class ExampleTemplateView(SomethingMixin, TemplateView): template_name = 'example.html' SomethingMixin is adding a new key to the context. Let's write some tests: from django.test import SimpleTestCase from django.views.generic import TemplateView from .views import SomethingMixin class SomethingMixinTest(SimpleTestCase): class DummyView(SomethingMixin, TemplateView): pass def test_something_mixin(self): dummy_view = self.DummyView() context = dummy_view.get_context_data() self.assertTrue(context['has_something']) I created a simple empty DummyView to … -
Testing django mixins
You may read all these books and tutorials that tell you - test your code! This blog post is to help you test your django mixins. Table of Contents: Why is it worth to test mixins? How to test mixins? Why is it worth to test mixins? You come to django … -
PyCon IT 2017 “Otto”
PyCon Italia is the national conference where professionals, researchers and enthusiasts of the most beautiful programming language gather together.