I use Django to manage addresses. To publish the data I have a list
and a detailed view. In the detail view I can change the name,
address, phone, etc. of the person. To do that I created an edit
form.

Now, everythin is fine. Only if I try to change and save the birthday
(witch is a datefield) it doesn't work. Everthing else is no problem.
Does anybody know why I cannot save datefields?

Here is my code:

### CODE ###

## models.py ##
class Person(models.Model):
    nameLast  = models.CharField ('Nachname', maxlength = 31)
    nameFirst = models.CharField ('Vorname', maxlength = 31)
    address   = models.CharField ('Adresse', maxlength = 63)
    birthdate = models.DateField ('Geburtsdatum',   blank = True, null
= True,)
    phone     = models.CharField ('Telefon', blank = True, null =
True, maxlength = 47)

    def __str__(self):
        return "%s, %s " % (self.nameLast, self.nameFirst)

    class Admin:
        list_display = ('nameLast', 'nameFirst', 'address',
'location')
        fields = (
            ('Personalien',        {'fields': ('nameLast',
'nameFirst', 'address', 'location', 'birthdate', 'nation')}),
        )

    class Meta:
        ordering = ('nameLast', 'nameFirst',)
        verbose_name        = "Person"
        verbose_name_plural = "Personen"

class Karateka(models.Model):
    person    = models.ForeignKey   (Person, verbose_name = 'Person',
core = True)
    comment   = models.TextField    ('Bemerkung', blank = True, null =
True)

    def __str__(self):
        return "%s" % (self.person)

    class Admin:
        list_display = ('person', 'bsc', 'skr', 'dojo')

    def name_last(self):
        return "%s" % (self.person.nameLast)

    class Meta:
        ordering = ('person',)
        verbose_name        = 'Karateka'
        verbose_name_plural = 'Karatekas'
## end models.py ##

## views.py ##
def Karateka_save(request, karateka_id):
    from kav.info.models import Karateka, Country, Location, Dojo
    karateka = Karateka.objects.get(id = karateka_id)

    try:
        karateka.person.nameLast      = request['nameLast']
        karateka.person.nameFirst     = request['nameFirst']
        karateka.person.address       = request['address']
        karateka.person.phone         = request['phone']
        karateka.person.birthdate     = request['birthdate']
        karateka.comment              = request['comment']

        karateka.save()
        karateka.person.save()
    except:
        return HttpResponseRedirect("/info/karateka-%d/edit" %
int(karateka_id))

    return HttpResponseRedirect("/info/karateka-%d/" %
int(karateka_id) )
## end views.py ##


--~--~---------~--~----~------------~-------~--~----~
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