So you need dynamic form as below
Class MyForm(forms.ModelForm):
fields
...
def __init__(self, user,*args , **kwargs):
super(MyForm,self).__init__(*args,**kwargs)
if user is not superuser :
Hi, is there a way to have a field editable by the superuser but not
by another logged in user, in the admin area?
The rest of the model should be editable by the logged in user.
example:
class Test(models.Model):
title = models.CharField(max_length=150)
page = models.TextField()
So pag
Was a "look all the fields type before asking problem" ...
I've solved with HiddenField and disabled option ...
class RuoteForm(forms.Form):
line_name = forms.ChoiceField(choices=get_lines(),
widget=forms.HiddenInput)
prefix = forms.ChoiceField(choices=get_prefixes(),
widget=forms.Hidde
Off the top of my head, not necessarily the cleanest way of doing
this but it should work. Pass the request.user as user if this is
the user that the form is for:
i.e.
return (render_to_response('form_template', {'user': request.user,
'form': form})
the template could then look something l
I have some models like :
class UserOfSomeStuff(models.Model):
[...]
class AvailableStuffToUse(models.Model):
[...]
class CurrentlyUsedStuff(models.Model):
user = models.ForeignKey(UserOfSomeStuff)
used_stuff = models.ForeignKey(AvailableStuffToUse)
In my application I don't n
5 matches
Mail list logo