Skip to content

Form is rendered in Request Vars panel #367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sneawo opened this issue Apr 2, 2013 · 6 comments
Closed

Form is rendered in Request Vars panel #367

sneawo opened this issue Apr 2, 2013 · 6 comments
Labels

Comments

@sneawo
Copy link

sneawo commented Apr 2, 2013

If form is passed through urls kwargs, it's rendered.

    url(r"^invite/$",
        "friends_app.views.invite",
        kwargs={"template_name": "friends_app/invite_postcard.html", 
                             "form_class": InviteForm},
        name="invite"),

Screen Shot 2013-04-02 at 10 57 47

@lucasicf
Copy link

lucasicf commented Apr 5, 2013

Could reproduce the bug. I'll try to fix it.

@lucasicf
Copy link

lucasicf commented Apr 5, 2013

Here lies the problem:

{% for k, v in view_kwargs.items %}
    {{ k }}={{ v }}{% if not forloop.last %}, {% endif %}
{% endfor %}

It shows the kwargs in the format "key=value". However, in the class_form attribute, the {{ v }} is the form, thus it renders it normally.

@lucasicf
Copy link

lucasicf commented Apr 5, 2013

What do you guys think about this solution I've written?
https://github.com/lucasicf/django-debug-toolbar/commit/b3df0e42c698a99d9c5ccb1f8cd482d9312e1b7d
I'm converting all the args to its string representation before passing to the view for them to be safe when displaying.

@lucasicf
Copy link

lucasicf commented May 1, 2013

Bringing here the discussion from my commit.

@sneawo commented on b3df0e4 (23 days ago)
Looks good for me. Why not use str(arg)?

@lucasicf commented on b3df0e4 (5 minutes ago)
To avoid possible problems with unicode strings, but I tested some code and saw that it does not make difference.

'%s'%object calls __str__ and u'%s'%object calls __unicode__. There's no risk of getting an unicode string and trying to convert it to 8-bit strings.

I'll change it and send a pull request.

@aaugustin
Copy link
Contributor

#418 describes a more holistic fix for this category of issues.

@aaugustin
Copy link
Contributor

This was fixed in 982f341.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants