Django FileField upload is not working for me

Viewed 13020

I have been scratching my head FileField. Does the FileField require a seperate process?

Although my url gets saved .. but my file doesn't get uploaded ... what am i doing wrong?

This is my models.py ...

class OpLink(models.Model):
    user = models.ForeignKey(User)
    file = models.FileField(blank=True, null=True, upload_to="uploads")
    url = models.URLField(blank=True, null=True)

my forms.py

class OpLinkForm(ModelForm):
    class Meta:
        model = OpLink
        exclude = ('user')

my views.py

oplinkform = oplinkform(request.POST)
                oplink = oplinkform.save(commit=False)
                oplink.user = user
                oplink.save()

and my html to process it.

<div class="span5">
                            {{ oplinkform.url|add_class:"span4"|attr:"Placeholder:URL for the item" }}
                            <br><h4>OR</h4><br>
                            {{ oplinkform.file|add_class:"input-file" }}
                            <br />
                            <input class='btn btn-primary btn-large' type="submit" value='Post' name='action'>
</div>
1 Answers
Related