-1

I am new in python as well as Django. i got error (IndentationError: unindent does not match any outer indentation level) line 36 model.py

below is my code enter image description here

class Load_ProviderRegistration(models.Model):
    def number(): // i got error in this line 
        no = Load_ProviderRegistration.objects.count()
        if no == None:
            return 1
        else:
            return no + 1
    Load_Provider_id = models.IntegerField(unique=True,default=number)
    Load_Provider_name = models.CharField(max_length=50)
    address = models.CharField(max_length=100)
    contact = models.CharField(max_length=13)
Nrzonline
  • 1,600
  • 2
  • 18
  • 37
Jeet Kumar
  • 55
  • 1
  • 7

1 Answers1

0

There are a few things to note here:

  1. Mixing tabs and spaces is not allowed in python. Using 4 spaces as an indention level is adviced by PEP8 or read this related SO question.

  2. Passing the self as the methods first argument if the method is not static.

    def number(self): ...

extra:

  1. Comments are marked by a hashtag ( # ).
  2. x == None comparement can be written as if x is None.
    In your case if no == None would be if no is None.
Nrzonline
  • 1,600
  • 2
  • 18
  • 37