django

Is there a naming convention for Django apps

Is there a preferred naming convention for creating a Django app consisting of more than one word? For instance, which of the following is preferred? my_django_app my-django-app Update: Not allowed syntactically mydjangoapp Recommended solution While all of them may be options 1 and 3 are syntactically allowed, is there a preference...

set user session in django

<?php session_start(); $_SESSION['username'] = "johndoe" // Must be already set ?> How to write equivalent code for the above in django ...

Django Template

Dear Everybody I am doing a Django tutorial on Templates. I am currently at this code: from django.template import Template, Context >>> person = {'name': 'Sally', 'age': '43'} >>> t = Template('{{ person.name }} is {{ person.age }} years old.') >>> c = Context({'person': person}) >>> t.render(c) u'Sally is 43 years old.' What I don...

How do you override the automatically generated fieldnames in a Django model?

I have a (pre-existing) table witha column 'foo'. I want the model to have a property 'bar' which maps to foo. I already use class Meta: db_table = u'actual_table_name' to remap classes/tables from the default table name. Is there a similar way to do this for properties/fields? Thanks, Chris. P.S. This seems like a very sim...

Django registration and multiple profiles

I'm using django-regitration in my application Now I want to create different kind of users, with different profile. for example a user is a techer and another user is a student. How can I modify registration to set the user_type and create the right profile? ...

Datetime.now() abnormality - Python

Hi folks, I'm serving a Python app through Django. Within the app I'm storing the classic "created" field within a few tables. This is how the field looks like within the Django form: created = models.DateTimeField(blank=True, default=datetime.now()) Unfortunately, datetime.now() is not accurate. In fact in the database I have set...

Partial vs. Ajax

Hi there, I have some content (a flash widget, to be precise) on a page that I want to be static, I have been using full coverage GWT on the entire page, which allows user to never have to reload the page. But I am thinking about switching to app engine and django, is there a way so that the user won't reload the widget? or do I have to ...

running command in background

hi, I am using python subprocess module to run some command and store its output in background. The command is deployed on my machine. Now whenever i run the command from shell prompt it works fine. But when I try to run the same command using subprocess module it gives following error The command to be executed is vxswadm listswitch a...

django model versioning/revisions/approval - how to allow user to edit own profile but keep old online until new approved?

I am building a site where users can make changes to their publicaly displayed profile. However I need all changes to be approved by an admin before going live. Until the changes are approved their old profile will be displayed. In the admin there should be a list of profiles awaiting approval. It is preferable, but not required, to keep...

The easiest way to have a multilingual django site?

Hi I have and old django site (0.97-pre-SVN-7457) and I'm about to make some changes and get the site running on the current development code of django. I have alot of content that needs to be intact. When I started the site, I made an ugly "hack" to get a dual lingual site, so the result is not pretty: Here is my model: class Entry(...

Django Template block tag

Hi How many different block tags like these exist? {% block %} In other words if I have a parent template and child templates with multiple block tags. How does Django know where to insert if not by different block tag names? Or can I customize like: {% block_mytag_1 %} Thanks L ...

Does Django admin provide group edit of models?

For instance, I have a model called Person, and it has a bool field called 'isAthlete'. I would like to be able to check off True for 50 of these Person records, and then hit submit, without having to go into each Person model record and make the change. Is there an easy or already provided way to set this up in Django? ...

How to select model records which are referenced the most by another model type in Django?

For instance, given a model A, and a model B, where A are unique records, and B are records that have Foreign Keys to A, how would you go about getting a set of A where those in the set are referenced by B at least n or more times? ...

Serialize a django-haystack queryset

Hi, I want to export the results I have in a Queryset that I obtain from a haystack search view. In order to do this, I've found the best way is by doing it asyncronally, so I'm using Celery and Rabbitmq to manage the task and there create the file and iterate over all the results and then notify the user via email that the file is ready...

django: Nonelogout in admin urls

After upgrading to Django 1.2 I have strange urls in my administration panel. They look like this: http://example.com/admin/Nonelogout/ or http://example.com/admin/Nonepassword_change/ What might have gone wrong during the migration and what I need to fix? I have found in django source, that it is caused by root_path, but I have n...

Django IntegrityError when saving permissions/groups via admin

Hi everyone. I'm using Django 1.0, and I'm having a tricky problem with permissions and groups. Having launched a site, I wanted to use more fine-grained permissions for the content editors, so that they can insert new content with django's built-in admin function, not having to worry about potential damage to those models they should n...

Pickling Django request objects

I'm trying to pickle a request object so that I can run my view code in a debugger with valid input. However, I'm getting Can't pickle 'lock' object: <thread.lock object at 0x93ad240> I looked through the request object, but couldn't find a thread.lock object anywhere in it. Does anyone know where it is? Is there a better way to go ab...

Django Model/Database design for subclasses

Hi. Ok, i'm shit at describing. Here's a relationship diag. In Django i've made my models like: from django.db import models from datetime import datetime class Survey(models.Model): name = models.CharField(max_length=100) pub_date = models.DateTimeField('date published',default=datetime.now) def __unicode__(self): ...

When overriding django admin views, how to get object information ?

I select an object (of type SourceClass) from the admin site and get to the 'change' page. The object I have selected has a ForeignKey relationship to another type of object (TargetClass). The change page for the object of type SourceClass gives me both a drop down box (from a select form field) and a link to add a new TargetClass. Th...

Django file upload/download in a social community

I have a social community built in Django, and i want to add a upload/download/read(documents) feature for users, so that many users can do these operations in the same time. What do you recommend me? The standard Django upload/download document feature is ok for that purpose? Thanks! ...