django

Query based on a composition of columns in Django

I'd like to figure out how to query based on a composition of columns, eg the fullname of a user, without any custom SQL. Is this possible? Imagine something like User.objects.filter(firstname_concat_lastname__startswith="Barack Ob") I know that in this particular example, it'd be easy enough to split "Barack Ob" by whitspace and ...

easy question about managing static content in django

Hi, I have a simple website in django where the content is static. Where i use templates like "AboutUs.html" ,"OurServices.html" or "contact.html".. now i want to use the django admin so anyone could change the content for those pages using a WYSIWYG editor (cause the people who will change this dont know html).. i wanted to create a cl...

Django - How to meter bandwidth usage on static content?

I realize this is more of a server question (since all media requests bypass Django via NGINX), but I want to know how others Django Developers have been doing this, more so than I care to understand only the specifics of how to do it in NGINX. I don't care about the bandwidth of HTML page requests via Django; only the bandwidth of stati...

Django templating engine and external js files

I'm writing a Google app engine app and obviously the default web app framework is a subset of Django. As such I'm using it's templating engine. My question is if I have say the following code: template_values = { 'first':first, 'second':second, } path = os.path.join(os.path.dirname(__file__), 'index.html') self.resp...

Django filter - only select postes depending on filters

**models.py** class Category(models.Model): name = models.CharField(max_length=50) def __unicode__(self): return self.name class Gender(models.Model): name = models.CharField(max_length=50) def __unicode__(self): return self.name class Post(models.Model): name = models.CharField(max_length=50) ...

custom template operator

Is it possible? I know about filters, but is it possible to create something like this: {% if 75 is_divisible_by 5 %} It just looks a lot nicer than: {% if 75|is_divisible_by:5 %} (this is a concept question, is_divisible_by is just an example) ...

How do I set default widget attributes for a Django ModelForm?

I'd like to set the class attribute for the TextInput Widget to one value for all the fields in my form that use it without having to list them all in Meta: widgets = {.... Is this possible? Thanks. ...

Downtime when reloading mod_wsgi daemon?

I'm running a Django application on Apache with mod_wsgi. Will there be any downtime during an upgrade? Mod_wsgi is running in daemon mode, so I can reload my code by touching the .wsgi script file, as described in the "ReloadingSourceCode" document: http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode. Presumably, that reload requ...

Load jQuery into Django

I have a really basic question. I'm trying to build some AJAX functionality into a Django project. I plan to use jQuery. Right now, I'm just running the code locally through Linux. I've been testing some code here so I'm reasonably certain that it works. But I'm having trouble figuring where to put the jQuery source code in combinati...

Python/GAE social network / cms?

Hi, After much research, I've come up with a list of what I think might be the best way of putting together a Python based social network/cms, but have some questions about how some of these components fit together. Before I ask about the particular components, here are some of the key features of the site to be built: a modern almo...

Django PayPal & Additional Options

I'm using Django PayPal. PayPal has a list of options you can pass on your button. I'm trying to add some of these to my paypal_dict paypal_dict = { # ... # preopulate paypal checkout page "email": invoice.user.email, "first_name": invoice.user.first_name, "last_name": invoice.user.last_name, "address1": invoice...

Can't get Celery run_every property to work

I'm trying to create some Celery Periodic Tasks, and a few of them need to have the ability to change the run_every time at runtime. The Celery documentation says I should be able to do this by turning the run_every attribute into a property (http://packages.python.org/celery/faq.html#can-i-change-the-interval-of-a-periodic-task-at-runt...

What's the best way to play a sound from my website?

I know it's generally frowned upon, but in this case I think it might actually be helpful. I want to play a little "ding" sound when a new item is posted on my site. I'll leave the option to turn it off of course. Now should I do this with JavaScript? Would jQuery be helpful? Or should I use Flash? Looking for something that is widely c...

Does Django repopulate file fields on form error?

Currently I have something like: def my_view(request) if request.method == 'POST': form = MyForm(request.POST, request.FILES) if form.is_valid(): form.save() redirect() else: form = MyForm() return render_to_response('form.html', {'form': form}) On a form validation error, al...

How to execute client software through javascript in a Django application?

Im thinking about creating an asset management application in Django. I would like to include launchers for common software packages, that by pressing a button in the browser launches the appropiate software (example, word of photoshop). How would I go on about doing this? ...

Django equivalent of SQL REPLACE

Is there a Django ORM best practice for this SQL: REPLACE app_model SET field_1 = 'some val', field_2 = 'some val'; Assumption: field_1 or field_2 would have a unique key on them (or in my case on both), otherwise this would always evaluate to an INSERT. Edit: My best personal answer right now is this, but it's 2-3 queries where 1 s...

pywin32 CreateEvent and Apache

Hello all, I have a website in Django1.1.1 deployed in Apache2.0. In the backend I have a launcher script that starts three python processes that interact with the frontend. One of these processes uses a Windows Event (using CreateEvent) that communicates with Apache. My problem is that when I run the launcher script first and then sta...

Django odd problem with using reverse and url tag

I've found very odd thing about using reverse in Django 1.2.1. I have: myapp/ views.py urls.py in urls.py from django.conf.urls.defaults import * urlpatterns = patterns('myapp.views', url(r'^$', 'browse'), ) in views.py from django.shortcuts import render_to_response from django.core.urlresolvers import reverse print reve...

Returning an inclusion tag

Hi, I am suffering whereever i try to do something in django that is not common(in django, not in python in general) For example, i don't know how to return an inclusion tag. This. obviously, won't work: @register.inclusion_tag('template.tpl') def myinclusiontag(parameter): return {'var': parameter.attr1} @register.inclusion_tag(...

django-admin.py startproject is not working

after installing django I tried django-admin.py startproject mysite and that worked, then I got a simple site working and I wanted to start on something real, so I tried django-admin.py startproject newsite and nothing happened. Whenever I try the command nothing happens now.. any idea what is wrong? ...