django

How can I get a total count of a model's related objects and the model's children's related objects?

In Django, I've got a Checkout model, which is a ticket for somebody checking out equipment. I've also got an OrganizationalUnit model that the Checkout model relates to (via ForeignKey), as the person on the checkout belongs to an OrganizationalUnit on our campus. The OrganizationalUnit has a self relation, so several OUs can be the ch...

Django: where is the code that prints the "+" icon close to a foreign key?

I cannot find which part of code print the "+" that is close to every foreign key field. In fieldset.html there is only the call to {{ field.field }}, but in the file django/forms/widgets.py the code that prints the select, doesn't contain that code, so I suppose that there is a piece of code that manage the foreign key: where is it? ...

Django reset not dropping tables

I just migrated my dev environment from Ubuntu Linux to Mac OSX snow leopard. All of this was working on Linux. On both, I have used MySQL for Django's db. Django's reset function is not issuing drop commands for all of my app's models. Here is my models.py (with the Forum and User object fields removed for brevity): from django.db imp...

Problem with jQuery Ajax...how do I update two DIVs with ONE ajax call?

function ajaxCall(query){ $.ajax({ method:"get", url:"/main/", data:"q="+query, beforeSend:function() {}, success:function(html){ $("#main").html(html); } }); }; This is the entire code that will populate #main: <p>{{ num_results }}, you just searched for {{ query }}</p> Suppose I have another div...

Google App Engine Patch - How to use stylesheets?

Struggling with an install of GAE-Patch and using my stylesheets. My settings.py has the following lines included already, but the media generator is not compiling and packaging it properly: 'combined-%(LANGUAGE_DIR)s.css': ( 'global/look.css', ), 'combined-%(LANGUAGE_DIR)s.css': ( 'global/base-%(LANGUAGE_DIR...

Conditionally Require Only One Field In Django Model Form

Anyway to make a field conditionally required based on whether or not another field in the same form has been filled out? If field1 has no data, but field2 does form is valid. If field1 has no data and field2 has no data form is invalid Not looking for any javascript solutions. I feel as it should be solved with django for...

[django] How to set tabindex on forms fields?

How do i set the html attribute "tabindex" on form fields? My template currently looks like.. <div class="field text username"> <label>Email Address</label> {{ form.email }} </div> ...

Displaying dictionary value in django template

All, I have the following in my views.py def getgradeform(request): id1=request.user.get_pf().id sc=Sc.objects.filter(id=id1) logging.debug(sc) logging.debug("++++") dict={} dict.update({'sc': sc}) return render_to_response('content/add.html',dict) Logging.debug gives an output as [<sc: Robert>] My question is t...

How can I access the WSGIScriptAlias from my django settings file?

I have this line in my wsgi.conf file: WSGIScriptAlias /trunk "c:/app/trunk/app.wsgi" Inside of my django settings file, I need to know the alias "/trunk" to get LOGIN_URL to work properly. How can I retrieve this value from my apache settings? Thanks! Pete ...

Django-mptt completely buggy or am I doing it wrong?

I'm attempting to use django-mptt with very little luck. This is with Python2.5, windows, sqlite3, Django 1.2pre , django-mptt latest from svn. The code: model: class Node(models.Model): name = models.CharField(max_length=20, blank=True) parent = models.ForeignKey('self', null=True, blank=True, related_name='children') ...

what is this code mean in django.

<a href={% url home %}></a> i can't find {% url %} in django api ...

Looking for a comprehensive guide to setting up custom authentication backends in Django, or pointers

I'm trying to set up a custom backend that queries another database, for which I have created a model in the system. It uses its own rules (email instead of username, and a differently salted/hashed password) so I can't use built in authentication. I've set up a custom authentication backend like so: class BlahBlahBackend: def chec...

django multiple installation problem

Have django serving different settings file & database based on subdomains. The virtual host entries are manually added to apache. There are currently two subdomains with different databases. First one is working okay, the second one is not displaying any css/images. Apache configuration is as, there are two of them <VirtualHost *:8...

django: filtering a object-list

I've got a list of objects (properties for rent, in this case) that I am listing, the list needs to be filterable by a handful of criteria (max price, area, n_bedrooms ...) and I figured I could do it like this: (r'^price:(?P<price_min>\d+)?-(?P<price_max>\d+)?/$', property_list) This works, and allows urls like price:300-600/ to do t...

python dictionary question

All, This is the request from the template that i get u'subjects': [u'7', u'4', u'5', u'3', u'2', u'1'] In my views how to extract the values like 7 4 5 3 2 1 How do i extract the above sequence from new_subjects=request.POST.get('subjects') Thanks. ...

Django: override RelatedFieldWidgetWrapper

I want to change the way that the "+" icon for the foreign key in the admin site is shown. I found that the widget that prints the code is RelatedFieldWidgetWrapper that is in django/contrib/admin/widgets.py. So I wrote my version of this class and I changed its render function. But now how can I use it? I mean... in the definition of...

How do I add a custom column with a hyperlink in the django admin interface?

I have a django admin interface and in the model listing I want a custom column that will be a hyperlink using one of the fields values. Basically one of the models' fields is a url and i'd like the column to have that URL in a clickable hyperlink. This link will need to have additional URL prepended to it as its a relative path in the...

Django Haystack exact filtering

I have a haystack search which has the following SearchIndex: class GrantIndex(indexes.SearchIndex): """ This provides the search index for the Grant application. """ text = indexes.CharField(document=True, use_template=True) year = indexes.IntegerField(model_attr='year__year') date = indexes.DateField(model_att...

How to create a django model field that has a default value if ever set to null

Given a model class Template(models.Model): colour = models.CharField(default="red", blank = True, null=True) How can I arrange it so that any access to colour either returns the value stored in the field, or if the field is blank/null then it returns red? The default=red will put "red" in the field when it's first created, but i...

Query for a ManytoMany Field with Through in Django

Hi All, I have a models in Django that are something like this: class Classification(models.Model): name = models.CharField(choices=class_choices) ... class Activity(models.Model): name = models.CharField(max_length=300) fee = models.ManyToManyField(Classification, through='Fee') ... class Fee(models.Model): activity = m...