django-tables2
django-tables2 copied to clipboard
CSRF with render_foo
First off, my apologies if this is my error... I am new to django and django_tables2 and trying really hard...
The Project:
I am building an intranet app that pulls data from multiple sources, adds them to the db, then lists them using a searchable, sortable table
Environment:
Python (venv) 3.8.2 Django: 2.2.12 Django-tables2: 2.3.1
The Goal:
- A bootstrap 4 (ish) styled table displaying a searchable & sortable list of data.
- A clickable "link" listed under the data for column 3 using a render_foo()
- Clicking will call a python function
- Function will return a pass / fail
- Currently using a button styled like a link
- Status returned eventually as a JS alert instead of loading a new page
What is working:
- A bootstrap 4 (ish) styled table
- A clickable "link" listed under the data for column 3 using a render_foo()
What isn't working:
- When I click the link I get a 403 forbidden error
- I added the following to my html after the render_table:
``` csrftoken: {{ csrftoken }}<br>
csrf_token: {{ csrf_token }}
```
- I added code to my button to set the csrftoken as a tooltip for the link
- When compared they look like this:
- html: ```Ldjjb8kjcGP3Y```
- button: ```yBqUw5ySKSxs```
Questions / Thoughts:
- Am I overcomplicating this?
- Is there a simple way to fix this?
- Is there a way to pass the csrf during render?
- Looking at the tutorial & example scripts it seems to work fine, but I don't see any render_foo examples?
#Edits:
- Complete re-write.
On second thought... cleaning this up causes less clutter
Code pastebin coming next.
Code pastebin: https://bpa.st/NB2Q
If anyone is willing to help me troubleshoot hit me up on discord: Compugician#1371
This is an issue tracker to report bugs and request features, not a place to ask for help on using the library. Please use stackoverflow and tag your question with django-tables2