django

Django: Is it a good idea to use an abstract base model in this situation?

class Account(models.Model): identifier = models.CharField(max_length=5) objects = MyCustomManager() class Meta: abstract = True class Customer(Account): name = models.CharField(max_length=255) If I have a lot of models, and I want to save time from having to put foreignkeys everywhere, is ...

What big change in the Django development version would account for these errors?

I was merrily developing a web application using the Django development version. After some time had passed, I updated to version 1.2 alpha 1 SVN-12271. Now, I am getting form field default cleaning error messages like "Value u'A325' is not a valid choice." This is on a choice field with no possibility of an invalid choice. Also, I'm see...

Dynamic Django model creation based on existing DB table

I'm trying to figure out how I can use the type() module to dynamically create a Django model based on existing DB tables without having to either write it out manually or use the manage.py generator to inspect the DB. Reason is my schema changes frequently -- adding new tables, adding/deleting columns, etc. Anyone have a good solution...

Integer Field Math in Django

from django.db import models from django.contrib.auth.models import User class Product(models.Model): name = models.CharField(max_length = 127) description = models.TextField() code = models.CharField(max_length = 30) lot_no = models.CharField(max_length = 30) inventory = models.IntegerField() commited = models.IntegerField() available ...

Does a library to prevent duplicate form submissions exist for django?

I am trying to find a way to prevent users from double-submitting my forms. I have javascript that disables the submit button, but there is still an occasional user who finds a way to double-submit. I have a vision of a re-usable library that I could create to protect from this. In my ideal library, the code block would look somethi...

Django: Are row level permissions for instance specific rules, or are they about views?

Sorry for the confusing title. I tried to make it less verbose, but... What I'm wondering is: Does Django's new row level permissions (a) fix the design problem that comes with multi-tenant applications (I don't mean multiple users, but rather multiple instances working with the same db/db schema), or is it (b) just a more complex versi...

Django dumpdata UTF-8 (Unicode)

Is there a easy way to dump UTF-8 data from a database? I know this command: manage.py dumpdata > mydata.json But the data I got in the file mydata.json, Unicode data looks like: "name": "\u4e1c\u6cf0\u9999\u6e2f\u4e94\u91d1\u6709\u9650\u516c\u53f8" I would like to see a real Unicode string like 全球卫星定位系统 (Chinese). ...

What is the best means to achieve efficient many-to-many scanning with Django models?

I have a many to many relationship in Django similar as this: class Account ( models.Model ): name = models.CharField( max_length = 30 ) user = models.ForeignKey( User, null = True, blank = True ) class Publisher ( models.Model ): publisherID = models.BigIntegerField( ) name = models.CharField( max_length = 30 ) lastRequested...

Django - Store unescaped html in model

I am trying to store raw, unescaped HTML inside one of my Django models for display on my home page. However, when I store it in a TextField it gets escaped, and ends up just being displayed as raw text. How can I store raw HTML in a Django model? ** EDIT ** It seems as if its not getting escaped in the model layer, but in the Template...

Limit number of model instances to be created - django

I have model from which I only want to create one instance, and no more instances should be allowed. Is this possible? I've got a feeling that I've seen this done somewhere, but unfortunately I'm unable to locate it. EDIT: I need this for a stupidly simple CMS. I have an abstract class for which FrontPage and Page classes inherits. I ...

Defining an index combining two tables with Djapian

hi, I've got the following Restaurant and Comment models. I'm doing full text search on some fields of the Restaurant model, as shown below in the RestaurantIndexer class. How can I do a full text search including the comments (i.e. a search returning Restaurant instances with the query contained in one or some fields defined in Restaur...

django-multilingual: order drop down field by translated field

how do i order a the options of a form field by a translated field? models.py: class UserProfile(models.Model): ... country=models.ForeignKey('Country') class Country(models.Model): class Translation(multilingual.Translation): name = models.CharField(max_length=60) ... template.html: {# userprofileform is a ...

Which technology is preferable to build a web based GUI Client?

I've well developed Python Server having workflows, views, object - ORM/OSV, etc... Server/Client communication based on socket protocol, can be done by any of service 1. XMLRPC Service 2. Socket Service now I want to develop a Fully Ajax based GUI web Client.. I've web/socket services to communicate with server. what I need is to s...

django model and sqlite db creation bug.

I have the following model. from django.db import models class Client(models.Model): postcode = models.CharField(max_length=10) first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) address = models.TextField(blank=True) phone = models.IntegerField(blank=True) email = model...

Google App Engine with Django Patch and the Deferred library

Anyone successfully using deferred.defer library with app-engine-patch? If so please share. ...

unittest import error with virtualenv + google-app-engine-django

I'm working with google-app-engine-django + zipped django. Just running "python manage.py test" succeeded without error. But with virtualenv, test was failed with "import unittest error". same error with Django 1.1. - OSX 10.5.6 - google-app-engine-django (r101 via svn) : r100 was failed with launcher 1.3.0 - GoogleAppLauncher 1.3.0 -...

How to require login for django generic views ?

I want to restrict access to urls serves by django generic views. For my views i know that login_required decorator does the job. Also Create/update/delete generic views takes login_requied argument but I couldn't find a way to do this for other generic views. ...

Django view does not redirect when request by jQuery.post().

hi, I've got a menu to switch languages in my Django template. I call, via POST, the "/i18n/setlang/" view shown below to change the language setting. When I use a html form the user is redirected as expected, but when I use jQuery.post(), it is not. What am I missing? Thanks Call to the view using jQuery.post(): $.post("/i18n/setla...

fields and base_fields - Django

When creating a flatpage, I want the user to select a template from a predefined list. In order to keep the Flatpage model untouched, I prefer ChoiceField over ModelChoiceField (the latter provides the PK of the template, but I need the name for the template_name field): class NewFlatpageForm(FlatpageForm): template_name = forms.Ch...

Django's ModelForm unique_together validation

Hi, I have a Django model that looks like this. class Solution(models.Model): ''' Represents a solution to a specific problem. ''' name = models.CharField(max_length=50) problem = models.ForeignKey(Problem) description = models.TextField(blank=True) date = models.DateTimeField(auto_now_add=True) class M...