This is a work in progress, answering questions that do indeed get asked frequently on the [irc://irc.freenode.net/django Django IRC channel] (#django on irc.freenode.net). Feel free to contribute, but try to keep it clear and concise. Please don't editorialize. There's also a helpful [https://docs.djangoproject.com/en/dev/faq/ official FAQ]. [[TOC]] = General Tips = * When asking for help in the channel, '''be as specific as possible''' in your request. "It doesn't work" is not sufficiently specific! [http://code.djangoproject.com/wiki/IrcFAQ#MoreInformationPlease (More advice on this)] * Showing actual code is useful. For code longer than a line or two, use the pastebin: http://dpaste.com/ * Django has very good [https://docs.djangoproject.com/ documentation]. Make sure you've checked it! * Try [http://code.djangoproject.com/search?q=&wiki=on&ticket=on searching in Trac]. * Can't join the IRC channel without registering with nickserv? What's this? [http://freenode.net/kb/answer/registration See here]. * General questions about IRC or Freenode? Try the [http://freenode.net/kb/all Freenode FAQ]. * Don't ask to ask, just ask! = Python questions = == How do I learn Python if I'm new to programming? == #LearnPython1 * http://openbookproject.net/thinkcs/python/english2e/ * http://wiki.python.org/moin/BeginnersGuide/NonProgrammers == How do I learn Python if I'm '''not''' new to programming? == #LearnPython2 * http://docs.python.org/tut/tut.html * http://www.diveintopython.net/ * http://wiki.python.org/moin/BeginnersGuide/Programmers == Are there any books on Python? == #PythonBooks Yes. http://wiki.python.org/moin/PythonBooks == What's this about Python Path? Django is complaining it can't import stuff. == #PythonPath This is an important concept to understand in order to use Python/Django happily. [http://docs.python.org/tut/node8.html#SECTION008120000000000000000 The official Python tutorial explains it pretty well.] = Installing and Deploying Django = #InstallAndDeploy == When will the next release be out? -or- When will feature X be done? == #AreWeThereYet "When it's done" is the short answer. Reading the [http://docs.djangoproject.com/en/dev/internals/release-process/ release process documentation] is recommended if you're curious. Searching or browsing the developer list (http://groups.google.com/group/django-developers/) can also be informative. If you feel like pitching in, great! See the [https://docs.djangoproject.com/en/dev/internals/contributing/ Contributing] docs. == I'm trying to install Django on Windows and something is weird. == #Windows Have you looked here? http://code.djangoproject.com/wiki/WindowsInstall = Troubleshooting = General problem-solving advice: Test the things you think are true until you find the one that isn't. == "It doesn't work!" or "I got an error!" == #MoreInformationPlease If you want good help you'll need to give a little more information. Keep in mind that we probably know little if anything about your project, your level of experience with Python and Django, etc. Did it work before? Or is this something you're trying for the first time? Does it raise an error? Die silently? Give unexpected output? If you want help with an error, try to give us 1) the code that produced the error and 2) the error traceback itself. When asking for help, make sure you describe 1) what you did, 2) what you expected to happen, and 3) what actually happened. [http://dpaste.com/ Pasting] your code is often helpful. Don't forget to set the syntax when you paste so that the proper colorizing is applied -- that makes it easier for us to read your stuff. The Django debug page has a handy button for automatically sharing traceback code. == My media/static files (CSS, images, etc.) aren't showing up. == #MediaTroubles Django doesn't serve static media automatically (exception: admin app running under the dev server). If you're running the development server, read this: https://docs.djangoproject.com/en/dev/howto/static-files/ If you're running Apache, read this: https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/#serving-files Confusingly, though the {{{MEDIA_*}}} settings in your settings.py file refer to ''your'' media files, not the Admin app's media files, the default path for Admin app media ({{{ADMIN_MEDIA_PREFIX}}}) is set to "/media/". Many Django users change this to "/admin_media/" or "/adminmedia/" to reduce potential confusion. == Why isn't my template tag or filter working? == #TemplateTagsAndFilters Of course, you've read the [https://docs.djangoproject.com/en/dev/howto/custom-template-tags/ documentation], right? Here's a brief list of things to check first before asking: * your filter/tag should be in a file named something like `[yourfilterlibraryname].py` (e.g. if it was `myfilter.py`, you'll use `{% load myfilter %}` in the template) * that file exists in a directory named `templatetags` and this directory is sitting inside of an ''app'' directory (e.g. `.../projectdir/appdir/templatetags`) * an empty file named `__init__.py` also exists in the `templatetags` directory (this makes the directory into a python module which can be imported) * in your project `settings.py`, the application where the `templatetags` directory is contained is in `INSTALLED_APPS` * each filter or tag in your library is decorated correctly (see docs) * neither your library nor anything it imports raises any exceptions (for example, if your library tries to import something that's not installed, and so raises an `ImportError`, that will prevent Django from seeing it) * restart the webserver (yes, even if you're using runserver) = How to do Stuff = == How do I create a subclass of an existing model? == #ModelInheritance If you're using model inheritance (aka model subclassing), make sure you've [http://docs.djangoproject.com/en/dev/topics/db/models/#model-inheritance read the documentation] and understand the difference between the '''abstract base class''' and '''multi-table''' inheritance options. The latter can be confusing to newcomers because an instance of a parent class will also contain, on an attribute named after a child class, that same object represented as an instance of the child class. Got that? An established mechanism for adding additional information to Django `User` objects without subclassing is known as "profiles"; you can [http://www.djangobook.com/en/1.0/chapter12/#s-profiles read about it in the Definitive Guide]. For an important alternatve viewpoint on model subclassing, see: http://www.b-list.org/weblog/2007/02/20/about-model-subclassing == I think Ajax is awesome! How do I do Ajax with Django? == #Ajax Choose your favorite excellent Javascript library and go to it. Django provides serializers to JSON and XML, which you can read about in the [https://docs.djangoproject.com/en/dev/topics/serialization/ documentation]. Also see this helpful article from James Bennett (with bonus anti-Javascript-helpers rant!): http://www.b-list.org/weblog/2006/07/02/django-and-ajax == How do I customise the admin interface so all logged-in users can use it without screwing up anything? == #AllUsersAdmin The admin interface is designed for use by trusted site staff, not by any user -- if you don't trust a user with the level of access the admin application provides, you'll need to provide non-admin views for the actions you'd like to allow them to take. == I want to have some code run when the server/application starts. How do I do that? == #ServerStartup Both mod_python and FastCGI are structured in such a way that there's no such thing as "application startup" or "server startup"; the best solution is to place your "startup" code somewhere that's guaranteed to be imported early on in the request/response cycle (the `__init__.py` file of your project, or of a specific application you're using, can be a good place, because Python will execute code found there the first time it has to import the module; just be aware that referencing the same module in different ways, say by doing `from myproject.myapp import foo` in one place, and `from myapp import foo` in another, will cause that code to be executed once for each different way you import it). == How do I use Django in a shell script? == #Shell http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/ == I want to repeat a bit of dynamic information (eg from a database) on many views. Do I have to change every view? == No, you can use an [http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags inclusion tag]. == Can I do greater than or less than in the Django template language? == There are no default if greater or if less type tags. But you can find them in the [http://code.google.com/p/django-template-utils/ django-template-utils] project. = Resources, Tools, and Code = #Resources == Which runs faster, X or Y? == #WhichIsFaster This is a tempting question to ask in hopes of getting a quick answer on the "best" way to do something. Unfortunately, the answer is generally "profile your app and see". Performance tuning always starts with a baseline. If you haven't measured current performance to get a baseline, you aren't in a position to do much with the answer to the question anyway. You can learn more about Python's handy profiling tools in the [http://docs.python.org/lib/profile.html Python documentation]. == Where can I find example code and/or reusable apps? == #ShowMeTheCode * http://djangosnippets.org/ * http://code.djangoproject.com/browser/djangoproject.com/django_website * http://www.djangosites.org/with-source/ * http://www.djangopackages.com/ * http://pinaxproject.com/ * http://code.google.com/hosting/search?q=label:django * http://github.com/search?q=django = IRC and djangoproject.com Miscellany = #Misc == The ticket tracker thinks I'm a spammer! == #TracTrouble You need to register: http://www.djangoproject.com/accounts/register/ == Is there a channel bot? == #DjangoBot Yes, it's very handy -- see DjangoBot for more.