I've been trying for the past week or so to make a rather simple view work the way I think it should, and I keep failing miserably.
What I'd like to do is to extend the user model with an app by allowing a user to supply one piece of information about themselves, their twitter user name. I could do this with the AUTH_PROFILE_MODULE setting, but I want to extend the user model with other apps in the future, and not to use the normal way here. So, it seems to me that I need to use user as a foreignkey, and that I need to add a piece of information about them to the database. So far, I've come up with a view that looks like this: @login_required def index(request): # If they did a post, then submit the data & redirect the user to / modules if request.method == 'POST': form = twitterForm(request.POST) if form.is_valid(): #Then we save the data to the database form = form.cleaned_data current_user = get_object_or_404(request.user, pk=request.user.id) t = TwitterModel( user= current_user, twitter_username= form['twitter_username'], ) t.save() return HttpResponseRedirect('/modules/') # If they did not do a post, show them the form. else: form = twitterForm() return render_to_response('twitter/index.html', {'form': form}) That's pretty basic. The problem is that it tries to do an insert EVERY time it is completed, which isn't what I intended. If the insert has already been done, it needs to do an update, and vice versa. Can somebody make sense of where I went wrong here? I'm new to django, and this is giving me a huge headache (metaphorically, that is). --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---