Thanks for the link.  Using a wrapper is one of the things I had tried.
Here is what I tried.  I *think* I'm close, but I don't see the last
little bit that I'm missing:

#### models.py
class Foo(models.Model):
   charfoo = models.CharField(maxlength=10)

class Goo(models.Model):
   chargoo = models.CharField(maxlength=10)
   foo     = models.ForeignKey(Foo, editable=False)

#### snippet from urls.py
   (r'^goo/create/foo_id/(?P<foo_id>\d+)/$',
'myproj.myapp.views.handle_goo_create'),

#### views.py
def handle_goo_create(request, foo_id):
   return django.views.generic.create_update.create_object(request,
Goo,

post_save_redirect = "/goo/%(id)s/",

extra_context = {'foo_id' : foo_id})

#### goo_form.html
{% extends "base.html" %}
{% block content %}

{% if form.has_errors %}
<h2>Please correct the following error{{ form.error_dict|pluralize
}}:</h2>
{% endif %}

<form action="" method="post">
   <!-- NOTE: i've also tried name="foo_id" and some other variations
of id="id_foo_id" etc some what at random -->
   <input type="hidden" id="id_foo" name="foo" value="{{foo_id}}">
   <label for="id_chargoo">chargoo:</label> {{form.chargoo}}
       {% if form.chargoo %}*** {{form.chargoo.errors|join:", "}}{%
endif %}
   <br/>
   <input type="submit">
</form>

{% endblock %}



When I view this page with the URL:
http://localhost:8080/goo/create/foo_id/1/

I see that the foo_id value is populated in the form, but when posted I
get:

OperationalError at /goo/create/foo_id/1/
(1048, "Column 'foo_id' cannot be null")
Request Method:         POST
Request URL:    http://localhost:8080/goo/create/foo_id/1/
Exception Type:         OperationalError
Exception Value:        (1048, "Column 'foo_id' cannot be null")
Exception Location:
        c:\Python23\lib\site-packages\MySQLdb\connections.py in
defaulterrorhandler, line 33


Any hints would be greatly appreciated.


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to