1

I have a model containing various entries tied to one user and I want to give the user a view where he can review these entries, select some of them and perform an action on the selection. something like the admin intereface has. I have tried UpdateView but that is for one entry only. ListView doesn't like that the model returns multiple entries for one identificator. Is there something else I could use?

EDIT: Below is the model, I am talking about. A user will have multiple model entries and I just want a view that lists these multiple entries and allows the user to perform a bulk action on them, like delete ...

class UserData(models.Model):
    class Meta:
        app_label = "app"

    user_id = models.IntegerField()
    name = models.CharField(_("Name"),max_length=100)
    latdeg = models.IntegerField(_('Latitude'))
    latmin= models.IntegerField(_('Latitude'), validators=[validate_60])
    londeg = models.IntegerField(_('Longitude'))
    lonmin= models.IntegerField(_('Longitude'), validators=[validate_60])
    main = models.BooleanField()

    def __unicode__(self):
        return user_id + "-" + self.name
Stefan
  • 828
  • 12
  • 24
  • Some code example would be useful mate. – Andrey Shipilov May 27 '17 at 07:48
  • I am searching for code myself :-) Basicaly what I need is something similar that what the django admin does - write out model entries and show action box, like delete to perform bulk action. – Stefan May 27 '17 at 07:52

1 Answers1

1

I think what you are looking for is inlineformset_factory

Since you have not given any example, I suggest you look at the example of One author, multiple books as given in this SO post.

bhaskarc
  • 9,269
  • 10
  • 65
  • 86
  • Thanks for the reply, I hoped it's not going to be formsets, they are so inconvinient to use in django .. but well, yes, it seems to be the only way. I search a litlle longer and if there is nothing better I go with formsets. – Stefan May 27 '17 at 08:04