django

Django-way for building a "News Feed"/"Status update"

Hi, I'd like to create a reusable Django app that handles status updates of the Users. Much like facebook's "news feed". Use cases includes, for example: A Professor can create an Assignment due to an specific date and every student can see on the news feed that the assignment was created, with a short description, the date that it's...

django-ajax-selects app: How do I create a new object when there isn't already one in the database?

I'm using django-ajax-selects, which is a freely available django app providing jquery autocomplete functionality. I've got it working - i.e. it is autocompleting the form fields I want it to. But I have a problem... I'm using it in a ModelForm which adds Partnership objects to the database: class Skater(models.Model): name = model...

How can I set up Celery to call a custom initialization function before running my tasks?

I have a Django project and I'm trying to use Celery to submit tasks for background processing ( http://ask.github.com/celery/introduction.html ). Celery integrates well with Django and I've been able to submit my custom tasks and get back results. The only problem is that I can't find a sane way of performing custom initialization in t...

django error in my code ,what does i do

from django.core.management import setup_environ from register2 import settings setup_environ(settings) from django import forms from django.contrib.auth.forms import AuthenticationForm from django.utils.translation import ugettext_lazy as _ class AuthenticationRememberMeForm ( AuthenticationForm ): """ Subcl...

Preprocess SHPAML in Django's template loader?

Is there any way to make Django's template loader run all templates it loads (i.e. directly or via extend/include) through SHPAML if it figures the HTML is out of date? I know how to invoke SHPAML recursively over an entire directory, but I would prefer to be able to run it on demand so I don't have to remember to sync the HTML every ti...

Writing eclipse templates

I am writing django templates in Eclipse->prefrences->templates, to autocomplete DJango templates. I wrote this {% block ${cursor} %} {% endblock %} Now, when I request and do autocompletion, after typing {% the autocompletion is {% {% block %} {% endblock %} While I would like {% block %} {% endblock %} With cursor after ...

Django No redirections

I have a flash file which calls a url like: http://test.com/savethis/123456/ I just want my view to save "123456" in the database and return nothing. After saving the values what do I do? If I redirect it it changes the page and that's bad. I could render a page, but I don't want to. I just want it to end and not throw any errors. ...

Django: Multiple COUNTs from two models away.

I am attempting to create a profile page that shows the amount of dwarves that are assigned to each corresponding career. I have 4 careers, 2 jobs within each of those careers and of course many dwarves that each have a single job. How can I get a count of the number of dwarves in each of those careers? My solution was to hardcore the...

Django-registration, force unique e-mail

Can I force users to make unique e-mail addresses in django-registration? ...

Django and SSL question

Hello, I am planning to sell products by charging credit cards thus using SSL will be critical for Django-powered website. And I am very naive for this. My initial django setup plan was using Apache as the webserver and using mod_wsgi to communicate with Django, static media again served by Apache. All seemed good until SSL protocol com...

Facebook notification error

hi, I have a piece of python code which is used to send notification to a perticular user. request.facebook.notifications.send(['500263834'], 'msg','user_to_user') return HttpResponse() which works fine when I run it on my own server (not from the facebook canvas page) and gives me a error that I need a facebook session. Which sounds...

Django: Return all Values even if filtering through a related model

Thanks to some fantastic help on a previous question I have managed to put together my query. Everything works swimmingly save one issue. careers = Career.objects.filter(job__dwarf__user = 1).annotate(dwarves_in_career = Count('job__dwarf')) In my view this does exactly what I want and when I loop it in my template like so: {% f...

Beginner Django Forms Question: Adding an Item to a User's Categories

I have in my models Item with a many-to-many connection with Categories, and Categories have a Foreign Key to User. What I'm hitting a road block figuring out is how to create a view with the intent to import an Item object to one or more of a User's Categories. In it's most basic implementation I would like the view to display only th...

django: gettext and coercing to unicode

I have following code in my django application. class Status(object): def __init__(self, id, desc): self.id = id self.desc = desc def __unicode__(self): return self.desc STATUS = Status(0, _(u"Some text")) When I try to display some status (or even coerce it to unicode), I get: TypeError: coercing t...

importing geonames database into postgres for django project - problem with foreignkey constraints

The geonames database has two models that refer to each other. In a postgres database, reference is provided by foreign key relationships. The problem is writing data to the database - writing to one table without having the referenced id in the other table violates a foreign key contraint. Class Geoname id = IntegerField(primary_...

Using django.db.connection.queries ...

Hi, I've got a Python/Django application which runs quite a lot of SQL statements. For debugging purposes, I thought I should create a simple view for me which just lists all the SQL statements that have been run. According to the documentation, this code should be enough to do that: from django.db import connection connectio...

What cheat sheets exist for Django?

What cheat sheets exist for Django? If possible, provide a description (e.g. scope, Django version information, number of pages, authors, direct download URL if it is in PDF), how you discovered it, etc. Some external resources are Our Favorite Cheat Sheets, devcheatsheet.com and TechPosters.NET, but I think there should be a directory...

Checkboxes for models, two submit buttons: add person model to group model, reject person model from group model

Hello guys, I've looked at formset and model formset at Django many times, but I still can't figure the smart way to do this. I have two models: Group Person I have a queryset that contains all the persons trying to join a particular group: Person.objects.filter(wantsToJoinGroup=groupD) Now, what I want to do, is display a page wit...

Django: How would one organize this big model / manager / design mess?

To sum things up before I get into bad examples, et al: I'm trying to make an application where I don't have to write code in all my models to limit choices to the current logged in account (I'm not using Auth, or builtin features for the account or login). ie, I don't want to have to do something like this: class Ticket(models.Model):...

Django: How do you access a model's instance from inside a manager?

class SupercalifragilisticexpialidociousManager(models.Manager): # Sorry, I'm sick of Foo and Spam for now. def get_query_set(self, account=None): return super(SupercalifragilisticexpialidociousManager, self).get_query_set().filter(uncle=model_thats_using_this_manager_instance.uncle) The magic I'm l...