Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Continuous integration with travis and coveralls.io for Django apps
Maintaining a solid rapport with the ongoing software development process always turns out to be a walk on air. Ensuring a software build integrity and quality in every single commit makes it much more exciting. If the current software bulid is constantly available for testing, demo or release isn't it a developer's paradise on earth? Giving a cold shoulder to "Integration hell" the 'Continuous integration' process stands out to deliver all the above assets. What's Continuous integration? Continuous integration is a development practice that requires a developer to integrate code into a shared repository in which isolated changes are immediately tested and reported on when they are added to a larger code base. Continuous integration (CI) originated from within the extreme programming paradigm, but the principles can be applied to any iterative programming model, such as agile programming. As critics noted several potential drawbacks on extreme programming many organizations have adopted CI without all of the extreme programming concepts. Principles of CI: Maintain a single source repository Automate the build Make the build self-testing Keep the build fast Everyone can see the results of the latest build Automate deployment Keywords: Build: All steps necessary to compile and create deliverables. Commit: … -
Absolute last chance for tickets!
We have been able to make a few more tickets available for DjangoCon Europe 2014. This last batch of sales must close at the very latest 1700 CET today, 29th April, and may close earlier. If you would like a ticket and don't have one, get it now. Please don't be disappointed! You can tell us about accommodation preferences, but please note that there are no more single rooms available. -
Working with JSON and Django
In this day and age of web development we work with json, a lot, especially with using web services. Unfortunately, sometimes you can forget what does what, when, and where when dealing with json. I know I have to look up the same thing over and over at times. This blog post is everything you need to deal with json "day-to-day" with Django. JSON to Dict One of the first things we, usually, do is convert json data that we get back from a web service call, or from a webhook, into a python datastructure. import json json_data = '{"hello": "world", "foo": "bar"}' data = json.loads(json_data) The key element from this is the json.loads which loads a string of json and converts the data to a python dict. From there you get to use it like normal. Dict to JSON import json data = {'baz': 'goo', 'foo': 'bar'} json_data = json.dumps(data) Normally you want to get your data into json from your dict, or model, which is just as easy using json.dumps. It converts your dict to a string of json so you can return it to in a response. HttpResponse with JSON There are a couple of key parts … -
Writing styled forms with absolutely minimal HTML (Part-1)
When controlling the form rendering, we all know that we can use the three pre-baked output format of the forms namely: as_u, as_p and as_table. For example: if we use: {{ registration_form.as_ul}} The output template would be: <li> <label for="id_uname">Userame:</label> <input type="text" name="username" id="id_uname"> <li> <li> <label for="id_email">Email:</lable> <input type="text" name="email" id="id_email"> <li> And so on... Here are some questions that come into the picture: What if we to want deal with divs? What if we want to reorder the fields? and what if I have 100 such fields? And what if I want to deal with model forms? How about field.errors and form.non_field_errors? To answer all those significant questions Django-crispy-forms steps into the arena. What are Django-crispy-forms? It's an app that brings up the best way to get the DRY Django forms, providing the tag and filter that lets us quickly render forms in a div format. This also provides an enormous amount of capability to configure and control the rendered HTML. As an added asset Django-crispy-forms support several frontend frameworks like Twitter Bootstrap(versions- 2 and 3), Uniform and Foundation. Using Django-crispy-forms is very simple and effortless. Let's dive in to learn to use the Django-crispy-forms with Twitter Bootstrap … -
Django backward relationship lookup
I often limit the lookup to fields of the model and forget about backward relations. Consider the following relationship: class Group(models.Model): name = models.CharField(max_length=100) class Student(models.Model): name = models.CharField(max_length=100) group = models.ForeignKey(Group) A group can have many students. We want to get the groups based on certain conditions on model Student. An example is getting the groups which contain a student named 'stud1'. If you can get it using model Group and without using Student, you can skip this post. In such a scenario, we tend to use Student model. It's more intuitive because the Foreign Key relationship exists from Student to Group. Let's load the following data to test our queries: group1 = Group.objects.create(name='Group 1') group1 = Group.objects.create(name='Group 2') Student.objects.create(name='stud1', group=group1) Student.objects.create(name='stud2', group=group1) Student.objects.create(name='stud3', group=group1) Student.objects.create(name='stud1', group=group2) Get the groups which contain student named stud1. Intuitive way: We first try to get all the students which satisfy the criteria. Query for that would be: Student.objects.filter(name='stud1') And then we try to get the groups of those students. If we use the Student model, we can't get a queryset of Group. So our approach would be to first get the ids of desired groups and then get a queryset of Group … -
Writing styled forms with absolutely minimal HTML (Part-2)
In the earlier post we have cruised through the fundamentals of using crispy forms for writing styled forms with minimal HTML. At this time, let us dip into getting a clear understanding on how to customize the crispy forms. Before diving into the crux of this post we will become aware with the following key words: FormHelper Layout FormHelper Django-crispy-forms implements a class called FormHelper to define the form rendering behavior. Helpers give us a way to control the form attributes and its layout. They control global form rendering behavior. Layout It is an another powerful class of Django-crispy-forms which allow us to change the way the form fields are rendered. This allows us to set the order of the fields, wrap them in divs or other structure, etc. Custom output Flexible and highly reususable In the first place we will get to know how to render a model form and then we will be customizing the divs and fields in the template. Handling ModelForm with a Django-crispy-form. As we know ModelForms render Model fields as HTML, let us do this using the crispy-forms now. Now lets render an Address form containing the fields like name, street, landmark and so … -
Webhooks, Django, and ngrok
Working with webhooks can be a pain. In this video learn more of what they are and how to easily work with them in your local environment using ngrok.Watch Now... -
Re: What Can Men Do?
TL;DR: Ignore Jeff; read Shanley. Jeff Atwood: If you see any behavior that gives you pause, behavior that makes you wonder “is that OK?” […] speak up. Honestly, as one man to another. OK, you got it. Jeff Atwood’s blog post today asks an important question: “what can men do?” (I’m not linking to Jeff’s post directly; it doesn’t need the signal boosting.) But it fails to answer that question effectively, reinforces several myths about gender in tech, and, worst of all, structurally reinforces male dominance rather than breaking it down. -
Two Scoops of Django 1.6 India Edition Available!
Newsletter #2 The India Edition of Two Scoops of Django 1.6 is now available at the following outlets: Within the next few weeks we hope to add Infibeam to the list of supported Indian retailers. Personal Note From Audrey The India Edition has special significance to us because my father is from India, and some of my family is still there. On my father's side, my grandfather was a civil engineer, and my grandmother was a mathematician. My grandmother passed away when I was very young, and my grandfather passed away a few years ago. I wish that they could have been around to see this. I grew up visiting my family in West Bengal often during the holidays. Information About the India Edition The India Edition, available internationally, is described in detail on our FAQ. -
Two Scoops of Django 1.6 India Edition Available!
Newsletter #2 The India Edition of Two Scoops of Django 1.6 is now available at the following outlets: Within the next few weeks we hope to add Infibeam to the list of supported Indian retailers. Personal Note From Audrey The India Edition has special significance to us because my father is from India, and some of my family is still there. On my father's side, my grandfather was a civil engineer, and my grandmother was a mathematician. My grandmother passed away when I was very young, and my grandfather passed away a few years ago. I wish that they could have been around to see this. I grew up visiting my family in West Bengal often during the holidays. Information About the India Edition The India Edition, available internationally, is described in detail on our FAQ. -
Two Scoops of Django 1.6 India Edition Available!
Newsletter #2 The India Edition of Two Scoops of Django 1.6 is now available at the following outlets: Within the next few weeks we hope to add Infibeam to the list of supported Indian retailers. Personal Note From Audrey The India Edition has special significance to us because my father is from India, and some of my family is still there. On my father's side, my grandfather was a civil engineer, and my grandmother was a mathematician. My grandmother passed away when I was very young, and my grandfather passed away a few years ago. I wish that they could have been around to see this. I grew up visiting my family in West Bengal often during the holidays. Information About the India Edition The India Edition, available internationally, is described in detail on our FAQ. -
DjangoCon Europe accommodation preferences
Our Django Island hotel offers accommodation in various different kinds of rooms (single, twin or double) in various different kinds of apartments (of one, two or three rooms). We need to know your preferences - tell us! Rooms The standard room is a twin (two single beds), which will be shared with another Django Islander of the same sex. If you would prefer to share with a particular person, you can let us know. There are 60 single rooms available. If you need - you don't need to tell us why - or strongly prefer a single room, just say so. If you are travelling with a partner (i.e. you have purchased a "companion" ticket) or you and your partner are both conference attendees, you can ask for a double room. Each room has its own private bathroom. Apartments You can also let us know whether you prefer to be in an apartment with only one room, or amongst others, and with whom. If you do have a preference about apartments, please tell us whether: you'd like to be in an apartment on your own you'd like to share the apartment with friends (tell us whom) you'd prefer to be … -
Assisted places for students
Thanks to the generosity of our sponsors and the attendees who bought a "Contribution" ticket we've been able to support a number of our speakers who were on tight budgets, and who would otherwise have been unable to attend. We are delighted to announce that the same generosity means that we're able to make an additional 7 conference places available to students at a discount of 270 € - that is, for 400 € each. The 400 € covers the conference, accommodation (Tuesday and Wednesday night) and all meals. These tickets are only available, on a first-come first-served basis, to students in full-time education. We'll require some proof of status. We're truly grateful to the community for providing the support that has made this possible. Student tickets -
Tutorials!
This year at DjangoCon Europe, as well as our packed programme of talks, we are running tutorials. They are all free, and all running on Friday, the first day of the sprints. One of them, Daniele Procida's Don't be afraid to commit, is even an introduction to contributing to projects such as Django, and will lead you seamlessly into the sprints! Harry Percival's Test-driven web development with Python and Django is frankly worth the price of admission to the entire conference. Patrick Lauber's Get started with django CMS will give you a big head-start with one of Django's most successful and well-known products, as a user and developer. The three tutorials we are offering represent our effort to use DjangoCon Europe to kickstart even more activity in the community. We know that people want to take part, and to contribute, but that it's not always so easy to get started. Our tutorials are for those people. They are three first-class reasons to stay on after the talks for the sprints, and will equip you with valuable skills. In short: don't think that the sprint days of DjangoCon are just for those 'other' people, the ones who can run while you're … -
教你开始写DJANGO1.6的第1个APP-4
回顾一下在第3部分中我们实现了投票应用的基本框架结构,但是并没有实现真正的投票表单和处理,以及结果显示等功能, […] -
Minimal Nginx and Gunicorn configuration for Django projects
We will see how to deploy a Django project with nginx and gunicorn. It was easier for me to understand nginx and gunicorn on development machine and then move to a publicly accessible server. So, we will cover this post in a similar sequence: On development machine Use django's runserver to serve the site. Stop runserver and start using gunicorn instead. Add nginx to this configuration. On server Deploy the project on a publicly accessible server using same stack. Use runserver We will use a minimal project with two apps and few static files. You can view this project at github. Project structure: |-- manage.py |-- other_app | |-- __init__.py | |-- models.py | |-- static | | `-- other_app | | `-- styles.css | |-- tests.py | |-- urls.py | `-- views.py |-- project_static | `-- base.css |-- requirements.txt |-- some_app | |-- __init__.py | |-- models.py | |-- static | | `-- some_app | | `-- styles.css | |-- tests.py | |-- urls.py | `-- views.py |-- templates | |-- other_app | | `-- home.html | `-- some_app | `-- home.html |-- test.db `-- test_project |-- __init__.py |-- settings.py |-- test_settings.py |-- urls.py `-- wsgi.py This project was … -
Django 1.6 最佳实践: 最佳Django开发环境设置
在本节中, 我们将介绍最佳的本地开发环境设置 1. 在开发和部署服务器中使用相同的数据库 可能有些开发者喜欢在本地开发Django程序时, 使用SqLite3数据库, 而在部署时使用PostgreSQL数据库(或任何不同于SqLite3的数据库). 但这一做法应当避免, 因为我们是希望不同的数据库表现的一致, 这显然是不现实的. 以下是一些我们使用不同数据库进行开发和部署时遇到的问题: Fixtures不是解决方法 或许你会想, 我们为何不能用fixtures来弥补不同数据库的不同呢? 是的, fixtures能用于创建简单的手写的测试数据, 它能在开发时填充进许多假的数据, 尤其是在开发初期阶段. 但是, fixtures对于从一个数据库到另一个未知数据库的大数据迁移而言, 并不是一个可靠地工具. 它本身也不是为了这一目的而设计的, 我们不应该将创建基本数据和数据迁移的用法混淆. 无法本地测试部署后数据 当你的本地数据库和部署数据库不同时, 你无法创建一个和部署服务器完全一样的拷贝进行测试. 当然你可能会觉得使用dump将数据完全拷贝出来放到本地数据库中测试, 但是这也无法保证导出和导入后的数据是完全一样的. 不同数据库拥有不同的数据类型 请牢记, 不同的数据库处理数据的类型是不同的! Django的ORM试图统一这些不同, 但毕竟所能实现的效果是有限的. 比如, 在使用SqLite3作为测试数据库, 而使用PostgreSQL作为部署数据库时, 由于SqLite3是动态, 弱类型数据库, 而PostgreSQL则是强类型数据库, 虽然程序在测试服务器上运行正常, 但最终可能导致在部署服务器上出现问题. 2. 使用Pip和Virtualenv 如果你还没有使用Pip和Virtualenv, 那么, 我们强烈推荐你现在就开始熟悉并使用Pip和Virtualenv. Pip和Virtuaenv是Django项目的标准配置, 并且大多数开发者依赖这两个工具. Pip是从Python Package Index下载Python模块的工具, 更是管理和安装Python模块的不二选择. 它有点像easy_install, 但具有更多的功能, 其中最重要的就是对于Virtualenv的支持 Virtualenv是创建独立的Python开发环境, 管理模块依赖性的工具. 当我们同时开发多个项目时, 且这些项目使用的库或模块都有所不同时, 它可以帮助我们轻松的在这些独立开发环境质检切换. 当然为了方便使用Virtualenv, 我们可以借助virtualenvwrapper. virtualenvwrapper为我们提供了诸多命令, 方便我们使用Virtualenv 3. 使用Pip安装Django和其他依赖库 Django官网提供了多种安装Django的方式, 但我们推荐使用pip来安装Django和其他项目依赖模块. 简单而言, 每个Django项目都需要一个requirements文本文件, 其中罗列了所有本项目中使用到的Python模块, 每条信息包括了模块的名字和版本号. 我们就使用pip将这些requirements安装到项目的virtualenv中, 具体的说明我们会在将来谈到requirements时做一个详细的介绍. 4. 使用版本控制系统 版本控制系统又叫源代码管理系通, 在进行任何语言的编程时, 你都应当使用版本控制系统来管理跟踪你的源代码. 如果你不了解的话, 可以搜索一下, 应该能找到各版本控制系统的详细比较. 在所有的版本管理系统中, 我们推荐使用git. 因为第一, git似乎是现在最为流行的版本控制系统, 第二它可以方便的建立和合并分支. 在使用版本控制软件的同时, 我们推荐使用GitHub或Bitbucket作为在线的源代码仓库, 用于备份源代码仓库. 5. 试着使用Vagrant Vagrant是一个用于创建, 设置和管理开发环境的工具. Vagrant借助VirtualBox等虚拟化工具, 可以轻松的创建我们需要的虚拟机开发环境. 例如, 我们的开发环境是OS X, 而部署环境是Ubuntu时, 我们就可以使用Vagrant创建一个Ubuntu虚拟机, 并在其中配置好开发环境. 详细的介绍, 我们会在将来讲到开发环境时再谈. -
Parsing tags with django-content-bbcode in examples
Some time ago I've released django-content-bbcode - a BBCode alike tag parser. In this article I'll show some example of usage for such parser - from simple search and replace to more complex using database to get the response. -
RuntimeError: App registry isn't ready yet
The upcoming Django 1.7 has many interesting and welcomed changes. One of them is an update to how applications are loaded. The relase notes also mention potential problems with these changes. I ran into RuntimeError: App registry isn't ready yet while using the self-contained tests approach, but the fix is as simple as mentioned in the docs. # Django 1.7 try: import django django.setup() except AttributeError: pass -
RuntimeError: App registry isn't ready yet
The upcoming Django 1.7 has many interesting and welcomed changes. One of them is an update to how applications are loaded. The relase notes also mention potential problems with these changes. I ran into RuntimeError: App registry isn't ready yet while using the self-contained tests approach, but the fix is as simple as mentioned in the relase notes. import django django.setup() If your code needs to run on Django < 1.7 as well you could use # Django 1.7 try: import django django.setup() except AttributeError: pass Update: Dieter's comment actually made me think about my code for a second and I'll be using something different: import django if hasattr(django, 'setup'): django.setup() -
RuntimeError: App registry isn't ready yet
The upcoming Django 1.7 has many interesting and welcomed changes. One of them is an update to how applications are loaded. The relase notes also mention potential problems with these changes. I ran into RuntimeError: App registry isn't ready yet while using the self-contained tests approach, but the fix is as simple as mentioned in the relase notes. import django django.setup() If your code needs to run on Django < 1.7 as well you could use # Django 1.7 try: import django django.setup() except AttributeError: pass Update: Dieter's comment actually made me think about my code for a second and I'll be using something different: import django if hasattr(django, 'setup'): django.setup() -
DjangoIsland, parce que les poneys savent nager
Vous êtes djangonautes ? Et vous n’avez pas encore acheté votre billet pour DjangoCon Europe ? Alors peut-être que vous ne le saviez pas. Après tout, même si on a essayé de faire un maximum de com sur le sujet, on n’en fait jamais assez et il est fort possible que vous soyez passé à coté. Donc, je vous refais un petit topo. 3 jours de confs du 13 au 15 mai et 2 jours de sprint le 16 et 17 mai. Et tout cela en France, donc facile au niveau transport, il vous suffit de prendre un TGV. Mais surtout, surtout, ce ne sont pas trois jours de confs dans une simple salle de conf, aussi belle soit-elle. Non, ce sont trois jours de confs (et 2 jours de sprint) dans une île. Oui, dans une ILE. L’île des embiez pour être exact, une petite île qui se trouve dans le Var qui appartient à la famille Ricard. Imaginez donc la scéne. Vous sortez de votre TGV à Toulon, vous prenez un bus et vous arrivez sur un port, le port du Busc. Et la vous prenez un petit ferry et vous voguez, le doux soleil de méditerranée vous … -
NoReverseMatch at xxxx is not a registered namespace 问题解决
Django模板语言中的url命令可通过使用命名空间语法防止url名称的重复,例如: [crayon-53e8 […] -
Caktus has a new website!
It’s been a few years since we last updated our website, and we gave it a whole new look! With the new site, it’s easy to see just what services we offer, and our processes for bringing our client’s ideas to life. The new layout allows for more in-depth reviews of our projects, and also highlights our talented and growing team. We also wanted to share more information on our commitment to the open source community and social good. And the updated structure makes finding out about events and reading our ever-popular blog posts simple. The new design utilizes a responsive grid structure and a refined typographic sensibility. Wrap this all up with our new branding—adding a bold blue to our green/grey—and you get a polished and and informative new site that reflects what Caktus does best. We hope you find the new site more intuitive, user-friendly and as easy-on-the-eyes as we do! -
Caktus has a new website!
It’s been a few years since we last updated our website, and we gave it a whole new look! With the new site, it’s easy to see just what services we offer, and our processes for bringing our client’s ideas to life. The new layout allows for more in-depth reviews of our projects, and also highlights our talented and growing team. We also wanted to share more information on our commitment to the open source community and social good. And the updated structure makes finding out about events and reading our ever-popular blog posts simple.