hi malcolm,
now i'm trying that but i get the error :
"int() argument must be a string or a number, not 'QueryDict'"
why?

Hi,
this is my model

class CampaignFile(models.Model):
    chance = models.DecimalField(null=True, blank=True, default=1.0,
decimal_places=2, max_digits=3,
        help_text=_("if < 1 then a random number generator will check
if the
user is lucky enough to get this file"))
    file = models.FileField(upload_to='campaign',
        help_text=_("campaign file itself"))

    campaign = models.ForeignKey(MarketingCampaign)

    def __unicode__(self):
        return "%s: %.2f" % (self.file, self.chance)

this is my form

class FileForm(forms.ModelForm):
    class Meta:
        model = CampaignFile

this is my view

def upload_file(request, file=None):
    print "configure_FILE", file

    errors = []
    messages = []
    form = None
    if request.method == "POST":
        form=FileForm(request.POST, request.FILES)
        if form.is_valid():
            rec = CampaignFile(request.POST, request.FILES)
            rec.save()
            return HttpResponseRedirect('/')

    return render_to_response('op/upload_file.html', {'form':
form})
            #messages.append("file uploaded")

this is my html body

<form action="." enctype="multipart/form-data"
method="POST">
   <table>
        <tr>
            <td>{% trans "campaign" %}</td>
            <td><input type="text" name="campaign"
value="{{ campaign }}" ></
td>
        </tr>
        <tr>
            <td>{% trans "chance" %}</td>
            <td><input type="text" name="chance" value="{{ chance }}"
></td>
        </tr>
        <tr>
            <td>{% trans "file" %}</td>
            <td><input type="file" name="file" value="{{ file }}" ></
td>
        </tr>
        {% if messages %}
            {% for message in messages %}
            <tr><td>{{ message }}</td></tr>
            {% endfor %}
        {% endif %}
        <tr>
            <td><input type="submit" value="{% trans "Upload" %}"></
td>
        </tr>
    </table>
</form>

and this in my  url
url(r'^json/prova/', views.upload_file),

Manuel

On Mar 1, 2:49 pm, Malcolm Box <[email protected]> wrote:
> I've got this working in the past, but only by writing custom create()
> methods on the Collection and Entry classes.
>
> In the custom create() method you can process the POST/PUT data directly
> into the FileField just like you would for a normal form
>
> Malcolm
>
> On Thu, Feb 25, 2010 at 7:03 PM, manu.polline <[email protected]>wrote:
>
> > Hi everyone,
> > anyone help me??
>
> > On 22 Feb, 19:19, "manu.polline" <[email protected]> wrote:
> > > Hi everyone,
> > > my name is Manuel. I'm tryng to upload a file directly in a filefield
> > > of Django model exposed by django-rest-interface.
> > > It'is possible?
> > > this is my model :
>
> > > class File(models.Model):
> > >     file = models.FileField(upload_to='files',
> > >         help_text=_("file itself"))
> > >     page = models.ForeignKey(page)
>
> > > and my urls.py :
> > > json_File_resource = Collection(
> > >     queryset = File.objects.all(),
> > >         authentication = HttpBasicAuthentication(),
> > >     permitted_methods = ('GET', 'POST', 'PUT', 'DELETE'),
> > >     receiver = JSONReceiver(),
> > >     responder = JSONResponder()
> > > )
>
> > > urlpatterns = patterns('',
> > >     ....
> > >     ....
> > >     url(r'^json/File/(.*?)/?$',json_File_resource),
> > >     ...
> > > )
>
> > > The GET works and the PUT to other field too but not the POST or the
> > > PUT on filefield Field.
> > > How i can pass the local file to the remote Service in the JSON
> > > string?
>
> > > Please Help Me!!!
>
> > > Manuel
>
> > --
> > 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]<django-users%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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