Skip to content
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

Search Example: Error Checksum when setting component value #690

Open
pfisterjonas opened this issue May 13, 2024 · 1 comment
Open

Search Example: Error Checksum when setting component value #690

pfisterjonas opened this issue May 13, 2024 · 1 comment

Comments

@pfisterjonas
Copy link

Hey Adam,

I've been using Django Unicorn a lot (great stuff) and currently trying to implement a dynamic search with dynamic filters.

I have encountered the following problem -->

Let's user your Search Example:

class RecommendationsView(UnicornView):
    template_name = 'unicorn/browser/recommendations.html'

    some_value = ''

    state = ""

   

 ALL_STATES = (
        "Alabama",
        "Alaska",
        "Arizona",
        "Arkansas",
        "California",
    )

    def clear_states(self):
        self.state = ""

    def states(self):
        if not self.state:
            return []
        
        self.some_value = 'foobar'

        return [s for s in self.ALL_STATES if s.lower().startswith(self.state.lower())]

    class Meta:
        exclude = ("ALL_STATES",)

My template looks like this:


<div>
    <label>State typeahead</label><br />
    <input type="text" unicorn:model="state" placeholder="State name" id="state-name"></input>

    <p>
        {{some_value}}
    </p>

    <p>
        Matching states:

        {% if states %}
        <ul>
        {% for s in states %}
        <li>{{ s }}</li>
        {% endfor %}
        </ul>

        <button unicorn:click="clear_states">Clear result</button>
        {% else %}
        n/a
        {% endif %}
    </p>
</div>

When i start a search, i get the following in the console: Error: Checksum does not match

Is this intended behaviour?

I need to be able to store some of the values from the search function for the user.
Best,
J.

@adamghill
Copy link
Owner

When i start a search, i get the following in the console: Error: Checksum does not match

Hmm, no that shouldn't happen. Do you have a CACHE specified in your settings?

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

No branches or pull requests

2 participants