Re: Django ModelForm user best practices

2012-06-02 Thread Peter of the Norse
https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form has a highlighted note about this very issue. The way they recommend is: (based on #1 below) initial_notification = Notification(user=self.request.user, board=..., post=...) form =

Re: Django ModelForm user best practices

2012-05-31 Thread RM
Good point. You can display the value but again.. you need to make sure it's a proper (not changed via post) value (clean() / save()) W dniu środa, 30 maja 2012 22:25:35 UTC+2 użytkownik Alexandr Aibulatov napisał: > > For example on second method i can change post, board id's via html, > and

Re: Django ModelForm user best practices

2012-05-30 Thread Alexandr Aibulatov
For example on second method i can change post, board id's via html, and write to board where i can be banned. I think we shoudn't override standart methods if we con don't override them(this about third method) P.S. sorry for my terrible english. 2012/5/31 Kurtis Mullins

Re: Django ModelForm user best practices

2012-05-30 Thread Kurtis Mullins
> On second method some experience users can > override hidden data For the second method, you'd just use -- class Meta: fields = ('board', 'post', 'name') to prohbit anyone from trying to override the 'user', if that's what you're talking about. > And it's a bad idea to > override __init__ and

Re: Django ModelForm user best practices

2012-05-30 Thread Alexandr Aibulatov
I think that the first method is the most usefull. On second method some experience users can override hidden data. And it's a bad idea to override __init__ and save method in my humble opinion/ 2012/5/31 RM : > Say there's a model: > > class Notification(models.Model): >    

Re: Django ModelForm user best practices

2012-05-30 Thread Kurtis Mullins
I tend to put as much functionality in my forms as possible. I've asked a similar question before (many months ago) and I believe that was the consensus. One advantage is you can re-use your forms (and its save functionality) for your Create and Update views. On Wed, May 30, 2012 at 3:45 PM, RM

Django ModelForm user best practices

2012-05-30 Thread RM
Say there's a model: class Notification(models.Model): user = models.ForeignKey(User) board = models.ForeignKey(Board) post = models.ForeignKey(Post) name = models.CharField() class Meta: unique_together = ('user', 'name', 'post', 'board') #i know