Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

'str' object has no attribute 'method'  #262

Open

Description

@jquiroz90

Describe the bug

Form input within 2nd level subpages

Steps to reproduce

-Home page already has form input

  • If a sub page of the site has a form input, nothing happens
  • When a second level sub page (root-page/1st-level-subpage/2nd-level-subpage) has form input, error triggers.

Expected behavior

The form input should be displayed and works flawlessly, not caring about if it's 1st, 2nd or so on... level of subpages.

Additional context

Exception location: page_models.py line 1356 (if request.method == 'POST':)

def get_form(self, request, *args, **kwargs):
        form_class = self.get_form_class()
        form_params = self.get_form_parameters()
        form_params.update(kwargs)
        if request.method == 'POST':
            return form_class(request.POST, request.FILES, *args, **form_params)
        return form_class(*args, **form_params)

Activity

  1. added
    Type: Bug
    on Oct 2, 2019
  2. corysutyak commented on Oct 2, 2019

    @corysutyak

    I have a page preview block using the form inputs template on the home page that is targeting home/subpage-1/subpage-2. subpage-2 is a Form Page with a text input and a dropdown input. This error is not triggering on coderedcms v.0.16.3. Is there additional context I am missing to replicate the error?

  3. vsalvino commented on Oct 2, 2019

    @vsalvino
    Contributor

    Thanks for the steps to reproduce. Just so I understand clearly...

    Home page (Web Page) - contains page preview block of subpage
    |- subpage (Form Page) - contains page preview of sub-subpage?
      |- sub-subpage (Form Page)
    
  4. jquiroz90 commented on Oct 2, 2019

    @jquiroz90
    Author
    Home page (Web Page) - contains page preview block of subpage
    |- subpage (Web Page) - contains page preview of subpage
    |- subpage* (Form Page) - It's hidden
      |- sub-subpage (Article Landing Page) - contains page preview of subpage*
    

    Then home-page and subpage are broken.

  5. vsalvino commented on Oct 2, 2019

    @vsalvino
    Contributor

    So subpage contains a preview of itself? If that is the case then it would definitely break. If subpage contains a preview of subpage* then it should work in theory, although it would likely break if subpage* is unpublished.

  6. jquiroz90 commented on Oct 2, 2019

    @jquiroz90
    Author

    No, it doesn't contain a preview of itself, form page is another one. But, yes, it's unpublished.

  7. vsalvino commented on Oct 2, 2019

    @vsalvino
    Contributor

    Try publishing the page. I believe that is the problem.

  8. jquiroz90 commented on Oct 2, 2019

    @jquiroz90
    Author

    I published it but the problem still persists

  9. vsalvino commented on Apr 11, 2020

    @vsalvino
    Contributor

    Closing due to inactivity / needs more info to reproduce the problem.

  10. pascalthivierge commented on Dec 10, 2020

    @pascalthivierge

    I get the same problem when using form page preview on an article page : 'str' object has no attribute 'method'.

    Home page (Web Page)
    |- subpage (Article Index Page)
    |- sub-subpage (Article Page) - page preview of form page
    |- subpage (Form Page)

  11. pascalthivierge commented on Dec 10, 2020

    @pascalthivierge

    I'm using Wagtailtrans, but I doubt it would be the problem.

  12. pascalthivierge commented on Dec 10, 2020

    @pascalthivierge

    I should add that the page preview of a form input on a standard web page works... but not on an article page under article page index.

  13. vsalvino commented on Dec 10, 2020

    @vsalvino
    Contributor

    Can you confirm that the site name and port under Settings > Site is correctly set? i.e. it should match your domain (www.example.com) and port (80 for http, 443 for https).

  14. pascalthivierge commented on Dec 11, 2020

    @pascalthivierge

    yes, the hostname match my domain name and using https with port 443

  15. Boomacroom commented on Dec 30, 2020

    @Boomacroom

    I'm having this issues as well.

    -Article Index Page
    --Article with Form Inputs preview (Sign up for our newsletter)
    The Article shows the inputs and accepts the form properly, I'm thinking it may have something to do with the index page grabbing the body content of the Article for the text preview.

  16. Boomacroom commented on Dec 30, 2020

    @Boomacroom

    yes, the hostname match my domain name and using https with port 443

    Using the template tag truncatewords, will give the same error.
    Commenting out the following fixed the issue for me.

    {% if self.show_preview_text %}<p>{{article.specific.body_preview}}</p>{% endif %}

  17. vsalvino commented on Jan 5, 2021

    @vsalvino
    Contributor

    Interesting, this must be related to trying to fetch child pages of the page while it is in "preview" state (it is technically not a page object during preview, it is some kind of special ephemeral preview object). This has long been a cryptic issue, thanks for investigating!

    A fix might be to add a try/except to body_preview() method, or to add special logic during render() of previews.

  18. pbspm01 commented on Sep 30, 2022

    @pbspm01

    Run into a similar error message when running a search:

    Start condition: there's a page ("Contact") with page preview block, pointing at a form ("Contact Form") ("Contact" and "Contact Form" are both children of "Home"), everything is published, no draft versions.

    • Case A) Running a search across the site, with a term that does not gives a match for "Home", Page Preview Template: "Form inputs" -> success, no error, other pages are found
    • Case B) Running a search across the site, search term should give a match for "Home", Page Preview Template: "Default" -> no error, other pages plus "Home" are found
    • Case C) Running a search across the site, search term should give a match for "Home", Page Preview Template: "Card" -> no error, other pages plus "Home" are found
    • Case D) Running a search across the site, search term should give a match for "Home", Page Preview Template: "Form inputs" -> 'str' object has no attribute 'method'

    Exception Location: /home/user/.local/share/virtualenvs/app-0IWFc-Ol/lib/python3.9/site-packages/coderedcms/models/page_models.py, line 1504, in get_form

    Error during template rendering
    In template /home/user/.local/share/virtualenvs/app-0IWFc-Ol/lib/python3.9/site-packages/coderedcms/templates/coderedcms/blocks/pagepreview_form.html, error at line 6

    'str' object has no attribute 'method'
    1 {% extends "coderedcms/blocks/base_block.html" %}
    2 {% load django_bootstrap5 coderedcms_tags wagtailcore_tags %}
    3 {% block block_render %}
    4 {% with page=self.page.specific %}
    5 {% if page.form_live %}
    6 {% get_pageform page request as form %}


    Django Version: 4.0.7
    Python Version: 3.9.2
    Coderedcms : 1.0.1


    The "Contact Form" works otherwise for submission as intended from all Page Previews (with "Form inputs") and in itself as well.


    Nonetheless, Coderedcms is some awesome work! Truly appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions