Hello,

I am new to Django and Python but am determined to learn.  I am
creating a page that asks for some user input.  My model looks like
this:

from django.db import models
from django.forms import ModelForm

floor_plan_choices = (
        ('A', 'Square'),
        ('B', 'Rectangular'),
        ('C', 'Round'),
)

direction_choices = (
        ('360', '360'),
        ('270', '270'),
        ('180', '180'),
        ('90', '90'),
)

class Customer(models.Model):
        date_stamp = models.DateTimeField(auto_now_add=True)
        order_number = models.PositiveIntegerField(editable=False)
        first_name = models.CharField(max_length=30)
        last_name = models.CharField(max_length=40)
        email = models.EmailField()
        email_conf = models.EmailField(verbose_name='Confirm Email')
        year_built = models.PositiveIntegerField()
        period = models.PositiveIntegerField(editable=False)
        direction = models.DecimalField(max_digits=5, decimal_places=2,
choices=direction_choices)
        floor_plan = models.CharField(max_length=2,
choices=floor_plan_choices)

        def __unicode__(self):
                return u'%s %s' % (self.first_name, self.last_name)

class CustomerForm(ModelForm):

        class Meta:
                model = Customer

And my view looks like this:

from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from newsite.order.models import CustomerForm

def order(request):
        if request.method == 'POST':
                form = CustomerForm(request.POST)
                if form.is_valid():
                        form.save()

                        return HttpResponseRedirect('/order_complete/')
        else:
                form = CustomerForm()

        return render_to_response('order.html', {'form': form})

def order_complete(request):
        return render_to_response('order_complete.html')

I would like to set the order_number in my model to be equal to the
automatically assigned ID plus 10,000.  Can anybody tell me how to
achieve this?

Thanks for your help.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to