views:

26

answers:

1

How do I make a Django form where the user can choose between several ways of providing the data, and I need one of them to be valid.

Say that I have a user profile where the user can choose between profile picture as URL or a imagefile:

class UserProfile(forms.Form):
    picture_url = forms.URLField()
    picture_file = forms.ImageField()
    ...

Is there any obvious way of doing this, without writing my own clean() method?

+2  A: 

Writing your own clean() method is the way to do it.

Daniel Roseman