it worked -- thanks!

On Sep 8, 11:00 pm, akaariai <akaar...@gmail.com> wrote:
> On 8 syys, 22:50, Heribert <der.fro...@googlemail.com> wrote:
>
>
>
> > hi everyone,
>
> > first of all: I'm totally new to django. I did the tutorial and now I
> > want to go beyond what I've learnt there ... and write a simple app to
> > manage all my projects in some kind of a archive.
> > whenever I create a new project via the admin view, a directory with
> > the name of the project is created in the file system. but in case the
> > projects gets renamed I also want the directory to be renamed.
> > how can I compare the old and new value of a field?
>
> > in admin.py:
>
> > class ProjectAdmin(admin.ModelAdmin):
> >         def save_model(self, request, obj, form, change):
> >                 if not change: # new project
> >                         os.mkdir("some/absolute/path/" + obj.name_short) # 
> > (how would I use
> > MEDIA_ROOT here?)
> >                 else:
> >                         # rename dir from old to new obj.name_short
> >                         # but how do I know what value obj.name_short had 
> > before?
> >                         pass
>
> >                 obj.save()
>
> > thanks a lot in advance!
>
> You can probably dig that data from the form.
> form.initial.get('name_short') should have it. I haven't tested this,
> so I am not sure if this will work...
>
>  - Anssi

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

Reply via email to