django

South does not recognize models when it is a package

I use South for schema and data migraton for my Django site. I'm happy about using it. One day I converted models.py file to models/__init__py and put some additional models at models/something.py. When I ran python manage.py schemamigration app --auto, I got the Nothing seems to have changed. message despite of the new classes at someth...

Is it possible to create more than one admin interface in Django?

I asked a similar question here. I didn't get many useful answers. May be the question was confusing. So to make it simple, I have different databases used by different users. I want to create a separated admin interface for each of them so that the users will see and modify only the tables related to them. For various reasons multi-db o...

Configuring the Django development server output

Is it possible to configure the output from the Django development server to show the IP address of the client making the request? ...

Django Many to Many in template

This is my template tag in a forloop {{ product.feature_set.all.1.value }} i want to change the number 1 to the forloop.counter. is this posible? like: {{ product.feature_set.all.forloop.counter.value }} It does not work like that, but is there a way to do this? ...

django form subclass for comments

hello im trying to subclass the CommentForm, and I'm not sure if I'm doing it correctly. I'm making those fields hidden, but they aren't rendering that way. from django.contrib.comments.forms import CommentForm from django import forms from django.utils.translation import ungettext, ugettext_lazy as _ class customCommentForm(CommentFor...

Custom multivaluefield isn't displayed in empty form

Hi, I'm trying to build a custom multivaluewidget in my django app. Widget class DayInputWidget(MultiWidget): def __init__(self, attrs=None): widgets = (DayInput(day_name='Mo'), DayInput(day_name='Di'), DayInput(day_name='Mi'), DayInput(day_name='Do'), DayInput(day_name='Fr')) super(DayInputWidget, self).__init__(...

With Django, is there a better way to dynamically import views in urls.py?

Summary: Say I have a project in Django called "devsite" which will be deployed first to a staging project (also called "devsite") and finally to the live codebase (where the project is called "livesite"). During live deployments, I'd have to make manual changes to urls.py in order to import views from the right project. Which means url...

How to make a file which is on local server download-able over HTTP in python?

Framework: Django Language: Python OS: Ubuntu For example, let us assume that I have a file "xyz.pdf" at "/home/username/project/". I have a webpage with download button. So if people click on that download button, the file xyz.pdf should be downloaded. What I have done, Created a webpage with download button with href as "download/...

Getting the SQL from a Django QuerySet

How do I get the SQL that Django will use on the database from a QuerySet object? I'm trying to debug some strange behavior, but I'm not sure what queries are going to the database. Thanks for your help. ...

Summarizing inside a Django template

I have the following template in django, i want to get the totals of the last 2 columns for each of my document objects {% for documento in documentos %} {% for cuenta in documento.cuentasxdocumento_set.all %} <tr {% cycle 'class="gray"' '' %} > {% if forloop.first %} <td>{{ documento.fecha_cr...

Django 1.2 CSRF and HTTP posts from Google Web Toolkit

Hi All, I have a GWT web app working with Django server-side. I recently upgraded Django to 1.2, and am not able to get HTTP posts to work from my GWT app. I am getting this error: CSRF verification failed. Request aborted. Reason given for failure: CSRF token missing or incorrect. I have enabled the csrf middlewares ('dj...

erase template cache

I have a Django app where users can select between 2 interface modes, that mode affect some pages... for those pages I use different templates In urls.py I have something like this: mode = Config.objects.get().mode urlpatterns = patterns('', url(r'^my_url/$', 'custom_view', {'template':'my_template.html', 'mode':mode} ), ) Then m...

Problem with Django using Apache2 (mod_wsgi), Occassionally is "unable to import from module" for no apparent reason

I have put my Django web site up to my web server and have it set up using apache2 and mod_wsgi.. everything works fine most of the time but occasionally it will just give the error that it can't import a module (usually from my views file). However, it's not an issue with that module as it usually works, for example, I will get the erro...

Django with mod_wsgi returns 403 error

Hi! I am trying to use Django with Apache (and mod_wsgi). With the default Django webserver everything was going well, but now I get 403 (access forbidden) error when trying to load the page. I searched previous posts here and read official docs but the solutions there weren't helpful. Here are the lines from my httpd.conf: WSGIScrip...

How to read/write input fields in Django-admin tabular inlines using ajax?

I am looking for ways to dynamically update the inline entries using ajax. i.e. as the user selects an item from the dropdown box, the associated input fields can be populated with data. The views.py part for ajax should be straightforward. But one problem for me is how to get the names of dropdown boxes in js, which can be added on the...

How can I start a python subprocess command on linux shell from within Django web app?

Hi, I have a web app which reads and displays log files generated by python test files. Currently I can launch the python files from cli and it works fine. However I would like to be able to launch python tests from within the application. At the minute I have a "Launch test" button which calls a function in the views.py file def lau...

Django: How to change to success message for update_object?

I'm using the django messages framework for user notifications and update_object to handle saving of forms. When a form is successfully posted the default message is [MyModel] successfully saved or similar. I want to change this message to a custom one ("Your changes were saved"), either for all form posts or for every use of update_obj...

Django ORM with Postgres: rows unexpectedly deleted - Bug?

Hi, I have the problem that objects were unexpectedly deleted and created a minimal example. I dont't know whether it's a bug or if a made a thinking error. The models are something like that: class A(models.Model): related = models.ForeignKey('C', blank = True, null = True) class B(models.Model): title = models.CharField(max...

Two foreign keys and a value in django template

I am a newbie to django, so the question might be dumb, but please feel free to teach me the right way if you know it. I tried googling the issue, but I am still at loss. Here's my problem: I have a class in my model that has two foreign keys: class X(models.Model): name = models.CharField(max_length=30) def __unicode__(self): ...

Django on Google App Engine: debug queries to datastore

What is the best way to get something similar to django-debug-toolbar working on Google App Engine? At least I want to log all GQL at my local development environment. I am using django-nonrel + djangoappengine + djangotoolbox. I tried: debug-toolbar - does not work http://popcnt.org/2008/05/google-app-engine-tips.html - link to the c...