NotesEspecially for side projects with limited traffic requirements and scaling concerns, the promise of SQLite is that it can remove a lot of ongoing hassles. Without a separate database, cache, or queue, there is less network traffic (because the SQLite file is local), and less servers to manage, maintain, and backup.Unfurl
NotesIf youâre using Amazon S3 to store your websiteâs files, and you want some of them to be private, only accessible to certain users, and particularly if youâre using Django, hereâs how.
FeedUnfurl
NotesSimilar to Profiling Middleware, but uses cProfile instead of hotshot.
Append ?prof to the URL to see profiling output instead of page output. FeedUnfurl
NotesTrust is a Django app for managing the trust levels of your users. All users start out with a default amount of trust, and as they do good things they gain trust, and as they do bad things they lose trust.Unfurl
NotesIn the twelve-factor model, all configuraiton variables are stored in the OS environment. This makes updating settings in the deployed application way easier but what to do in local development?Unfurl
NotesSingle domain web sites are so boring. Custom subdomains are a great way to provide customization for customers of SaaS products and to differentiate content without resorting to long URL paths. Implementing subdomain support in a web application isnâtUnfurl
NotesLike Apacheâs mod_xsendfile, Nginxâs X-Accel module provides for internal redirects. An x-accel-redirct is internal because instead of redirecting the clientâs request to another URL, it redirects the location of Nginxâs request to another resource.Unfurl
NotesIâve been using Travis-CI for a while now. Both my personal projects, and even several of the libraries we maintain at DISQUS rely on it for Continuous Integration. I figured it was about time to confess my undenying love for Travis, and throw up some notes about the defaults we use in our projects.Unfurl
NotesSometimes you canât avoid using HTTPS right starting from development (such as for developing Facebook canvas applications). You can setup Apache on your local machine and go through a bunch of trouble setting up your domain and setting up the certificate etc but thereâs an easy way of using Djangoâs python manage.py runserver to work with HTTPS.Unfurl
NotesSo I started wondering - what if we just created a real user for every person who visited the site? Django already has support for creating users with unusable passwords - so if we just create a user with an unusable password every time a new person comes along, log them in, and then at some future point (presumably once they've fallen in love with your site) they can set themselves up with a real username and password. And as a bonus, all that data that they created while messing about with the site sticks around, and carries over into their 'real' user.Unfurl
NotesIf youâre prototyping a new project, or if youâre a start-up and need to ship something, or if youâre just one person working on a little app with a few (even a few tens of thousands) of users, odds are that none of those benefits are worth losing the nice stuff Django gives you, or the time it takes to build APIs (even using existing apps to do it) or abstraction layers between the silos.FeedUnfurl
NotesAlso, as part of a plan to re-emphasize a digital and local focus, Mediaphormedia, which created the internationally accepted Django Web framework, released 10 employees and will phase out its commercial software operations to serve only the companyâs specific internal needs. The change was announced to employees and clients earlier this week.Unfurl
NotesMaking strings in templates localizable is exceptionally easy. Making strings in Python localizable is a little more complicated. The short answer, though, is just wrap the string in _().Unfurl
NotesThe key parts are the get_urls function and the admin_update_feeds view. The get_urls method returns the urls for this admin to which we are adding our custom view. The custom view does the updating of the lifestream feeds and returns the user to the Item model's changelist view. We get the url for that view by calling reverse with the pattern "<namespace>:<app>_<model>_changelist" which in our case is "admin:lifestream_item_changelist" since the django admin uses the admin namespace.Unfurl
NotesWebDAV implemented as a Django application. The motivation for this project is to allow authentication of users against Django's contrib.auth system, while also exporting different directories per user. Many Django tools and app can be combined with this such as django-digest etc. to provide a powerful WebDAV server. Unfurl
Notes But what if you're allowing your users to create their own survey questions, so that you don't know ahead of time how many answers you'll need? Luckily, you can add fields to the form as you're constructing it, in addition to specifying them as class attributes. If you have all your survey questions in a list (let's call it questions just to be confusing), you could create a Survey class that looks like this: Unfurl
NotesBelow is example code that allows you to resize images using Djangoâs models.ImageField and PIL library. Hopefully this saves someone some time as it took me a few hours to come up with a solution.Unfurl
Notes"As my Django sites get larger and larger, there inevitably comes a point where I want access to the current request from deep inside some function that doesn't have the request object. The latest reason was that I wanted a model class helper to have access to the session so it could access some debug flags.<br />
<br />
"FeedUnfurl
Notes"This is exactly the kind of cross-cutting concern (note the use of a signal publisher for notification!) that would be better handled with a signal from the microblogging app. Perhaps the app could have published âtweet receivedâ as a signal, with an optional âmodule for common associated applicationsâ dispatching that event to logging, activity streams, notifications or whatever as available. The presence of explicit publication would have signaled to any developer to look for subscribers, so I donât think this is a dangerous case of unlabeled subroutines and the potential for spaghetti code that goes with it. Most Django apps are small silos of code; it would not have been onerous to separate out and isolate this cross-cutting concern from the rest of the microblogging applicationâs functionality."Unfurl
Notes"If you use a source control system (CVS, SVN, ...), or want to publish your application on the web, it may be a good idea to move sensitive or machine/user specific settings like database passwords and such out of the main settings.py file. "Unfurl
Notes"A template extension system for marking points in your django templates as 'plugin-points', and providing plugins which inject themselves at those points. Multiple applications can be injected at each plugin point, and 'registered' plugin-points can have the visibility, order and access of the plugins controlled via DB models. This control can be done on a site wide or per-user basis. Thus you can allow users to add, remove, and reorder the plugins on their profile page for instance."FeedUnfurl
Notes"Sore Thumb is a Python module to process images in to thumbnails, and apply effects that may be difficult or impossible to do in the browser."Unfurl
Notes"Here at Sourcefabric we have been looking in to what software stack to use for our next web products. This discussion used to be (oh, 5-10 years ago) a lot simpler, mainly involving choosing an operating systems, a language, and a database. But now itâs about higher-level things like out-of-the-box support for commenting, activity streams, ajax, cloud storage, deployment tools, scalability, geolocation, tagging, RESTful interfaces, search, twitter, facebook, and a whole lot more. Users and customers are starting to expect all of this built into any web application you build. Building applications these days is largely about integrating a large number of existing technologies instead of building something from scratch."Unfurl
Notes"Freshen is an acceptance testing framework for Python, inspired by Cucumber and has the same goal: make BDD fun, but using Python instead of Ruby. Freshen uses the same syntax of Cucumber (Gherkin Syntax) and runs as a plugin of Nose, a powerful Python tool for using daily when you with TDD"Unfurl
Notes"It's a clever solution because you end up defining what doesn't get cached instead of what does get cached. It's a sideways way of looking at the problem -- sort of like how Django's template inheritance system defines which parts of the page change instead of defining server-side includes of the common bits."Unfurl
Notes"Start changing one single line of code in an application build on top of Drupal or ezPublish, to name only the two major ones, and you are in trouble. The moment you need something that is not natively supported, you enter the Dark Zone of CMS hell. You are going to spend a lot of money on development. You will never see the end of the tunnel. That is, until someone says, a few years from now, âDo we need all that crap? Letâs build something that fits our needs and that actually worksâ.Given number of available open-source CMS solutions, building one on your own sounds like a stupid idea. But if your website is 50% content management and 50% something else, you probably need to start with a web application framework like symfony or Django, rather than a CMS. These frameworks provide plugins that do part of the Content Management job already, so creating a CMS today is like assembling Lego bricks to build something that exactly fits your needs."Unfurl
Notes"In my humble opinion, this kind of âdumbed-downâ templating results in only one thing: more lines of code in the application modules, lines of code that are really only about presentation, and should be in the templates."Unfurl
Notes"After several Java (J2EE) development jobs Leah Culver wanted to learn a new programming language. Following a friendâs suggestion, she began âplaying aroundâ with a Python Web framework called Django last January."Unfurl
Notes"For the second entry in my series of posts about the Django template language (part one was an introduction), I've chosen to focus on its inheritance capability, which is probably its most powerful feature."Unfurl