Thanks man, the only problem I still have is the following

class Book(models.Model):
    user      = models.ForeignKey(User)
    title     = models.CharField(max_length = 100)
    author    = models.CharField(max_length = 100)
    publisher = models.CharField(max_length = 100)
    publication_date = models.DateField()
    front_page       = models.FileField(upload_to='books')

    def __unicode__(self):
        return self.title

@csrf_exempt
@login_required
def update_book(request):
    dontvalidate = request.POST['dontvalidate']
    book_id = int(request.POST['book_id'])
    book = get_object_or_404(Book, id = book_id)
    if dontvalidate == 'yes':
        bookform = BookForm(instance = book)
    else:
        booknoteform = BookForm(request.POST, request.Files)
    if bookform.is_valid():
        bookform.save()
    return render_to_response(
        'books/update_book.html',
        {
        'bookform':bookform,
        'dontvalidate': dontvalidate,
        'is_authenticated' : request.user.is_authenticated(),
        },
        context_instance = RequestContext(request)
        )

the problem is simply that I can return back the information of the
model to be updated except that of the front_page field.
I did add enctype in the form template but this also didn't work. is
there a way out?
On Jan 18, 10:31 am, Derek <[email protected]> wrote:
> First read and 
> understand:http://docs.djangoproject.com/en/dev/topics/forms/modelforms/
>
> Then:
> 1.http://stackoverflow.com/questions/1645444/django-modelform-accessing...
> 2.http://neverfear.org/blog/view/123/Auto_Generate_Forms_With_Django_s_...
>
> On Jan 16, 8:43 am, Benchouia Ahmed Abdelhakim <[email protected]>
> wrote:
>
> > Hello there,
>
> > I am new to django developement model.  If someone know
> > 1- how to access to the ModelForm fields instance in the view?
> > 2- I am trying to developpe a website that contains many forms,  is
> > there a way to make the same template (new and update) for a given
> > model.Models class
>
> > thanks,

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