django

Override save_model on Django InlineModelAdmin

I have a model that has a user field that needs to be auto-populated from the currently logged in user. I can get it working as specified here if the user field is in a standard ModalAdmin, but if the model I'm working with is in an InlineModelAdmin and being saved from the record of another model inside the Admin, it won't take. ...

Is Piston ready for OAuth?

I tried using Piston for a simple API, hoping to use its OAuth support. But the first time I hit the endpoint after enabling OAuth, I got an error: TemplateDoesNotExist: oauth/challenge.html and sure enough, there is no such file. Does OAuth work in Piston? Am I making a stupid n00b mistake? ...

Django ease of building a RESTful interface

I'm looking for an excuse to learn Django for a new project that has come up. Typically I like to build RESTful server-side interfaces where a URL maps to resources that spits out data in some platform independent context, such as XML or JSON. This is rather straightforward to do without the use of frameworks, but some of them such as R...

What is simplest way join __contains and __in?

I am doing tag search function, user could observe a lot of tags, I get it all in one tuple, and now I would like to find all text which include at least one tag from the list. Symbolic: text__contains__in=('asd','dsa') My only idea is do loop e.g.: q = text.objects.all() for t in tag_tuple: q.filter(data__contains=t) EDIT: Now...

Negative custom Django admin FilterSpec

I'm working on a custom Django Admin FilterSpec (covered already on SO #991926). My FilterSpec is a replacement for the default filter on ForeignKey(User), and basically replaces the list of all users with three only choices, all, mine, and others. For example, if I applied the custom filterspec to the field created_by it would add an ...

Django error opening SQLite3 db file on when running off Apache

Hey guys, I got this error: OperationalError at / unable to open database file Things I've tried so far are setting the absolute path of my dev.db file in the settings.py. I've tried adding www-data to my admin group and setting the group of my project folder to the admin, and setting the group to www-data, none of which solved the p...

Django url template tag: 'module' object has no attribute 'views'

The tag in question: < a href="{% url django.contrib.auth.views.login %}">Login< /a> URLConf: from django.contrib.auth import views ... (r'^login/$',views.login, {'redirect_field_name' : '/' }) ... ...

Problem getting started with GeoDjango

As soon as I add "from django.contrib.gis.db import models" instead of "from django.db import models", Django stops recognizing the app and gives this error: Error: App with label location could not be found. Are you sure your INSTALLED_APPS setting is correct? The error goes away as soon as I comment out "from django.contrib.gis.db i...

GAE Django template and swedish characters

Hi, I'm trying to render templates of an html-page that contains swedish characters "åäö" but when it renders in the web browser it ends up with "�". The page renders in UTF-8. Is there any way to workaround this or do I need to write the chars as html-code? Also any pointers to the best support for multi-lang site? ..fredrik ...

Django fetch model objects based on time with interval on the model itself

I'm trying to fetch all expired objects for a model in my Django application. The model looks like this: MyModel(models.Model): owner = models.ForeignKey(User) last_check = models.DateTimeField(blank=True, null=True) interval = models.IntegerField(default=1800) I need to fetch all matching objects where last_check is earl...

Why isn't psycopg2 executing any of my SQL functions? (IndexError: tuple index out of range)

I'll take the simplest of the SQL functions as an example: CREATE OR REPLACE FUNCTION skater_name_match(INTEGER,VARCHAR) RETURNS BOOL AS $$ SELECT $1 IN (SELECT skaters_skater.competitor_ptr_id FROM skaters_skater WHERE name||' '||surname ILIKE '%'||$2||'%' OR surname||' '||name ILIKE '%'||$2||'%'); $$ LANGUAGE SQL; If I ...

2 mysql instances in MAC

i recently switched to mac. first and foremost i installed xampp. then for django-python-mysql connectivity, i "somehow" ended up installing a seperate MySQL. now the seperate mysql installation is active all the time and the Xampp one doesnt switch on unless i kill the other one. what i wanted to know is it possible to make xampp work ...

Production quality Python opensocial container and client?

Hi Is there any production quality library for developing opensocial containers and clients in python and django? ...

Set Django model field with a method.

I'm trying to set title_for_url but it shows up in my database as "<property object at 0x027427E0>". What am I doing wrong? from django.db import models class Entry(models.Model): def _get_title_for_url(self): title = "%s" % self.get_title_in_url_format() return title AUTHOR_CHOICES = (('001', 'John Doe'),) ...

Remove the comment variable from URL after posting (django)?

When I post a comment with the django's comment framework, I have a hidden next value set in hopes that once the comment is posted, it will bring the user to view their own comment. The next field renders like this: <input type="hidden" name="next" value="http://example.com/item/1#c23" /> However, when a comment is posted, django is ...

Save FileField file uploads someplace other than MEDIA_ROOT?

Can I use FileField to handle a file, but store it someplace not under MEDIA_ROOT/MEDIA_URL but somewhere else entirely. Seeking is to ensure it is not downloadable; although denying read permissions would do the trick here's hoping for something better... like a different directory altogether. ...

Programatically saving an image to a Django ImageField is creating an infinite loop of images

I've got a save method on a model that looks like so: def save(self, force_insert=False, force_update=False): img_url = "http://example.com/%s.jpg" % (self.title) name = urlparse(img_url).path.split('/')[-1] content = urllib.urlretrieve(img_url) self.image.save(name, File(open(content[0])), save=True) super(Test, sel...

Django auto_now and auto_now_add

For Django 1.1. I have this in my models.py: class User(models.Model): created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) When updating a row I get : [Sun Nov 15 02:18:12 2009] [error] /home/ptarjan/projects/twitter-meme/django/db/backends/mysql/base.py:84: Warning: Column 'crea...

Django: debugging entries just disapearing

So, I'm pulling my hair out here, and maybe someone has an insight. I have a cronjob that loops over all my Link objects, does some stuff, might change properties on the object and does a save(). That's it. Every so often (around once an hour), one of my rows just disappears. Poof. Nothing in the logs. So, I'm trying to add debugging...

object_list of multiple models in django

I have multiple abstract models similar to this Class Article(models.Model): title = models.CharField() body = models.TextField() created_date = models.DateTimeField() author_name = models.CharField() class Video(models.Model): title = models.CharField() body = models.TextField() created_date = models.DateTi...