Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Hosting Django under different locations with Nginx and gunicorn
Do you know how Django uses SCRIPT_NAME? It's not often I host different instances of Django under different locations on the same domain. One legacy install has been setup that way for over a year with Apache2 and mod_wsgi (with Nginx infront). Almost all of my new deployments use virtual hosts with different subdomains for each service. If you are using virtual hosts with Nginx it looks like this: server { listen 80; server_name service.albertoconnor.ca; # other settings location / { try_files $uri/index.html $uri.html $uri @cluster; } location @cluster { proxy_pass http://service.albertoconnor.ca; } } Assuming you have defined an upstream server cluster called "service.albertoconnor.ca". If you are doing something by location on the same domain it might look something more like this: server { listen 80; server_name _; # other settings... location /a/ { proxy_pass http://127.0.0.1:8001/; } location / { proxy_pass http://127.0.0.1:8080/; proxy_redirect off; } } The idea is that something else, let's say Apache2, is running on 127.0.0.1:8080, and Django being served by gunicorn is running on 127.0.0.1:8001. So under /a/ the pages will be generated by Django; anywhere else Apache2 takes over. If you try this though, things will go horribly wrong. Besides redirects not working because you … -
Hosting Django under different locations with Nginx and gunicorn
Do you know how Django uses SCRIPT_NAME? It's not often I host different instances of Django under different locations on the same domain. One legacy install has been setup that way for over a year with Apache2 and mod_wsgi (with Nginx infront). Almost all of my new deployments use virtual hosts with different subdomains for each service. If you are using virtual hosts with Nginx it looks like this: server { listen 80; server_name service.albertoconnor.ca; # other settings location / { try_files $uri/index.html $uri.html $uri @cluster; } location @cluster { proxy_pass http://service.albertoconnor.ca; } } Assuming you have defined an upstream server cluster called "service.albertoconnor.ca". If you are doing something by location on the same domain it might look something more like this: server { listen 80; server_name _; # other settings... location /a/ { proxy_pass http://127.0.0.1:8001/; } location / { proxy_pass http://127.0.0.1:8080/; proxy_redirect off; } } The idea is that something else, let's say Apache2, is running on 127.0.0.1:8080, and Django being served by gunicorn is running on 127.0.0.1:8001. So under /a/ the pages will be generated by Django; anywhere else Apache2 takes over. If you try this though, things will go horribly wrong. Besides redirects not working because you … -
Working with the Django admin and legacy databases, pt.3
Working with the Django admin and legacy databases, pt.3 -
Working with the Django admin and legacy databases, pt.2
Working with the Django admin and legacy databases, pt.2 -
Contributing to Django Documentation, Part 1: Generating and Editing Documentation Locally
Contributing to Django Documentation, Part 1: Generating and Editing Documentation Locally -
Image resizing on file uploads. Doing it the easy way.
Image resizing on file uploads. Doing it the easy way. -
Contributing to Django Documentation, Part 2: Submitting A Patch
Contributing to Django Documentation, Part 2: Submitting A Patch -
DjangoCon 2011 Wrap Up
Sadly DjangoCon 2011 has come and gone and while I’m sad that it is over I’m excited to try the things I learned over the conference. There were a number of excellent talks by a number of great speakers but there were a few that stood out to me. Advanced Security Topics – Paul McMillan had a great talk on different security aspects of Django. He showed a couple of critical flaws (that were patched in 1.3.1 and 1.2.7. He also talked about the django-secure application that can help you plug your security holes within your own Django projects. Overall this was my favourite talk due to Paul’s excellent presentation and the quality of the content. Secrets of PostgreSQL Performance – Frank Wiles also had a great talk on performance tuning your PostgreSQL server. While this wasn’t really geared towards Django I thought there were a number of great performance tips that he gave to speed up your DB server. I’ve already followed a few of these tips and have noticed a slight increase in performance. The Story and Tech of Read The Docs – Eric Holscher talked about how Read The Docs came to be and the technology of … -
Quick conferences report: Presentations
My lovely Fiancée, Audrey Roy, was invited to be the opening keynote speaker at both PyCon Australia on Diversity in Python (video) and PyCon New Zealand on Python on the Web.As for me, I managed to get talks into both of those conferences AND DjangoCon US. I co-presented on three of them, and I share all credit for success with my cohorts. The talks I gave at the conferences were (I'll post videos when they get up):Confessions of Joe Developer (PyCon Australia, DjangoCon US)The genesis of this talk was as a lightning talk at I gave at the Hollywood Hackathon. It is a talk about admitting that us mere mortals need to ask questions, take notes, and follow good practices in general. I gave it again at LA Django this summer, extending it to a full length talk complete with lots of technical content. At PyCon Australia I toned down the technical content because I was nervous, and while the response was positive, it could have been much better. So for DjangoCon I ramped up the tech-talk and it worked much better. I've now given the talk 4 times, and I'm leaning towards retiring it. Python Worst Practices (PyCon New Zealand)This talk grew out … -
Try Redis instead
Redis is an invaluable part of software on my server. If you have never tried, or seen it, you should go and install it anyway. You can benefit from Redis just by changing a couple of Django settings. Furthermore, it can replace several uselessly humongous applications you are probably considering right now. -
Testing Web Server Configurations with Fabric and ApacheBench
Load testing a site with ApacheBench is fairly straight forward. Typically you'd just SSH to a machine on the same network as the one you want to test, and run a command like this:ab -n 500 -c 50 http://my.web.server/path/to/page/ The -n argument determines the number of requests to execute, and the -c argument the determines ... -
Testing Web Server Configurations with Fabric and ApacheBench
Load testing a site with ApacheBench is fairly straight forward. Typically you'd just SSH to a machine on the same network as the one you want to test, and run a command like this: -
Contributing to Django Documentation, Part 2: Submitting A Patch
Contributing to Django Documentation, Part 2: Submitting A Patch -
Contributing to Django Documentation, Part 1: Generating and Editing Documentation Locally
Contributing to Django Documentation, Part 1: Generating and Editing Documentation Locally -
Gedit as a Django IDE for Linux
gedit is actually a pretty bad ass IDE for Django web development. -
Por: Marcos Alcazar
gracias! -
Por: jjconti
La verdad no la uso hace rato. -
Por: Marcos Alcazar
juanjo, seguis usando esta app? en code.google desde mediados de 2010 que no hay commits, y encontré en github una que parece ser la misma :S https://github.com/mirumee/dja…… alguna idea o recomendación? -
How to discover unit tests from your project
Within code snippet below implemented very primitive way to collect your unit tests within your project. This is not for real project - I know at least two of fancy discovering tools - it's nose and discover , which do same thing in more convenient and accurate way.I was curious and I did it.# -*- coding: utf-8 -*-import osimport sysimport unittestFILE_ABSPATH = lambda p: os.path.dirname(os.path.abspath(p))COMPARE_DIRS = lambda a, b: FILE_ABSPATH(a) == FILE_ABSPATH(b)def collect_tests(): """ Function to collect tests from whole project """ basedir = os.path.abspath(os.path.dirname(__file__)) main_module = os.path.basename(basedir) test_file = "tests.py" test_dir = "tests" tests = [] new_locals = {} for root, dirs, files in os.walk(basedir): if test_file in files and \ os.path.join(root, test_file) != os.path.abspath(__file__): tests.append(os.path.join(root, test_file)) if os.path.dirname(root) == test_dir: tests.append(root) for test in tests: test_path = test.replace(basedir, '').replace('.py', '') module_name = "%s%s" % (main_module, test_path.replace('/', '.')) __import__(module_name) module = sys.modules[module_name] for cls in dir(module): attr = getattr(module, cls) try: attr.__module__ except AttributeError: continue # we don't want to import anything from current file if COMPARE_DIRS(sys.modules[attr.__module__].__file__, __file__): continue try: if issubclass(attr, unittest.TestCase): new_locals[cls] = attr except TypeError: pass return new_locals# execute testsif __name__ == '__main__': locals().update(collect_tests()) unittest.main() -
Django South : How To Fix The UnknownMigration Exception Error
Django South : How To Fix The UnknownMigration Exception Error -
Language redirects for multilingual sites with Django CMS …
If you have a multilingual website that uses Django CMS probably you have noticed that your pages can be opened both with and without language code in the URL? This leads to duplicate content but this is easy to fix problem. -
Ready Set Sprint – DjangoCon 2011 Sprints
As the conference wraps up the sprints get started. For those that don’t know what a software sprint is: A sprint is a get-together of people involved in a project to give a focused development on the project. Sprints are typically two to seven days long. Sprints have become popular events among some Open Source projects. [wikipedia] DjangoCon 2011 Sprints are being held at Urban Airship in Downtown Portland. So far I’m really impressed with their space. It’s an open style concept with a warehouse feel. The people here have been really nice to host over 100 developers, and the sponsors have even catered it. This year a number of teams have gotten together and are sprinting on different Django related projects. While all of them sounded great I decided to dive into Django’s open tickets to see how I can help. While I’ve only been here a couple of hours I’ve closed one ticket as invalid and added a patch (and documents) to another. It definitely doesn’t take a lot of work to look into Trac. Finding something you can work on is a little more difficult but even adding extra documentation or reviewing tickets can help out the core developers and make … -
DjangoCon 2011 – Making interactive maps for the web
For the last regular talk of DjangoCon US 2011 we’ll be hearing from Zain Memon on “Making interactive maps for the web”. When tasked with displaying geo-data, most developers decide to put some big red markers on an embeddable Google Map and call it a day. If you’re interested in creating maps that are more beautiful, more interactive, and more usable, this talk is for you. Updates Below: 20.05The talk is over now. I’ll update the notes with the slides if they become available. 19.51@zainy just finished up. Great talk, question time… 19.47“When you’re doing this, you’re basically telling your users to fuck off” = Use less datapoints, don’t flood information to your users. 19.43Good maps are… Attractive (Nice looking things do better. People like it more) Readable (Need to make the data pop more than the maps. Pale Dawn or Midnight Commander) Interactive (Hover states. Polygons on more information. Selecting + Filtering) Fast (Tile your map, don’t use a lot of polygons) 19.31The Stack: DB: PostgreSQL + PostGIS ORM: GeoDjango Front-end: TileStache Slippy Map: PolyMaps (GoogleMaps, leaflet) 19.27Map Tiles 256px by 256px images 21 different zoom levels Standard URL scheme (zoom)/(x)/(y).png A collection of map tiles makes up a … -
Заметки с DjangoCon 2011
Выдалось немножко свобдного времени, решил набросать быстрых заметок про DjangoCon 2011 в Потленде. Признание Я не хотел ехать на конференцию сначала. Потому что последние полгода-год всё связанное с Джанго, Питоном, интернетом, да и вообще компьютерами стало навевать на меня тоску. Да и конференции со временем утратили очарование новизны: приехал, послушал доклады, которые лучше было бы прочитать текстом, уехал — только время потерял. Однако потом передумал, потому что… да просто потому что Портленд от меня теперь в трёх-четырёх часах езды. Как теперь потихоньку понимаю, передумал не зря. Похоже, эта конференция пропитана каким-то особым духом Хабанбай-Батыра, и я снова начинаю получать удовольствие от происходящего :-). Я наконец понял, что надо не доклады слушать, а с людьми разговаривать :-). Организация Главный организатор конференции — Стивен Холден, председатель PSF, который на этом деле собаку съел (PyCon тоже он организует). Результат — организация на уровне Just Works® с отсутствием каких бы то ни было заметных проблем: DjangoCon оплачивает всем участникам отельный WiFi, так как сами отели пока ещё не додумались, что это людям несколько важнее трёх комплектов полотенец в одноместном номере. В конференц-залах работает отдельный WiFi, без которого отельная сеть бы загнулась. Он всё же иногда мигает, но довольно редко. В конференцию входит завтрак, обед … -
DjangoCon 2011 – Y’all Wanna Scrape with Us? Content Ain’t a Thing : Web Scraping With Our Favorite Python Libraries
The great talks keep on rolling in with day 3 representing. The next talk is entitled “Y’all Wanna Scrape with Us? Content Ain’t a Thing : Web Scraping With Our Favorite Python Libraries” by Katharine Jarmul. Love or hate them, the top python scraping libraries have some hidden gems and tricks that you can use to enhance, update and diversify your Django models. This talk will teach you more advanced techniques to aggregate content from RSS feeds, Twitter, Tumblr and normal old web sites for your Django projects. Updates Below: 19.09Talk has ended. I’ll try to find the slides and post them. 18.59Interesting links to read. http://www.asheesh.org/note/preso/pycon09-scraping-fun.html goldb.org/pythonwebscraping.html lxml.de lxml.de/lxmlhtml.html#cleaning-up-html scrapy.org 18.55Talking about designer friends… 18.53 re: html == strings == parseable re: Good for “I only care how many comments are on this page” feedparser: follows standard XML rules feedparser: Good for “I only care about RSS feeds” HTMLParser: good base class for your own HTMLParser HTMLParser: Good for “I have an idea about how I want to handle embed tags” 18.52feedparser, HTMLParser, re Sometimes lxml is too much or you have to parse in real-time (think page-load) Sometimes you don’t care about broken pages or trying to parse …