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

Django Admin Preview Broken - Forbidden (403) CSRF verification failed. Request aborted. #112

Open
sampiecz opened this issue Mar 18, 2018 · 11 comments

Comments

@sampiecz
Copy link

Hello,

I have scoured the documentation and google before coming here but I can't seem to find anything on the topic.
I run into no issues in my development environment. However, on my production machine I get some really odd behavior.
When I go to edit a model that has a MarkdownxField(), my websites navigation starts to appear, and I get a 403 error.
I don't really know how else to describe it. I have no traceback to post.
Any suggestions of how I can start troubleshooting this?

The first two images attached are just to show my admin behaves as normal.
Last two are the strange behavior I am getting.

standard2
standard
error2
error1

Thanks a bunch in advance!

@sampiecz
Copy link
Author

For whatever reason it's inheriting from my base.html and the css associated with that template.

@sampiecz sampiecz reopened this Mar 23, 2018
@sampiecz
Copy link
Author

sampiecz commented Apr 4, 2018

Suggestions anyone? For the time being I just created a template to override the django-markdownx preview -- since the preview isn't showing, my error is gone. However, it would be nice to use the preview if possible.

@sampiecz sampiecz changed the title Django Admin - Forbidden (403) CSRF verification failed. Request aborted. Django Admin Preview Broken - Forbidden (403) CSRF verification failed. Request aborted. Apr 4, 2018
@Pyvonix
Copy link

Pyvonix commented Apr 5, 2018

How do you return your CSRF TOKEN ? Does it return in the POST or store in session ??

@sampiecz
Copy link
Author

sampiecz commented Apr 5, 2018

@TheBuky Here is my current "Solution". I'm not sure what you mean by how do I return my current CSRF TOKEN? Prior to overriding the template, my admin looked like it did in the pictures. Obviously buggy, however when override the template I don't get that issue. Solely because it doesn't even load the preview container.

However, I do want to see the preview, and not have it pulling in my main web app's navigation..

Thanks in advance for the help @TheBuky

<div class="markdownx row">
    <div class="col-md-6">
        <p>testing</p>
        <!-- Django 1.10 and below -->
        {% csrf_token %}
	{{ markdownx_editor }}
        <!-- Django 1.11+ -->
            <!--       {% include 'django/forms/widgets/textarea.html' %} -->
    </div>
    <div class="col-md-6">
        <div class="markdownx-preview"></div>
    </div>
</div>

@qwergram
Copy link

@sampiecz did you by any chance achieve a more robust solution?

@sampiecz
Copy link
Author

sampiecz commented Jul 15, 2018

@qwergram I have not yet. Are you encountering something similar?

Right now, I just edited the HTML template and commented out the preview box.

@qwergram
Copy link

@sampiecz I encountered exactly what you're seeing on a personal project. Luckily I have enough flexibility to use a different library, specifically markdownify.

@sampiecz
Copy link
Author

It's really a shame, I'd prefer to use markdownx because of it's drag and drop image feature too. I'll have to checkout mardownify, thanks for the heads up @qwergram

@adi-
Copy link
Member

adi- commented Nov 2, 2018

Please update with recent code. Probably you have session csrf activated in your config.

@qwergram
Copy link

qwergram commented Nov 2, 2018

@adi- can you explain a little more what you mean? How do I deactivate "session csrf in my config"? In settings.py?

@adi-
Copy link
Member

adi- commented Nov 3, 2018

Check this one #111

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

No branches or pull requests

4 participants