django

Django: How to follow ForeignKey('self') backwards

class Achievement(MyBaseModel): parent_achievement = models.ForeignKey('self', blank=True, null=True, help_text="An achievement that must be done before this one is achieved") # long name since parent is reserved I can do : Achievement.objects.get(pk="1").parent_achievement which is great. But how do I get all the children? Ach...

Django Model Sync Table

If I change a field in a Django model, how can I synchronize it with the database tables? Do I need to do it manually on the database or is there a tool that does helps with the process? ...

Static methods and thread safety

In python with all this idea of "Everything is an object" where is thread-safety? I am developing django website with wsgi. Also it would work in linux, and as I know they use effective process management, so we could not think about thread-safety alot. I am not doubt in how module loads, and there functions are static or not? Every inf...

Can I filter on multiple contrains with django aggregate functionlity?

How can I count records with multiple constraints using django's aggregate functionality? Using django trunk I'm trying to replace a convoluted database-specific SQL statement with django aggregates. As an example, say I have a database structured with tables for blogs running on many domains (think .co.uk, .com, .etc), each taking many...

Django Initialization

I have a big array, that I would like to load into memory only once when django starts up and then treat it as a read only global variable. What is the best place to put the code for the initialization of that array? If I put it in settings.py it will be reinitialized every time the settings module is imported, correct? ...

Editing foreign key objects

class Foo(models.Model) field1 = models.IntegerField() field2 = models.IntegerField() bar_field = models.ForeignKey("Bar", null=True, blank=True) In a view, I am given the Foo pk, and from that I need to grab the corresponding Bar object, edit it, and then save it again. Whats the best way to do this? def my_view(request, ...

Efficiently importing modules in Django views

Hi all, I was wondering - how do people handle importing large numbers of commonly used modules within django views? And whats the best method to do this efficiently? For instance, I've got some views like, admin_views.py search_views.py . . and from what I've seen, every one of them needs to use HttpResponse or other such commonly ...

Set Django IntegerField by choices=... name

When you have a model field with a choices option you tend to have some magic values associated with human readable names. Is there in Django a convenient way to set these fields by the human readable name instead of the value? Consider this model: class Thing(models.Model): PRIORITIES = ( (0, 'Low'), (1, 'Normal'), (2, '...

Make Form Invalid without Raising ValidationError in Django

Hello, I would like a form to be invalid without raising a ValidationError in any of the form's or form's field's clean methods. The reason for this is that the form is the "super form" for a set of "sub forms", and I want the super form to be invalid when any of its subforms are invalid. But this invalidity does not entail raising a ...

geodjango + PostGIS = GPL?

I always get confused with licenses, I'm reading up again, but I'm sure someone out there already understands this and may be able to explain it more clearly. I'm trying to get my company to use geodjango, and being a typical large enterprise company they don't want to open-source the resulting project. And therefore opposed to touchin...

Turbogears 2 vs Django - any advice on choosing replacement for Turbogears 1?

I have been using Turbogears 1 for prototyping small sites for the last couple of years and it is getting a little long in the tooth. Any suggestions on making the call between upgrading to Turbogears 2 or switching to something like Django? I'm torn between the familiarity of the TG community who are pretty responsive and do pretty good...

How to debug in Django, the good way?

So, I started learning to code in Python and later Django. The first times it was hard looking at tracebacks and actually figure out what I did wrong and where the syntax error was. Some time has passed now and some way along the way, I guess I got a routine in debugging my Django code. As this was done early in my coding experience, I s...

What is a good python-based Webshop Software?

I am currently evaluating for an eCommerce project. Is there any good Python based webshop software. Are there any personal experiences people can share? Until now I have only found: http://www.satchmoproject.com/ Coming from the PHP world finding only ONE project seams akward to me. Does anybody have experience with Satchmo? Ar...

Migrating Django Application to Google App Engine?

Hello, I'm developing a web application and considering Django, Google App Engine, and several other options. I wondered what kind of "penalty" I will incur if I develop a complete Django application assuming it runs on a dedicated server, and then later want to migrate it to Google App Engine. I have a basic understanding of Google's ...

Which are good Python - Django hosting solutions?

I'm looking for a hosting provider for my Python-Django project. I need suggestions in terms of both shared space and managed server solutions. Of course, in case of shared space, Python execution through CGI is not an option. For now, I'm concerning Slicehost or Linode... Anyone with other recommendations? Thanx ...

How to put infinity and minus infinity in Django FloatField?

I am trying to put infinity in a FloatField, but that doesn't seem to work. How do I solve this? f = DjangoModel(float_value=float('inf')) #ok f.save() #crashes Results in: Traceback (most recent call last): ... ProgrammingError: column "inf" does not exist LINE 1: ... "float_value") VALUES (inf) I'm using Django 1.0.2 with Postgre...

Getting "Comment post not allowed (400)" when using Django Comments

I'm going through a Django book and I seem to be stuck. The code base used in the book is .96 and I'm using 1.0 for my Django install. The portion I'm stuck at is related to Django comments (django.contrib.comments). When I submit my comments I get "Comment post not allowed (400) Why: Missing content_type or object_pk field". I've fo...

Django templates: adding sections conditionally

I just started using django for development. At the moment, I have the following issue: I have to write a page template able to represent different categories of data. For example, suppose I have a medical record of a patient. The represented information about this patient are, for example: name, surname and similar data data about cur...

Eliminating certain Django Session Calls

Hi, I was wondering if I could eliminate django session calls for specific views. For example, if I have a password reset form I don't want a call to the DB to check for a session or not. Thanks! ...

How to model one way one-to-one relationship in Django

Hi, I want to model an article with revisions in Django: I have following in my article's models.py: class Article(models.Model): title = models.CharField(blank=False, max_length=80) slug = models.SlugField(max_length=80) def __unicode__(self): return self.title class ArticleRevision(models.Model): article = ...