Jeremy,
I tried and it still doesn't work. Below are part of my models.py and
views.py files:
models.py
class Delivery(models.Model):
name = models.CharField(maxlength=100)
url = models.CharField(maxlength=100)
class Orders(models.Model):
s_name = models.CharField("Name", maxlength=100, blank=True)
s_address = models.CharField("Shipping Address", maxlength=100,
blank=True)
s_city = models.CharField("Shipping City", maxlength=100,
blank=True)
s_state = models.USStateField("Shipping State", blank=True)
s_zip = models.CharField("Shipping Zip", maxlength=100,
blank=True)
delivery_method = models.ForeignKey(Delivery, null=True,
blank=True)
/
views.py
def success(request):
o = Orders()
o.s_name = request.session['orderdetails']['s_firstname'] + " " +
request.session['orderdetails']['s_lastname']
o.s_address = request.session['orderdetails']['s_address']
o.s_city = request.session['orderdetails']['s_city']
o.s_state = request.session['orderdetails']['s_state']
o.s_zip = request.session['orderdetails']['s_zip']
o.save()
/
Notice how when I'm creating a new order in my view I don't specify a
value for o.delivery_method.
Here is the error that I'm getting when I get to o.save():
IntegrityError at /plush/cart/success/
plush_orders.delivery_method_id may not be NULL
//
Thanks for any help
On Oct 11, 12:41 am, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 10/11/07, Greg <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Hello,
> > I have the following field in my Orders class
>
> > delivery_method = models.ForeignKey(Delivery)
>
> > I want to be able to add a Order record and not specify a Delivery
> > option when the order is initially created.
>
> > I've tried
>
> > delivery_method = models.ForeignKey(Delivery, null=True)
> > and
> > delivery_method = models.ForeignKey(Delivery,blank=True)
>
> > However, when I do this I get the error 'This field is required'
>
> Try it with both.
> null=True, blank=True
>
> null is DB-specific. blank is validation-specific.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---