django

Django model: delete() not triggered

I have a model: class MyModel(models.Model): ... def save(self): print "saving" ... def delete(self): print "deleting" ... The save()-Method is triggered, but the delete() is not. I use the latest svn-Version (Django version 1.2 pre-alpha SVN-11593), and concerning the documentation at http://w...

what is setup.py?

Can anyone please explain, what is 'setup.py' and how can it be configured or used? ...

Django profile - user adding some objects

Hello, I'm learning Django and I have a problem. I want to have django user profile where the user can add some objects (he can add more than one) e.g. his addresses, his products and theirs description and so on. I've no idea how to do that. Thanks for any help. Best regards, LH ...

Anyone know an up-to-date (September 2009) example of file-uploading in Django?

UPDATE : thanks to posters below, it's clear that the official documentation is up-to-date. Best to read that carefully rather than skim a bunch of other pages that turn up in Google. I keep finding examples and snippets for uploading files in Django, but then reading people saying that they're out of date. Here are my basic confusio...

PostgreSQL, Foreign Keys, Insert speed & Django

A few days ago, I ran into an unexpected performance problem with a pretty standard Django setup. For an upcoming feature, we have to regenerate a table hourly, containing about 100k rows of data, 9M on the disk, 10M indexes according to pgAdmin. The problem is that inserting them by whatever method literally takes ages, up to 3 minutes...

select_related does not join columns marked with nulll=True

Hi All! I have a Django model - class NoticedUser(models.Model): user = models.ForeignKey(User, null=False) text = models.CharField(max_length=255, null=True) photo = models.ForeignKey(Photo, null=True, blank=True) article = models.ForeignKey(Article, null=True, blank=True) date = models.DateTimeField(default=dateti...

Django ORM - assigning a raw value to DecimalField

EDIT!!! - The casting of the value to a string seems to work fine when I create a new object, but when I try to edit an existing object, it does not allow it. So I have a decimal field in one of my models of Decimal(3,2) When I query up all these objects and try to set this field fieldName = 0.85 OR fieldName = .85 It will throw a ...

django view function code runs after return

Hello, I have a django view that looks like... def add_user(request): if User.objects.get(username__exact = request.POST['username']): context = { 'message': "Username already taken"} return render_to_response("mytemplate.html", context, RequestContext(request)) newUser = User(username="fre...

Raising ValidationError from django model's save method?

I need to raise an exception in a model's save method. I'm hoping that an exception exists that will be caught by any django ModelForm that uses this model including the admin forms. I tried raising django.forms.ValidationError, but this seems to be uncaught by the admin forms. The model makes a remote procedure call at save time, and ...

Django Admin: Ordering of ForeignKey and ManyToManyField relations referencing User

Hello, I have an application that makes use of Django's UserProfile to extend the built-in Django User model. Looks a bit like: class UserProfile(models.Model): user = models.ForeignKey(User, unique=True) # Local Stuff image_url_s = models.CharField(max_length=128, blank=True) image_url_m = models.CharField(max_length=...

Nginx doesn't serve static

I'm running django on ubuntu server 9.04 Django works well, but nginx doesn't return static files - always 404. Here's the config: server { listen 80; server_name localhost; #site_media - folder in uri for static files location /static { autoinde...

Python Django Config Question

I am getting this error, how would I go about fixing this? daniel@daniel-toshiba~ $ python Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import django Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportErr...

Python Question about global counter in Django Application?

Hi Everyone I was wondering if there is "global counter" in Django application, like the way I store "global counter" in Servlet Context scope in Tomcat. Thanks something like getServletContext().getAttribute("counter"); counter++; ...

Performance of concurrency in Django (apache2 prefork/mod_wsgi), what am I doing wrong?

First of all I am not in any way unhappy with the performance of my Django powered site, its not getting massive traffic, a bit over 1000 visits per day so far. I was curious how well it would cope with heavy traffic peaks so I used the ab-tool to do some benchmarking. I noticed that the performance when the concurrency is larger than ...

OneToMany in Django-Forms

Hi there, Django has the StackedInline-Feature for the Admin-Backend - is there any equivalent for django.forms? When i define a ForeignField representing a ManyToOne-Relation, it does not show up in generated forms. ...

Login code for Django

Can anyone give me some sample code with a template code to create a Django login? Thanks. ...

Cronjobs in Django

I'm writing a database application where certain parts of the database might need updates based on time, not based upon user actions. For example, there may be certain values that are updated daily, and certain other values that must be updated say, four hours after the database entry is created. Thus I need some way to update values r...

How to find which view is resolved from url in presence of decorators

For debugging purposes, I'd like a quick way (e.g. in manage.py shell) of looking up which view that will be called as a result of a specific URL being requested. I know this is what django.core.urlresolvers.resolve does, but when having a decorator on the view function it will return that decorator. Example: >>>django.core.urlresolvers...

Django timezone mess

I'm working on a localized Django app with a simple forum. Some posts' timestamps show up as if they were posted 7 hours earlier. What's weird is that it happens to some users, sometimes (a user may post once and it's OK, posts again and it's wrong). settings.py: TIME_ZONE = 'Europe/Prague' LANGUAGES = ( ('cs-cz', _('Czech')), ) DATAB...

How to get the django Current login user?

How to get the django Current login user? ...