On Nov 11, 4:09 pm, phred78 <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to build a small Ecard app using Django but I've been
> running into all sorts of problems and can't get around them. I was
> hoping some of you more advanced programmers could give me a few
> hints.
>
> These are my models:http://dpaste.com/hold/90019/
> (FileBrowseField and product_name are just related to the storage of
> cards and it works fine)
>
> And I've created these views:http://dpaste.com/hold/90022/
>
> What I intend to do is receive a series of arguments from a Flash
> interface, so that the url will look like this:
>
> /ecards/preview/1/?
> sender_name=AAAAA&sender_email=AAAAA&recipient_name=AAAAA&recipient_email=AAAAA&subject=AAAAA&message=AAAAA&language=AAAA
>
> My url conf looks like this: (r'^ecards/preview/(?P<ecard_id>\d+)/$',
> 'childrenshouse.views.ecard_preview'),
>
> preview/1/ relates to the EcardStorage id so that I can retrieve the
> correct SWF from the database and show it on preview, and the
> arguments write data in Flash variables so they appear correctly
> inside the SWF.
>
> This is what the preview template looks like:http://dpaste.com/hold/90024/
> And my forms.py:http://dpaste.com/hold/90025/
>
> So the idea is that you have a Flash interface that lists every
> available EcardStorage item (this comes from simple XML), then passes
> all information to the URL. I should then be able to catch everything,
> display and store inside hidden form fields.
> Everything is going well so far, except instead of getting a numeric
> id for the EcardStorage, the hidden field shows the title and when I
> submit I can't get the form to validate:http://dpaste.com/hold/90029/
>
> What I am doing wrong? My biggest problem seems to pass the
> EcardStorage id to the Ecard table. I just doesn't work...
> Anyone has any ideas?
>
> Thanks,
>
> Fred

In your view, you're being passed a variable 'ecard_id' as an integer
from the URL, but then you're overriding that in the first line:
ecard_id = get_object_or_404(EcardsFiles, pk=ecard_id)
so now ecard_id is actually an EcardsFiles object, not an ID. When you
then pass ecard_id as the initial value of the 'ecard' field in the
form, it uses the unicode representation of the object, which is why
you're seeing the title.

If you just pass the ID in directly, your form should work. Note that
you aren't ever using the values of the existing EcardFiles instance,
so these will always be overridden by the GET parameters - not sure if
that's what you want.

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