django

Django: Filtering or displaying a model method in Django Admin

I have a model with an expiration DateField. I want to set up an Admin filter that will allow the user to toggle between "Not Expired" and "Any". The model method is quite a simple Date comparison, no problem. However assigning this as a field or filter parameter in the AdminForm is not automatic. Is such a thing possible, and if not...

how to allow RSS aggregators to use feeds available only for logged-in users?

I want to have RSS feeds in my Django application, which should be viewable only by a logged-in user. I want to allow users to add these RSS feeds to all aggregators, so I would need something which would work like this: supply the feed URL with a token, for example: http://example.com/feed/rss&token=AeYQtFjQfjU5m so that token will...

Django 1.1.1: How should I store an empty IP address using PostgreSQL?

I am writing a Django application that stores IP addresses with optional routing information. One of the fields for the IP model I have created is nexthop (for next-hop routes), which will usually be empty. Originally we intended to use MySQL, but now project requirements have changed to use PostgreSQL. Here is a stripped down version...

Django: Overriding form save?

Is there any documentation on this? I couldn't dig any up. I have a custom ModelForm for creating articles. Whenever I use this form, I pass in an article instance so that I can automatically set the author: article = Article(author=req.user) form = ArticleForm(req.POST, instance=article) How do I access this instance/article...

Customizing django-comments

So, I'm using django.contrib.comments. I've installed it OK but rather than the unwieldy default comment form, I'd like to use a custom form template that just shows a textarea and submit button. The rationale behind this is that user only see the form if they area already authenticated, and I'd like the keep the form simple and pick up...

Problem with import curses.ascii

Hi, I am trying from curses.ascii import * to django project, but I get: No module named _curses, I am using Python 2.5, any suggestion? Anyway I only need isalpha() function to use.... ...

is there a difference between MyModel.objects.filter(pk=1) and MyModel.objects.get(pk=1) ?

Is there a difference in the result between: MyModel.objects.filter(pk=1) and MyModel.objects.get(pk=1) If there is no difference, then why does the .get() method exist? ...

What is wrong with this loop in my Django view/template?

I hate to ask here but I am stumped and so were the guys in irc. The template does not display the contents of the list I am trying to display. {{ bet }} alone also displays no values. What am I missing? Template: {% for bet in bets %} <tr> <td><div>{{ bet.game_num }}</div></td> <td><div>{{ bet.home_team }}</div></td> <t...

WMD Preview Doesn't Match Output

I am using WMD in a google app situation whereby the site administrator can update the pages of the site and the users see the information. The preview function is working fine and I can see the text the way I want it to appear, but when I am in the users section, the markdown is being returned without the formatting - how can i fix th...

Assigning a group while adding user in django-admin

In my application, I have models that have the Users model as a Foreign key, eg: class Doctor(models.Model): username=models.ForeignKey(User, unique=True) ... In the admin site, when adding a new Doctor, I have the option of adding a new User next to the username field. This is exactly what I want, but in the dialog that opens, it...

MySQL to PostgreSQL: GROUP BY issues.

So I decided to try out PostgreSQL instead of MySQL but I am having some slight conversion problems. This was a query of mine that samples data from four tables and spit them out all in on result. I am at a loss of how to convey this in PostgreSQL and specifically in Django but I am leaving that for another quesiton so bonus points if ...

Display from a table using Django

Hi all, Can you please give me a small piece of code where we display data from a table if any in Django..... Please point me to a code that goes into views.py and template/index.html to diaply the table............. Thanks.... ...

Performing PostgreSQL LEFT OUTER JOINS and CASEs in Django.

So I have a fairly involved sql query here. SELECT links_link.id, links_link.created, links_link.url, links_link.title, links_category.title, SUM(links_vote.karma_delta) AS karma, SUM(CASE WHEN links_vote.user_id = 1 THEN links_vote.karma_delta ELSE 0 END) AS user_vote FROM links_link LEFT OUTER JOIN auth_user ON (links_link.user_id = a...

Django: filtering models on the difference of Counts of related models

I've got a bunch of Order objects, each connected to one or more OrderRow objects (visible as a reverse relation to their parent Orders with Order.order_rows.all()). Each OrderRow has a collection_status attribute, which can be 'collected', 'uncollected' or a bunch of other special values. Each Order has a status attribute, one of the v...

How do I mimic browser back arrow in my application page ?

request.path gives me the clicked url. I need a return link on that page which on clicking, should return to Referrer page, just as it would happen in case of browser back arrow . I do not maintain any session and do not want to hardcode the referrer page url. ...

Dynamic SEO-friendly URLs

I'd like to deploy dynamic URL's for my app in two ways: when viewing available vehicle, I get a link like: http://www.url.com/2006-Acura-MDX-Technology-Package I also have a filter page, so here, the URL will change according to the filters selected like: http://www.url.com/2007-Nissan or http://www.url.com/2007-Nissan-Maxima and so o...

Django: how to use bare classes in urls.py urlpatterns?

I've seen somewhere a urls.py construct like this: from project.f import SomeClass urlpatterns = patterns('', (r'^url/$', SomeClass()), ) Nowhere in http://docs.djangoproject.com/en/dev/topics/http/urls/ I can find out what this means, normally an entry is like this: (r'^url/(?P<some_id>\d+)/$', 'project.views.some_view'), C...

how can I get the current user in a filter without explicitly passing it in?

I'd like the simplest way to show "You" instead of a username if that username matches that of the current user. ideally a filter like this (where object.owner is a ForeignKey field pointing at auth.User) {{ object.owner|username_or_you }} or a way to intercept this higher up the chain - so anywhere i output user.username it'll outpu...

Django to use different settings.py file based on subdomains

How can Django use different settings.py file based on subdomains. Can these utilities ("django-admin", "python manage.py") still be used if there were different settings connecting to different databases. ...

searching all fields in a table in django

How to search all fields in a table in django using filter clause ex:table.object.filter(any field in the table="sumthing") Thanks. ...