django

Django, Ajax + Generic foreign keys

Hi, I have a generic foreign key in one of my models: # models.py class Tasks(models.Model): content_type = models.ForeignKey(ContentType, limit_choices_to=tasktype_limits, null=True, blank=True) object_id = models.PositiveIntegerField(null=True, blank=True, ) target = generic.GenericForeignKey('content_type', 'objec...

Django ModelChoiceField does not cache the query

Hi, I have a problem with ModelChoiceField, it re-runs the query set every time, I am trying to cache my querysets here and I noticed that ModelChoiceIterator uses queryset.all() when iterating, which creates a new queryset, without cached data, and triggers a fresh query on the database. Is there any way past that? I am using cached...

django model Charfield

If I want a CharField with only one digit is this the way to write the model variable = model.CharField(max_length=1) Or if you only have one Char it is a differnet field? Thanks! ...

Django chat App..

How to integrate http://ajaxim.com/ to a django module Small piece of code would be helpful ...

Django Model ForeignKey

If I want to add a Foreignkey to a model from another class in the same model e.g. class1 (models.Model): variable1 = models.IntegerField() class2 (models.Model): variable2 = models.CharField() foreignkey = models.Foreignkey(class1.variable1) Is that possible? Does that make sense as a programming move? This ForeignKey w...

Development setup advice needed - Django + Apache2 + mod_wsgi - on Mac and Ubuntu Dev Server

I need advice if this setup is ok. I have a personal dev server which runs Ubuntu. I have setup Ubuntu completely with git, django, mod_wsgi and apache2 running. I will be developing using my Macbook Pro. My idea was to have identical directory structure on both machines off of web root. Say: Mac: /path/to/webroot/ ...

Django Model ForeignKey 2

I dont understand how I can "import"(I dont know the right terminology, so please dont crucify me on this) a Foreignkey from 1 model class to a another: e.g. class1 (models.Model): variable1 = models.CharField() variable2 = models.CharField() class2 (models.Model): variable3 = models.CharField() variable4 = class1.vari...

Django Queryset to List conversion => Data loss?

I'm trying to populate a list based on partiular members, but it doesn't seem to be going to plan. user = request.user members = [] userprofile = user.get_profile() if user.is_superuser or user.is_staff: if userprofile.countries.count() == 0: members = Member.objects.all() elif userprofile.countr...

Multiple pages html output from a .rst document in Django

I'm writing a Django app to serve some documentation written in RestructuredText. I have many documents written in *.rst, each of them is quite long with many section, subsection and so on. Display the whole document in a single page is not a problem using Django filters, but I'd rather have just the topic index on a first page, whit li...

URL is appended to WSGI script's path, why?

I have a development server set up running Apache 2.2 with mod_wsgi. I have a test project and a webapp in development setup, and they half work. When I attempt to access something other than the project's landing page, Apache appends the rest of the URL onto the path of the WSGI script and won't load the page. In httpd.conf: WSGIScrip...

Django ForeignKey which does not require referential integrity?

I'd like to set up a ForeignKey field in a django model which points to another table some of the time. But I want it to be okay to insert an id into this field which refers to an entry in the other table which might not be there. So if the row exists in the other table, I'd like to get all the benefits of the ForeignKey relationship. ...

blank space in the top of the plot matplotlib django

Hi again people :) I've a question about matplotlib bars. I've already made some bar charts but I don't know why, this one left a huge blank space in the top. the code is similar to other graphics I've made and they don't have this problem. If anyone has any idea, I appreciate the help. x = matplotlib.numpy.arange(0, max(total)) ind...

accent letter's or special (ñ) in verbose_name or help_text ?

Hi guys, how ill use accent's letter's or special characters like ñ in verbose_name or help_text? Thanks ...

Caught DoesNotExist while rendering: Photo matching query does not exist.

When I do the following inside an admin file: photo = Photo.objects.get(original_image__exact=file_name) val = photo.admin_thumbnail.url I get this error: Caught DoesNotExist while rendering: Photo matching query does not exist. Here is my class: class AdminImageWidget(forms.FileInput): """ A ImageField Widget for admin t...

Opensource real django projects

Hi folks, I'm trying to learn Django. And need something to go beyond Hello world and Polls tutorial. Could you please recomend any real project written in Django? Tried to search, but found not many. Especialy interested in usage of buildout. ...

Django utf-8 and django-mailer strangeness

Latest django mailer from trunk http://github.com/jtauber/django-mailer/tree/master/docs/ Tested with Postgresql 8.4, sqlite3 template {{ title }} forms.py #-*- coding: utf-8 -*- if "mailer" in settings.INSTALLED_APPS: from mailer import send_mail else: from django.core.mail import send_mail ... body_txt = render...

how to model the following in Django correctly.

I have the following tables. The ComponentBuild table has two columns 'comp_pn' and 'parent_pn' that are both ForeignKeys. Django is complaining Unknown column 'product_parent_pn.product_id_id. What's the correct way to model these relationship? class Product(models.Model): name = models.CharField(max_length=80) def __unicod...

Django not finding apps in virtualenv when using manage.py syncdb

My problem is in getting manage.py syncdb to run within a virtualenv. It was working fine at one point, but seems to have broken sometime around when I installed South and updated pip and distribute. Anyways, when the virtualenv is activated, I can import apps fine within the interactive interpreter. Running through mod_wsgi, the apps ...

How do you use the django 1.2 form validators?

I have been trying to use the new validators that are now included with Django. I have set the validators parameter on my fields and while I don't get an error, the validation doesn't seem to be working. Here is my console session that dupplicates the issue. Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on...

Django many-to-many problem in admin

I am essentially creating a blog application in django as a way of learning the ropes and boosting my skill level in django. I basically have a many-to-many relationship that I am having problems with in the admin site. I have two main types, Article and ArticleTag. Many Articles can belong to many ArticleTags, and the relationship shoul...