Re: How do I manage the order of related objects?

2009-01-15 Thread Beres Botond
The parent object knows about all it's children. Each parent instance has a 'manager' for the set of children, like parent_instance.mychildren_set. More exactly: activity = Activity.objects.get(id=someid) activity_parts = activity.activitypart_set.all() # you can use .filter () etc. And I'm not

Re: Trouble with admin select related

2009-02-20 Thread Beres Botond
It doesn't work if you set up the list_select_related option explicitly in the ModelAdmin for Page? Or if you add the foreign key field to the list_display list. http://docs.djangoproject.com/en/dev/ref/contrib/admin/ Also have you tried just setting select_related() first, without any field opt

Re: Multiple different user profile objects - Django code design help

2009-02-20 Thread Beres Botond
To be honest I don't really see why you would need multiple user profile models, instead of having one user profile model, and each entry would define a different user profile. Of course I don't know the full details/requirementes of your project, and what exactly you are trying to do ... but I c

Re: Is there a way to dumpdata truncate to last n lines?

2010-08-30 Thread Beres Botond
Hi Steven, You can use the django-test-utils app, more specifically it's "makefixture" command, then you can just dump a single model instance if you want. Or a subset of model instances. You can see it here: http://github.com/ericholscher/django-test-utils/blob/master/test_utils/management/comman

Re: Custom attributes in Django

2010-08-30 Thread Beres Botond
Hi Sebastian, I suppose you are trying to do something like this? class CustomAttributes(models.Model): name = models.CharField(max_length=30) value = models.CharField(max_length=50) class ObjectWithCustom(models.Model): name = models.CharField(max_length=30) attributes = models.

Re: django-tagging languages and multi fields

2010-09-07 Thread Beres Botond
Hi Henrik, What are your exact requirements? Is it sufficient if you could simply translate all your tag instances (in every language you have basically the same tags for the same entry, except translated)? Or you need to be able to have possibly completely different tags for the same model insta

Re: Using group by aggregation (values().annotate()) on fields from joined table

2010-09-07 Thread Beres Botond
Hi Patrick, It *does* support this as far as I know. I've tried/used similar queries and it works ok, although ofc not with your models. Please post your model definitions for CitlData and Installation, to see if there's any issue there. Also what version of Django are you using? Best Regards, B

Re: Testing if a file has changed while saving the class

2010-03-10 Thread Beres Botond
Just a quick idea off the top of my head before going to bed :) def save(self, *args, **kwargs): super(MyModel, self).save(*args, **kwargs) # Call the "real" save() method. timestamp = os.path.getmtime(self.my_image_field.path) if datetime.datetime.now() - timestamp < VERY_

Re: overriding saving fails in loop

2010-03-10 Thread Beres Botond
Even if we ignore the infinite loop, selecting and updating every single instance of Subject at every save() of a Subject, is horribly wrong and inefficient on many levels. Exactly what kind of functionality/logic were you trying to implement? On Mar 10, 10:32 pm, Ali Rıza Keleş wrote: > Hi all,

Re: overriding saving fails in loop

2010-03-10 Thread Beres Botond
Or more specifically, why exactly do you want to reorder them all at every Subject .save()? And what exactly do you use the values in 'order' field for? On Mar 10, 11:46 pm, Beres Botond wrote: > Even if we ignore the infinite loop, selecting and updating every > single instan

Re: ModelAdmin

2010-03-10 Thread Beres Botond
You cannot directly register a form with admin, you should be registering models from myapps.forms import MyModelForm from myapps.models import MyModel class MyModelAdmin(admin.ModelAdmin): form = MyModelForm admin.site.register(MyModel, EmailAdmin) Also the form should be a ModelForm for

Re: Generic create_update with inline many-to-many

2010-03-10 Thread Beres Botond
Please copy and paste here the Model definitions for Recept, ingredient and 'verhouding' (I'm assuming this is explicitly defined, given the non-standard name) On Mar 10, 11:07 am, Marout wrote: > Hi there, > > I'm relatively new tio django and I can't get to grips with my many-to-many > relation