Re: Django model version control

2008-10-02 Thread Marek Stępniowski
2008/10/2 David Hall <[EMAIL PROTECTED]>:
> Marek Stępniowski wrote:
>> How does django-reversion deal with relationships between Django models?
>>
>> Version-controlling relationships between entities is an Achilles heel
>> of such applications. I have read django-reversion docs on google code
>> wiki, but I couldn't find any information on that matter.
>>
> This is best explained by example.
>
> Let's say you have two models, Foo and Bar, both under version control.
>
>  >>> class Bar(models.Model):
> ... pass
> ...
>  >>> class Foo(models.Model):
> ... bar = models.ForeignKey(Bar)
>
> If you save an instance of Foo, then the primary key of the referenced
> Bar is stored in the version.  Thus, rolling back a version of Foo will
> not roll back the version of Bar.
>
> However, Reversion allows you to create revisions that group related
> changes together:
>
>  >>> @create_revision
> ... def save_relations(foo, bar):
> ...foo.save()
> ...bar.save()
>
> This will group the two changes together.  They can then be rolled back
> as a single unit.

Thanks for reply. Your approach is simple and it works. I like it! :-)


Cheers,
-- 
Marek Stępniowski
http://stepniowski.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django model version control

2008-10-01 Thread Marek Stępniowski
On Wed, Oct 1, 2008 at 5:25 PM, David Hall <[EMAIL PROTECTED]> wrote:
>
> I've just released an open-source version control application for
> Django.  It is available for download from Google code.
>
> http://code.google.com/p/django-reversion/
>
> Features include:
>
>  - Roll back to any point in a model's history - an unlimited undo
> facility!
>  - Recover deleted models - never lose data again!
>  - Admin integration for maximum usability.
>  - Group related changes into revisions that can be rolled back in a
> single transaction.
>  - Automatically save a new version whenever your model changes using
> Django's flexible signalling framework.
>  - Automate your revision management with easy-to-use middleware.
>
> It can be easily added to your existing Django project with an
> absolute minimum of code changes.
>
> It's so far been previewed by a half dozen developers, with good
> feedback.  I'd appreciate any comments / suggestions you may have to
> offer.

How does django-reversion deal with relationships between Django models?

Version-controlling relationships between entities is an Achilles heel
of such applications. I have read django-reversion docs on google code
wiki, but I couldn't find any information on that matter.


-- 
Marek Stępniowski
http://stepniowski.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Issue with django-tagging 0.3 (svn) with models definition

2008-07-09 Thread Marek Stępniowski
On Sat, Jul 5, 2008 at 11:23 PM, Nicolas Steinmetz <[EMAIL PROTECTED]> wrote:
> Despite I read a lot of time the overview.txt on the django tagging svn
> repository, I still can't stand how to use it at my model's level. I'm
> quite new to python and may miss some elements.
>
> When diving into the register part, it says it requiers a field for tag
> which is supposed to be "tags". But what kind of type is this tag supposed
> to be ? a TagField() ?
>
> I came down to this kind of things which looks not the optimum for me (at
> least at validate & runserver step, it stops shouting...):
>
> from django.db import models
> import tagging
> from tagging.models import Tag
> from tagging.fields import TagField
>
> # Create your models here.
> class Links(models.Model):
>title = models.CharField(max_length=80)
>description = models.TextField()
>url = models.URLField()
>tags = TagField()
>
>class Admin:
>list_display = ('title', 'description', 'url', 'tags',)
>list_filter = ['title', 'tags']
>search_fields = ['title','tags',]
>
>class Meta:
>verbose_name = "Lien"
>verbose_name_plural = "Liens"
>
> tagging.register(Links)
>
> But when I try to save a link, I got :
>
> IntegrityError at /admin/links/links/add/
> tagging_taggeditem.object_id may not be NULL
>
> What did I miss ?

It seems you are running into one of django-tagging quirks.
See issue #95 [http://code.google.com/p/django-tagging/issues/detail?id=95].


-- 
Marek Stępniowski
http://stepniowski.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to create field not stored in database, but visible in admin?

2008-07-08 Thread Marek Stępniowski
How to create a field that is not stored in database, but is visible
in Django newforms-admin? (I'm assuming there is a way)

I would like to define a field which acts as a kind of proxy. Setting
and getting value of this field actually runs some defined operation
(for example executes custom SQL query) and returns it's results. This
field has a related form field which is visible in Django
newforms-admin among the form fields for other fields of containing
model.

As I'm using newforms-admin, I could add the form field to the
ModelForm of my model in ModelAdmin and define custom save method for
this form, which would execute a defined operation. But I want to have
this functionality in two my different projects, and this approach
would not be DRY.

So is there a way to create such model field? Or maybe there is a
better way to achieve what I want? Please help.


PS. Sorry for my bad English. I'm not a native speaker. If something
is not decipherable to you, just ask.


Regards,
-- 
Marek Stępniowski
http://stepniowski.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---