Disable single instance of a system check warning

2018-02-09 Thread Mattias Linnap
Hi djangonauts, > System check identified some issues: > HINT: ForeignKey(unique=True) is usually better served by a OneToOneField. I would like to keep using ForeignKey(unique=True) for this particular model, and mark the warning as disabled for this model only (keep it enabled project-wide

Queryset .count() breaks when counting distinct values generated by .extra()

2015-01-18 Thread Mattias Linnap
Hi all, I think I've found a strange case where QuerySet.count() does not match len(queryset), and the behaviour is certainly unexpected. But I'm not sure whether this is a bug, some mistake on my part, or a known limitation of combining .extra(), .distinct() and .count(). I am aware of the

Why are DateTimeField auto_now and auto_now_add bad?

2014-07-27 Thread Mattias Linnap
Hi all, I've seen DateTimeField's auto_now and auto_now_add parameters often described as "buggy" or "error-prone". For example: https://code.djangoproject.com/ticket/22995 https://groups.google.com/forum/#!topic/django-developers/TNYxwiXLTlI The ticket proposes to document these downsides or

Re: Restrict access to user-uploaded files to authorized users

2013-09-25 Thread Mattias Linnap
> Are there any obvious solutions that I have over looked? Or am I stuck having to use django to serve the files? Depending on the security that you aim to achieve, one option would be to add a custom file storage implementation that overrides

Server-side validation for complex ajax forms

2013-09-25 Thread Mattias Linnap
Hi all, I have been asked to build a single-page, ajax based data entry interface for a moderately complex set of models. There are 5 models, linked into a tree structure by foreign keys. The number of children for each model is variable, so there could be up to 4 levels of nested formsets. I

Re: how to evaluate "cities/countries of the world" static table for an application.

2013-02-26 Thread Mattias Linnap
https://github.com/coderholic/django-cities parses the GeoNames export, and makes it very easy to integrate into Django apps. On Tue, Feb 26, 2013 at 11:32 AM, Daniel Blasco wrote: > This is a useful resource http://download.geonames.org/export/dump/ > > > On Monday, February

Multiple model inheritance

2012-12-31 Thread Mattias Linnap
Hi all, I would like to define multiple abstract base models with small set of fields each. The "real" models inherit from multiple mixins to add the fields. For example: class Taggable(?): tag = models.CharField() class Visible(?): visible = models.BooleanField() class SomeFullModel(?,

Re: Django admin runs out of memory with ForeignKeys to large tables

2012-09-05 Thread Mattias Linnap
l editable=False fields show up as readonly: after all, their data is still interesting to look at, just should not be editable. Mattias On Wed, Sep 5, 2012 at 1:37 PM, Mattias Linnap <matt...@linnap.com> wrote: > Hi all, > > I have a model X that references another model Y with a For

Django admin runs out of memory with ForeignKeys to large tables

2012-09-05 Thread Mattias Linnap
Hi all, I have a model X that references another model Y with a ForeignKey. There are very few Xs, but close to a million Ys in the database (and it will grow considerably in the future). This causes MemoryErrors in the Django built-in admin pages: the ForeignKey is rendered as a select box

Re: Overriding save to create and save related entity

2012-07-25 Thread Mattias Linnap
It is possible to override the save() method in a model to add functionality: https://docs.djangoproject.com/en/dev/topics/db/models/#overriding-model-methods Another choice would be to register a receiver for the pre_save or post_save signals:

Various thoughts on authentication, registration and social logins

2012-06-17 Thread Mattias Linnap
Hi all, I'm trying to build a nice authentication flow for a website. In my opinion, a good flow would be: 0. There are no usernames, emails are used instead, 1. User signs up by just entering their email address, 2. An account is created for them, and a temporary plaintext password, along with

What is the best way to implement time-based / cronjob actions in a Django app?

2010-10-13 Thread Mattias Linnap
Hi Django users, I'm building an application with Django, and I need some database changes to occur at certain times in the future - independently of any web request. Things like cleaning up expired sessions, deleting expired user actions, etc. What is the best way to implement those? 1) Make a

Django 1.2 and unittest2 - does this hack work?

2010-09-12 Thread Mattias Linnap
I'm using Django 1.2.3 with Python 2.6. I would like to use the new fancy unittest asserts available in Python 2.7. These have been backported to Python 2.6 as the unittest2 module (http://www.voidspace.org.uk/python/articles/unittest2.shtml). But at the same time, I would like to use test