🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.python
2 messages
2 total messages Started by PawelM Sat, 04 Apr 2009 18:00
Django: ModelForm z dwoch modeli (powiazanych przez OneToOne)
#25939
Author: PawelM
Date: Sat, 04 Apr 2009 18:00
21 lines
1164 bytes
Witam,
Mam dwa modele:

class Profile(models.Model):
    user = ...
    name = ...
    ...

class IMData(models.Model):
    profile = models.OneToOneField(Profile)
    gg = ...
    ....

Oraz Form:

class ProfileForm(forms.ModelForm):
    class Meta:
        model = Profile

Generowana formatka daje mozliwosc edycji tylko pol z modelu Profile. Czy da 
sie do niej dorzucic takze pola z IMData i przy save zapisać oba modele?
Re: Django: ModelForm z dwoch modeli (powiazanych przez OneToOne)
#25940
Author: Piotr Husiatynski
Date: Sat, 04 Apr 2009 18:04
29 lines
1546 bytes
Dnia 04.04.2009 PawelM <stahsNIESPAMUJ@DO_USUNIECIAgazeta.pl> napisał/a:
> Witam,
> Mam dwa modele:
>
> class Profile(models.Model):
>     user = ...
>     name = ...
>     ...
>
> class IMData(models.Model):
>     profile = models.OneToOneField(Profile)
>     gg = ...
>     ....
>
> Oraz Form:
>
> class ProfileForm(forms.ModelForm):
>     class Meta:
>         model = Profile
>
> Generowana formatka daje mozliwosc edycji tylko pol z modelu Profile. Czy da 
> sie do niej dorzucic takze pola z IMData i przy save zapisać oba modele?

Kiedyś się o to pytałem. Zalecanym sposobem jest utworzenie dwóch formularzy.


-- 
pozdrawiam
Piotr Husiatyński
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads