django

south. migrate entire database

how can i migrate entiry db at one step? south`s startmigration command can work only with single application ...

Django aggregation get_*_display function usage

Hi all, This question relates to Django Aggregation/Annotation in 1.1. Suppose I have a simple model with an IntegerField that has a "choices" parameter passed to it. In this case, it maps to a GENDERS tuple as shown. Normally, in a template (or view) I can refer to the textual value of the gender by using the get_gender_display() f...

About index and primary key in SQL?

It may looks a naive question but I am wondering about the relationship between primary keys and indexes in most common SQL databases. Is it a standard rule for a SQL database to create automatically an index for every primary key? I am asking that because I am designing a model with Django and I am wondering if it is redundant to set...

Django buggy template tag - 'NoneType' object has no attribute 'source'

Wondering what is causing this? Had me stumped for some time, everything checks out in console when running in pieces as a side note: the template is using the same object in other places and displaying values - the object in template is also the same one loaded in the console below error 'NoneType' object has no attribute 'source'...

Pass session data onto URL

I have some information that is set in the sessions, and I was wondering if it's possible to pass this info onto the URL for the view that uses this session data. I want this to be working in such a way that if the user bookmarks the page from that view, the session data is used to pass the variables onto the view. How can I do this? I...

DJANGO : Update div with AJAX

Hi there I am building a chat application. So far I am adding chat messages with jquery $.post() and this works fine. No I need to retrieve the latest chat message from the table and append the list on the chat page. I am new to Django, so please go slow. So how do I get this back to the chatpage? Thank in advance! ...

ImageModel and BaseProfile

Hello, I want to write an app that registers a userprofile and uploads an image at the same time, I've got my baseprofile registration done, now all I want is to upload a user image using ImageModel and link it to a user, how do I achieve this?. These are the models: class BaseProfileImage(ImageModel): member = models.ForeignKey(BasePr...

Django Many To Many Insert Ordering

Hi everyone, We have been struggling with this for a few days and have done lots of searches on the web. We are trying to figure out how entries are saved in Django forms for many to many fields. For example we have a news model that has a many to many relationship with images. When we add images to a news article e.g. images with id ...

Large functionality change based on variables.

I'm in a situation where I've got a project that has a large number of Django views across quite a few different apps. The same codebase and database is being used by a large number of clients. There are a few site-specific use-cases that are coming in and this requires quite a bit of custom code to be written. I'd like to come up with ...

static site apache and dynamic/member site django

I have a site for static content, accessible to all that runs on apache. As an adjunct to that, there is a members site that runs on django. I haven't had any issue 'sharing' my .css and making both sides equivalent in appearance, but what I can't quite seem to grok is getting my django site to be django password protected (with the ad...

Does 'p' have a special meaning in Django?

Why are p and p8 different in the following code? The beginning of a view function (in file views.py in a Django app named "proteinSearch" with a model named "Protein" that has a field named "description"): def searchForProteins2(request, searchStr): p8 = Protein.objects.filter( description__icontains=searchStr) #Why doesn't t...

Python stacktrace help

hello, I have this stack trace error when I try view some data in my Python website, could some one clue me up as to what the problem is I am so lost Environment: Request Method: GET Request URL: http://mywesbite.genericdomain.co.uk/admin/shop/passwordresetrequest/4/ Django Version: 1.1.1 Python Version: 2.5.2 Installed Applicati...

How to restrict models foreign keys to foreign objects having the same property

Here is my example : We have printers. We can define page formats that are linked to a specific printer then we define workflows that select a starting format (first page added to the printing job), a body format and an end format (last page added to the printing job). Start and End are not required (null and blank = True) I want to b...

How do I transfer data in .csv file into my sqlite database in django?

This is my models.py from django.db import models class School(models.Model): school = models.CharField(max_length=300) def __unicode__(self): return self.school class Lawyer(models.Model): firm_url = models.URLField('Bio', max_length=200) firm_name = models.CharField('Firm', max_length=100) first = mode...

Issue with Django form when submitted using jQuery form plugin

hi, when submitting my form using jQuery form plugin, the request received by the target view is different than that received when the form is submitted in the standard way (with no javascript), and my Django template does not render as expected. When submitted in the standard way, the template renders the form errors (the "form.[field_...

Pass an initial value to a Django form field

Django newbie question.... I'm trying to write a search form and maintain the state of the input box between the search request and the search results. Here's my form: class SearchForm(forms.Form): q = forms.CharField(label='Search: ', max_length=50) And here's my views code: def search(request, q=""): if (q != ""): ...

For a ForeignKey field in a form, how do you display a widget other than a Select menu?

I have a modelchoicefield that has too many valid options to really show in a menu. How can I tell Django forms to use another widget that won't take up as much space rendering? I want to use a HiddenField and I have another widget on the screen taht will populate it. If the hiddenfield has no value I keep getting form validation er...

Excel and Django

I have an excel spreadsheet with calculations I would like to use in a Django web application. I do not need to present the spreadsheet as it appears in excel. I only want to use the formulae embedded in it. What is the best way to do this? ...

django admin TinyMCE integration

This is weird: I have installed and configured django-tinymce, but it doesn't seem to work with django admin. this works fine with Safari: class ArticleAdmin(admin.ModelAdmin): formfield_overrides = { models.TextField: {'widget': TinyMCE(attrs={'cols': 80, 'rows': 20}, )}, } but i does not work within firefox. Just ...

Prepopulating inlines based on the parent model in the Django Admin

I have two models, Event and Series, where each Event belongs to a Series. Most of the time, an Event's start_time is the same as its Series' default_time. Here's a stripped down version of the models. #models.py class Series(models.Model): name = models.CharField(max_length=50) default_time = models.TimeField() class Event(...