Did some more testing now..
Some really weird behaviour in my admin add view. If I add an "Egg"
object (see above) with an e value of "test1" it works (just adds
once) but if I add with an e-value of "test 1" (extra space), two
entries are added. Two requests are sent:

[22/Jul/2009 11:13:44] "POST /admin/foo/egg/add/ HTTP/1.1" 302 0
[22/Jul/2009 11:13:44] "POST /admin/foo/egg/add/ HTTP/1.1" 302 0

This only seem to happen in django admin.I made a really simple add
view and when submitting the form only one entry is added.

 def foo(request):
     if request.method == 'POST':
         form = EggForm(request.POST)
         if form.is_valid():
             #import pdb; pdb.set_trace()
             form.save()
             request.user.message_set.create(message=u'saved it!')
             return http.HttpResponseRedirect('/foo/')
     else:
         form = EggForm()

     ctx = RequestContext(request, {'form':form})
     return render_to_response('foo.html', context_instance=ctx)


Any pointers gladly appreciated!

On 21 Juli, 19:49, JP <jeppe.peter...@gmail.com> wrote:
> Hi!
> I'm not sure why this happens but when I save a model (that has a
> foreign key) two identical entries are saved in the database (but
> diffs in id of course..).
> As there aren't really any errors I'm stumped on where to actually
> start looking. Any ideas?
>
> The models I made we're really simple tests. I don't have them here
> right now but it's more or less something silly like this:
>
> class Egg(models.Model):
>     e = models.CharField(...)
>
> class Spam(models.Model):
>    x = models.ForeignKey(Egg)
>    name = models.CharField(...)
>
> What I used:
> Django 1.0.2 (tarball)
> IE 6 (don't have a choice)
> Python 2.5.4
> Django dev. server
> cx_Oracle 5.0.1
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to