hi michael, sorry for not finding the needed information and thanks a lot for the link!
regards. tom On 4 Mrz., 14:31, Michael <[EMAIL PROTECTED]> wrote: > This question in various forms was asked 3 times in the last 24 hours. > Check this > outhttp://collingrady.com/2008/02/18/editing-multiple-objects-in-django-... > > On Tue, Mar 4, 2008 at 4:11 AM, tom <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I've been looking and searching for the last days to find out how i > > could fix that, but I don't get around. I did read the newforms-admin > > fieldset.py stuff, also the edit_inline_stacked.html template, but I > > still don't figure it out. > > > What i would like to do is, to have 2 Models within one form. > > > The model is: > > #-------------------------------------------------------------------------- > > -------------------------------------------------- > > class Album(models.Model): > > artist = models.ForeignKey(PortalUser) > > title = models.CharField(max_length=100) > > slug = models.SlugField(prepopulate_from=("artist", "title")) > > genre = models.ManyToManyField(Genre, > > filter_interface=models.HORIZONTAL) > > def __unicode__(self): > > return self.title > > > class Admin: > > list_display = ('title', 'rating_stars', 'artist', > > 'release_date') > > list_filter = ('label', 'release_date') > > ordering = ('-release_date',) > > search_fields = ('title', 'label') > > fields = ( > > (None, {'fields':('title',)}), > > ('Album informatin', {'fields':('cover', 'language', > > 'release_date', 'genre')}), > > ) > > > class Track(models.Model): > > artist = models.ForeignKey(PortalUser) > > title = models.CharField(max_length=100, core=True) > > file = models.FileField(upload_to="/", core=True) > > album = models.ForeignKey(Album, edit_inline=models.TABULAR, > > num_extra_on_change=1, num_in_admin=10) > > > def __unicode__(self): > > return self.title > > > class Admin: > > list_display = ('title', 'album', 'artist') > > search_fields = ('title', 'genre', 'artist') > > list_filter = ('language',) > > #-------------------------------------------------------------------------- > > -------------------------------------------------- > > > and I use the following form: > > class AlbumForm(forms.ModelForm): > > > class Meta: > > model = Album > > > with this view: > > login_required > > def add_or_edit_album(request, success_url='', > > form_class=AlbumForm, > > template_name='music/album_form.html'): > > > success_url = '/artist/%s' % (request.user.username) > > > if request.method == 'POST': > > > form = form_class(data=request.DATA, files=request.FILES) > > if form.is_valid(): > > album = form.save(commit=False) > > album.artist = request.user > > album.save() > > form.save_m2m() > > return HttpResponseRedirect(success_url) > > else: > > form = form_class() > > return render_to_response(template_name, > > { 'form': form }, > > > context_instance=RequestContext(request)) > > > what happens, when I call the template is, that only the album form > > shows up, but it does not contain the track slots. When I try to call > > the TrackForm (created the same way as the Album Form) I do get a drop- > > down box for the albums. Does someone know a way how to solve this? > > > I use the current svn version from django. > > > Many thanks! > > > Tom --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---