python - Favorite Django Tips & Features Context processors are awesome. Say you have a different user model and you want to include that in every response. Instead of doing this: def myview(request, arg, arg2=None, template='my/template.html'): ''' My view... ''' response = dict() myuser = MyUser.objects.get(user=request.user) response['my_user'] = myuser ... return render_to_response(template, response, context_instance=RequestContext(request)) Context processes give you the ability to pass any variable to your templates. I typically put mine in 'my_project/apps/core/context.py:
- Luc Stepniewski's Blog In a Django project, I have a template that is used by two urls, which is quite common (generic views, using ‘create_object’ and ‘update_object’). The problem is that I had to add a supplementary menu just when the template is loaded from the ‘update’ generic view, and not from the ‘create’ generic view. Making the difference between the two urls calls at the template level is a problem because it’s managed by generic views, so the same template is used. Anyways, there are several possibilities:
Pinax : Package List
Confusion in Django admin, static and media files Static files are files needed by your applications that server can serve without modifications, like custom JS scripts, icons, applets, etc. The best way to use it is to place static files in a "static" folder in each of your app's folder. Like this, the test server will find them there, and if you deploy on a production server, you'll just have to run python manage.py collectstatic to copy them all in the root static folder defined in you settings.py Media files are those uploaded by the users of your applications, like avatar's pics, etc.
From Designer to Django’er in Six Weeks — djangocon-2011-notes v0.0.1 documentation Start out on the right foot:If you can, spend 100% of your time on your project.Have a large savings account, low debt.Make sure you’re having fun.Success can be just launching the app.Be focused and optimistic before you start. Cofounders are awesome, but no cofounder is better than the wrong cofounder. Launch as fast as possible:What can you take out?Launch tiny bits to keep motivated.Work on the hard stuff first.Spent as little time as possible on learning, as much on building.Launch with bad code (really, it’s okay).Have a plan for monetizationDon’t be forever alone:Talk to friends.Don’t be prideful; accept help.NDAs suck.Surround yourself with good people & resources.
A Guide to Testing in Django - Toast Driven For many people, testing their Django applications is a mystery. They hear that they should be testing their code but often have no clue how to get started. And when they hit the testing docs, they find a deep dive on what functionality is available, but no guidance on how to implement. This is the first in a series of blog posts to try to help alleviate this & get everyone on the testing bandwagon.
There are quite a few great little tricks and tips one could use on their Django projects that would speed up development and save many headaches in the long run. From basic to obscure, these tips can help any skill-level of programmer become more adept with Django and all it's glory. Django is an excellent framework for Python. 10 Insanely Useful Django Tips
Tutorials General Tutorials ¶ Tutorials on Specific Topics: ¶ Note: Django snippets has plenty of code 'snippets' which do all sorts of useful things too. Setup/Configurations ¶ Testing Django ¶
Django Projects — Django Best Practices Location Templates typically live in one of two places, inside the application or at the root level of a project. We recommend keeping all your templates in the project template directory unless you plan on including your application in multiple projects (or developing it as a open source “reusable” application). In that case, it can be helpful to ship with a set of sample templates in the application, allowing it to work out-of-the-box or serving as an example for other developers.
How and why to use django-mongokit (aka. Django to MongoDB) - Peterbe.com Here I'm going to explain how to combine Django and MongoDB using MongoKit and django-mongokit. MongoDB is a document store built for high speed and high concurrency with a very good redundancy story. It's an alternative to relational databases (e.g. MySQL) that is what Django is tightly coupled with in it's ORM (Object Relation Mapping) and what it's called now is ODM (Object Document Mapping) in lack of a better acronym. That's where MongoKit comes in. It's written in Python and it connects to the MongoDB database using a library called pymongo and it turns data from the MongoDB and turns it into instances of classes you have defined.
Django by Example: Django Tutorials - Django by Example
current community your communities Sign up or log in to customize your list. more stack exchange communities Stack Exchange Django - Static file not found
I've Googled, but have not found any really organized and layman-friendly overview, which is why I came here. I know how to get python/django working on my computer (PC or Mac) and have developed simple test apps using django's built-in dev server and a mysql back-end. So I can get things to work and don't need help on installing stuff. But as a coding hobbyist, I don't know how to set up a pro workflow. I don't know best practices on how to setup and maintain a dev and production environment, how to efficiently publish to production, how to integrate all that into a version control system (i.e., git), basically anything that a pro coder at a startup would take for granted as "the way to do things". (48) What does an ideal Django workflow setup look like
Welcome to the online version of The Django Book, a free book about the Django Web framework for the Python programming language. A warning about this edition The community edition of The Django Book is in transition.
Five Days to a Django Web App: Day Three, Coding - The Daily Build Thanks for coming back for Day Three! [Note: Sorry this post is a day late. It was all ready to go late yesterday, but some of the code included below triggered a bug either in WordPress or ScribeFire and the whole post got mangled. I managed to resurrect it today from drafts, and I think it's coherent, but if you find some problem with it please drop me a note.] Progress So Far
Documentation de Django — Documentation de Django 1.1.1
This is a collection of patterns which we have found occurring commonly with Django. All of these either make collaboration easier, coding simpler or code more maintainable. None of them are design patterns in the sense of GoF design patterns. Index — Django Design Patterns
Billets publiés en 2012 ★ Résolutions : rediriger, économiser et débattre Billets publiés en 2011 Billets publiés en 2010