Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What parameters does Django's models.DO_NOTHING expect?

Tags:

python

django

I've searched the documentation but I haven't found any explanation of the parameters.

The implementation of the DO_NOTHING does exactly that, so it shouldn't matter what I'm passing in, but for other methods (such as CASCADE) they're actually used.

The closest explanation I've found is a discussion of CASCADE.

What datatypes are collector, field, sub_objs, and using, and what values do I pass?

EDIT:

I'm using it in my model, like so:

class Office(models.Model):

    #   Office locations have a name, and a location.

    display_name = models.CharField(max_length=255)

    location = models.OneToOneField(
        GeoLocation,
        on_delete=models.DO_NOTHING(None, None, None, None)
    )
like image 692
Moshe Avatar asked Mar 04 '16 18:03

Moshe


1 Answers

You shouldn't be calling models.DO_NOTHING, you should just be passing it as a value:

location = models.OneToOneField(
    GeoLocation,
    on_delete=models.DO_NOTHING
)

The fact that it's a function is an implementation detail, not part of the API, which is why those parameters are undocumented.

like image 52
Kevin Christopher Henry Avatar answered Oct 24 '22 00:10

Kevin Christopher Henry