django

What kind of data do I pass into a Django Model.save() method?

Lets say that we are getting POSTed a form like this in Django: rate=10 items= [23,12,31,52,83,34] The items are primary keys of an Item model. I have a bunch of business logic that will run and create more items based on this data, the results of some db lookups, and some business logic. I want to put that logic into a save signal or...

Django tutorial says I haven't set DATABASE_ENGINE setting yet... but I have

I'm working through the Django tutorial and receiving the following error when I run the initial python manage.py syncdb: Traceback (most recent call last): File "manage.py", line 11, in <module> execute_manager(settings) File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 362 in execute_manager utility...

Django Thread-Safety for templatetags

Hi, I am coming here, because I have a question about Django and Thread. I read the documentation http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#template-tag-thread-safety and I would like to now if the next code could be impacted also, at the rendering context. class ChatterCountNode(NodeBase): def __init__(self,...

Can I add other tables in my db ?

Can I add other tables in the database created by django ? It is for my PHP application. ...

Integrate django with django-lfs

Hi All, I try to integrate django-ifs like a django app without using buildout. Now I can start server by after syncdb django create all model. I can manage shop , add product BUT when I try to display product on page.Its display Exception Value:Caught AttributeError while rendering: 'Shop' object has no attribute 'content_type' Except...

How to add CometChat in my Django project ?

Is there a way to add this chat in my django project? : http://www.cometchat.com/ ...

How do I create a Django ModelForm, so that it's fields are sometimes required, sometimes not?

Ok, here is the question. Imagine I have a ModelForm which have only two fields. like this one: class ColorForm(forms.Form): color_by_name = forms.CharField() color = forms.IntegerField(widget = forms.Select(choices=COLOR_CHOICES)) So a user can either input a color name, a choose it from a list. Color is required, but that ...

Django - Expression based model constraints

Is it possible to set an expression based constraint on a django model object, e.g. If I want to impose a constraint where an owner can have only one widget of a given type that is not in an expired state, but can have as many others as long as they are expired. Obviously I can do this by overriding the save method, but I am wondering if...

Python / Django : emulating a multidimensional layer on a MySQL database

Hi, I'm working on a Django project where I need to provide a lot of different visualizations on the same data (for example average of a value for each month, for each year / for a location, etc...). I have been using an OLAP database once in college, and I thought that it would fit my needs, but it appears that it is much too heavy fo...

django inheritance with foreignkey field

My models are set up as follows (this is an example and not my actual models) class modelA(Model): field1 = CharField(max_length=50) class modelB(modelA): field2 = CharField(max_length=50) class anotherModel(Model): connection = models.ForeignKey(modelA) title = CharField(max_length=50) Would I be able to have an connect...

django blog - post- reply system display replies

I have a mini blog app, and a reply system. I want to list all mini blog entries, and their replies, if there are any. i have in views.py def profile_view(request, id): u = UserProfile.objects.get(pk=id) paginator = New.objects.filter(created_by = request.user) replies = Reply.objects.filter(reply_to = paginator...

reddit style voting with django

Hay i need to hand implemeneting a voting system into a model. I've had a huge helping hand from Mike DeSimone making this work in the first place, but i need to expand upon his work. Here is my current code View def show_game(request): game = Game.objects.get(pk=1) discussions = game.gamediscussion_set.filter(reply_to=None) ...

Pinax: Customize Signup and profile

I want to gather some more information when the user signs up and also display this as part of the profile information - so that the user can edit it once he creates a login. How do i do this? I did search a lot the docs, but i did not find anything and i did not want to mess up the base code when i change the underlying models/forms....

Skip sanitization for videos in html5lib

I am using a wmd-editor in django, much like this one in which I am typing. I would like to allow the users to embed videos in it. For that I am using the Markdown video extension here. The problem is that I am also sanitizing user input using html5lib sanitization and it doesn't allow object tags which are required to embed the videos. ...

How can I map field names between Django/PyAMF and Flex?

For example, using my UserProfile model: class UserProfile(models.Model): user = models.ForeignKey( User, unique=True ) blurb = models.CharField( max_length=200, null=True, blank=True ) public = models.BooleanField( default=True ) ... Thus, I end up with a field called "public". This doesn't jive in ActionScript be...

Django disable editing (but allow adding) in TabularInline view

I want to disable editing ALL objects within a particular TabularInline instance, while still allowing additions and while still allowing editing of the parent model. I have this trivial setup: class SuperviseeAdmin(admin.TabularInline): model = Supervisee class SupervisorAdmin(admin.ModelAdmin): inlines = [SuperviseeAdmin] admin...

Django: common template subsections / simple html templatetags ?

What's a good way to handle commonly occurring subsections of templates? For example, there is a sub-header section that's used across 4 different pages. The pages are different enough to not work well with template inheritance (ie. "extends" doesn't fit well). Is "include" the recommended method here? It feels a bit heavyweight, requi...

Using .annotate() and extra() together in django

It seems i cannot use annotate and extra together when making a queryset This discussions = game.gamediscussion_set.filter(reply_to=None).annotate(up_votes = Count('userUpVotes'), down_votes=Count('userDownVotes')).extra(select={'votes':"'userUpVotes' - 'userDownVotes'"}).order_by('votes') returns Caught Warning while rendering: Trun...

Getting "Error loading MySQLdb module: No module named MySQLdb" - have tried previously posted solutions

This is a much discussed issue for OSX 10.6 users, but I haven't been able to find a solution that works. Here's my setup: Python 2.6.1 64bit Django 1.2.1 MySQL 5.1.47 osx10.6 64bit I create a virtualenvwrapper with --no-site-packages, then installed Django. When I activate the virtualenv and run python manage.py syncdb, I get this err...

Error running celeryd

I'm posting this question (and answer) so if anybody else has this problem in the future, you'll be able to google it. If you are trying to run celeryd in Django like so: python manage.py celeryd You can receive the following error immediately after it has started: celery@eric-desktop-dev has started. Traceback (most recent call las...