django

How do you add a model method to an existing class within an interactive session (in iPython)?

I have a basic model: class Person(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) state = USStateField() I start up an iPython session with: $ python manage.py shell >>> from app.models import Person How do I add this model method within the iPython session? >>> ...

How can I use a Django template tag for greater than on a forloop.counter?

I want the effect of an "ifgt" template tag in a django template page: {%ifgt forloop.counter 10%}<!---special greater than 10 code--!>{%endif%} ...

Setting up cache with Django to work around the "page has expired" IE problem

I have got a familiar problem. I am using Django-0.97, and cannot upgrade -- though the version of Django being used should not play any part in the cause of the problem. I have a search view that presents a form to the user, and, on submission of the form via POST, performs heavy computations and displays a list of items that are gener...

How can I get the reverse url for a Django Flatpages template

How can I get the reverse url for a Django Flatpages template ...

Python value unpacking error

I'm building a per-user file browsing/uploading application using Django and when I run this function def walkdeep(request, path): path, dirs, files = walktoo('/home/damon/walktemp/%s' % path) return render_to_response('walk.html', { 'path' : path[0], 'dirs' : path[1], 'files' : path[2], }, context_i...

Django url tag gives wrong values

My URLconf has: url(r'^view-item$', 'appname.views.view_item', name='view-item'), Now, if I go to http://myhost/path_to_django_app/view-item/, it works. However, {% url view-item %} returns '/view-item/'. Why is it doing this? This problem occurred when I moved the application to a new server, so I'm guessing something must be conf...

Using URLS that accept slashes as part of the parameter in Django

Is there a way in Django to accept 'n' parameters which are delimited by a '/' (forward slash)? I was thinking this may work, but it does not. Django still recognizes forward slashes as delimiters. (r'^(?P<path>[-\w]+/)$', 'some.view', {}), ...

Virtualenv with Eclipse (Galileo)

Does anybody have directions for getting Eclipse (Galileo), PyDev, and Virtualenv working together? I'm specifically trying to run Pinax but any instructions are fine. I thought I had it (and even blogged everything but the final step - interactive debugging) and still there is no solution. I'm specifically on OS X but any answer shou...

Import most recent wordpress blog post from rss into django site

Is there a third party django app for eaily importing rss items (specifically wordpress blog posts) in google-code? I've been searching for 20 minutes and can't pull anything up. Ideally the end result would be something like: def news(request): most_recent_post = ??? #get most recent rss post from http://feeds.feedburner.com/codi...

What are the best books and resources for learning to develop, deploy and/or host Django?

I'm a newbie on the Django scene coming from an ASP.NET C# background. I'm looking for some good resources to help me learn the ins and outs of Django/Python. Any recommendations? ...

How to make easy_install expand a package into directories rather than a single egg file?

How exactly do I configure my setup.py file so that when someone runs easy_install the package gets expanded into \site-packages\ as a directory, rather than remaining inside an egg. The issue I'm encountering is that one of the django apps I've created won't auto-detect if it resides inside an egg. EDIT: For example, if I type easy_in...

Django Forms Template design classes

Django Forms framework is excellent and renders the entire form by just the following. {{ form.as_p }} For a registration form, it converts above into: <p><label for="id_username">Username:</label> <input id="id_username" type="text" name="username" maxlength="30" /> Required. 30 characters or fewer. Alphanumeric characters only (let...

The Interpreter used by django application

Hi, I have hosted my django application with apache and mod_python. When i was going through the mod_python documentation, I found that there is a way to know under which interpreter my application is running (By using req.interpreter). I tried to check that in django, by checking request object. But I couldn't figure out(request.inter...

What is the DRY way to configure different log file locations for different settings?

I am using python's logging module in a django project. I am performing the basic logging configuration in my settings.py file. Something like this: import logging import logging.handlers logger = logging.getLogger('project_logger') logger.setLevel(logging.INFO) LOG_FILENAME = '/path/to/log/file/in/development/environment' handler =...

Alternative to django form processing boilerplate?

The suggested pattern for processing a form in a view seems overly complex and non-DRY to me: def contact(request): if request.method == 'POST': # If the form has been submitted... form = ContactForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass # Process th...

Rendering common session information in every view

I'd like to output some information that depends on session data in Django. Let's take a "Login" / "Logged in as | Logout" fragment for example. It depends on my request.session['user']. Of course I can put a user object in the context every time I render a page and then switch on {% if user %}, but that seems to break DRY idea - I wou...

To get PYTHONPATH correct in running Django

I run at a cloned Django repository python manage.py runserver I get Traceback (most recent call last): File "manage.py", line 2, in <module> from django.core.management import execute_manager ImportError: No module named django.core.management The problem is in my PYTHONPATH according to MacPorts' IRC. I run ls -l $(which ...

common components in django

Hi all, I know i can have common stuff like this in django <html> {% include "header.html" %} <div id = 'content'> blah </div> {% include "footer.html" %} </html> but it seems i need to pass data footer.html and header.html every time i include these pages? Thanks ...

Signals registered more than once in django1.1 testserver

I've defined a signal handler function in my models.py file. At the bottom of that file, I use signals.post_save.connect(myhandler, sender=myclass) as recommended in the docs at http://docs.djangoproject.com/en/dev/topics/signals/. However, when I run the test server, simple print-statement debugging shows that the models.py file gets i...

$_SERVER vs. WSGI environ parameter

I'm designing a site. It is in a very early stage, and I have to make a decision whether or not to use a SingleSignOn service provided by the server. (it's a campus site, and more and more sites are using SSO here, so generally it's a good idea). The target platform is most probably going to be django via mod_wsgi. However, any documenta...