Hello,
I have a Model called 'Skin' with the attributes (1n-relationships)
game and car. Game and car stand in a m2m-relationship to each other.
Each skin can be either a skin of Game1 or Game2.
Each car (car model) can be playable in Game1 and Game2, or only in
one of these.
I want to create a form to upload a skins for either Game1 or Game2. A
ModelForm of model 'Skin' displays the dropdownboxes game and car.
The Problem is that users can choose a game and a car which is not in
the chosen game. For this I tried to first select a game, and then
display the ModelForm of 'Skin' without the game-field and only the
cars available in the chosen game. But I run into problems with the
POST parameters.
------------------------------
@login_required
def submit_skin(request):
if request.method == 'POST' and request.POST.get("game", None):
# Should be displayed 2nd
# Display ModelForm with exclude = ('artist', 'game',)
# Working
game_instance = Game.objects.get(id=request.POST["game"])
skin = Skin(artist=request.user, game=game_instance)
form = SkinForm(instance=skin)
# Here I fill data in the form and press send/submit. But:
# 1. game is not in post
# 2. it never reaches the "elif" line because the "if"-line
above is called.
elif request.method == 'POST' and not request.POST.get("game",
None):
form = SkinForm(request.POST, request.FILES, instance=skin)
else:
# Should be displayed 1st
# Display ModelForm with fields = ('game',)
# Working
form = SkinFormGame()
return render_to_response('skins/submit_skin.html', {'form':
form}, context_instance=RequestContext(request))
------------------------------
Any Ideas how to accomplish this?
-leon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---