The Django docs 
(https://docs.djangoproject.com/en/1.11/topics/db/models/#field-name-restrictions)
 
state there are only two restrictions on model field names:


   1. A field name cannot be a Python reserved word
   2. A field name cannot contain more than one underscore in a row


However, given the following example, it doesn't look like I can use the 
field name `check` as a ForeignKey.

    class Check(models.Model):


        name = models.CharField(max_length=100)


    class MyModel(models.Model):


        # this works fine
        #check = models.BooleanField()
        
        # this breaks
        check = models.ForeignKey(Check, on_delete=models.PROTECT, 
related_name='+')

Here's the error:

    $ python manage.py check
    SystemCheckError: System check identified some issues:


    ERRORS:
    myapp.MyModel: (models.E020) The 'MyModel.check()' class method is 
currently overridden by <django.db.models.fields.related_descriptors.
ForwardManyToOneDescriptor object at 0x03A818D0>


Are the docs wrong, or am I doing something wrong?

This project is using Python 2 and Django 1.11

Here's the StackOverflow question: 
https://stackoverflow.com/questions/54681167/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5c3a58d0-3a5b-4703-b478-7f4d2cf1dd05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to