django

run django with xampp on windows

can i run django (Python framework) site with xampp on windows? Please guide me. ...

list() doesn't work in appengine?

i am trying to use set function in appengine, to prepare a list with unique elements. I hit a snag when i wrote a python code which works fine in the python shell but not in appengine + django This is what i intend to do(ran this script in IDLE): import re value=' [email protected], dash@ben,, , [email protected] ' value = value...

How to restrict users voting on their own model

I am using django-voting as a voting application for two of my models. Those both models have fields "author". How can I restrict a user from voting on a model that has this particular user set as it's author without modifying django-voting app? Django middleware is the first thing that comes to my mind, but I don't understand it's "pr...

Can I force the first letter of the verbose_name of a django model field to be lower case?

Django automatically capitalizes the first letter of the verbose_name of a field in a model. I'd like it to be lower case. Is there a way to do that? ...

Number of visitors in Django

In Django, how can I see the number of current visitors? Or how do I determine the number of active sessions? Is this a good method? use django.contrib.sessions.models.Session, set the expiry time short. Every time when somebody does something on the site, update expiry time. Then count the number of sessions that are not expired. ...

Django: how to make DATETIME_FORMAT active?

Where should DATETIME_FORMAT be placed for it to have effect on the display of date-time in the Django admin site (Django’s automatic admin interface) ? Documentation for DATETIME_FORMAT, on page http://docs.djangoproject.com/en/1.0/ref/settings/, says: "The default formatting to use for datetime fields on Django admin change-list page...

Django: How to sort a ModelForm's Many2ManyField (Select Tag) according to the object's __unicode__() value?

As stated in the title. ...

How to distinguish field that requires null=True when blank=True is set in Django models?

Some model fields such as DateTimeField require null=True option when blank=True option is set. I'd like to know which fields require that (maybe dependent on backend DBMS), and there is any way to do this automatically. ...

Using Django JSON serializer for object that is not a Model

Is it possible to use Django serializer without a Model? How it is done? Will it work with google-app-engine? I don't use Django framework, but since it is available, I would want to use its resources here and there. Here is the code I tried: from django.core import serializers obj = {'a':42,'q':'meaning of life'} serialised = seri...

How do I create a Django model with ForeignKeys which does not cascade deletes to its children?

One of my models which has ForeignKey's is actually a MySQL view on other tables. The problem I'm running into is that when I delete data from these tables, Django, as described in the "deleting objects" documentation... When Django deletes an object, it emulates the behavior of the SQL constraint ON DELETE CASCADE -- in other ...

Models unique_together constraint + None = fail?

2 questions: How can I stop duplicates from being created when parent=None and name is the same? Can i call a model method from within the form? Please see full details below: models.py class MyTest(models.Model): parent = models.ForeignKey('self', null=True, blank=True, related_name='children') name = models.CharField(max...

"sites framework" on a single django instance

I want to serve up specialized RSS feeds on a different subdomain from the rest of the site. Can I use the sites framework to use a different urls.py and settings.py file within a single django instance. or do I need to set up two apache locations and just set the different settings.py files in the apache conf. The reason I need to set...

implementing a template tag within a generic app - django

I have developed some code that builds on the contrib comments app, such as handlers for ajax requests. This code is in a separate application, which we can call 'comments2'. the url configuration of the project is structured in such a way that all calls to /comments are directed to this app's views. This works without problems. Very re...

How do I replace whitespaces with underscore and vice versa?

I want to replace whitespace with underscore in a string to create nice URLs. So that for example: "This should be connected" becomes "This_should_be_connected" I am using Python with Django. Can this be solved using regular expressions? ...

Django App CSS working in Safari 3, not in Firefox 3.

I'm working my way through a Django book and I just noticed something strange the other day. The CSS code works just fine in Safari 3 (on Mac and Windows) but not in Firefox 3 (Windows). I'm running the django dev web server and I can see the css file being called in the console when in Safari but not when using Firefox. Any idea on w...

Django comments reverse relationship

When using django.contrib.comments is there anyway to add the reverse relationship to a model that has comments? For example: post = Post.objects.all()[0] comments = post.comments.all() ...

Django in Lighttpd + FCGI on Ubuntu - rewrites stop working when I enable a second site

I've got lighttp configured to start and serve django via fastcgi on ubuntu. When I have only a single site enabled (via ubuntu's apache-like conf-available, conf-enabled mechanism), everything runs beautifully. When I enable a second site, my url rewrites seem to stop working correctly, though the fcgi processes are started and serving ...

Timestamp conversion is off by an hour

I'm trying to parse a twitter feed in django, and I'm having a strange problem converting the published time: I've got the time from the feed into a full 9-tuple correctly: >> print tweet_time time.struct_time(tm_year=2009, tm_mon=6, tm_mday=17, tm_hour=14, tm_min=35, tm_sec=28, tm_wday=2, tm_yday=168, tm_isdst=0) But when I call thi...

Would extracting page metadata be a good use of multiple inheritance?

I was wondering if I have a couple of models which both include fields like "meta_keywords" or "slug" which have to do with the web page the model instance will be displayed on, whether it would be advisable to break those page metadata elements out into their own class, say PageMeta, and have my other models subclass those via multiple ...

Customizing Django auto admin terminology

Hello everyone, I'm playing around with Django's admin module, but I've seemed to run into a bit of a bump that's more of an annoyance than an error. I have my modules setup using names like UserData and Status, so Django's admin panel likes to try to call each row in UserData a user datas and each status a statuss. Is there any way I c...