0

I am getting the following error: How can I fix it?

File "/Users/rjeudy/PycharmProjects/virtualenv/virtualenv/src/products/forms.py", line 35 def clean_title(self, *args, **kwargs): ^ TabError: inconsistent use of tabs and spaces in indentation

        def clean_title(self, *args, **kwargs):
            title = self.cleaned_data.get("title")
            if "CFE" in title:
                return title
  • 2
    In your indentation, sometimes you're using tabs, and sometimes you're using spaces. It's inconsistent. Consistently use one or the other - spaces are standard for Python. – user2357112 May 24 '20 at 18:33
  • Also try: 1) Select the code 2) Shift+Tab 4 times. 3) Then use Tab to make the code. – Chris P May 24 '20 at 18:47
  • Does this answer your question? ["inconsistent use of tabs and spaces in indentation"](https://stackoverflow.com/questions/5685406/inconsistent-use-of-tabs-and-spaces-in-indentation) – Adrian W May 24 '20 at 19:32

2 Answers2

1

The problem is that you are using both tabs and spaces inconsistently.

(https://medium.com/@peey/what-is-the-inconsistent-use-of-tabs-and-spaces-in-indentation-error-and-why-is-it-caused-f3bbb8b2568b)

If you use vim as your text editor you can fix this with ':retab'

CircuitSacul
  • 1,594
  • 12
  • 32
0

Welcome to SO.

It's your indentation. If you're using PyCharm you can reformat your code and or auto-indent the lines.

In the taskbar: code -> auto-indent lines.

https://www.jetbrains.com/help/pycharm/reformat-and-rearrange-code.html

Max Lyman
  • 13
  • 6