furious-luke / django-address

A Django address model and field. Addresses may be specified by address components or by performing an automatic Google Maps lookup.
BSD 3-Clause "New" or "Revised" License
431 stars 181 forks source link

Still deleting associated user with "null=True" #122

Closed stefvonb closed 4 years ago

stefvonb commented 4 years ago

I have a simple custom user model:

class User(AbstractUser): ... address = AddressField(null=True) ...

I don't want the user to be deleted when deleting the address, and the documentation says this is the way to do it. However, when I go to the django admin page and delete an address, it will still delete the user as well... How can I fix this? Is there a specific "on_delete" to set?

banagale commented 4 years ago

Thanks for the report. @Benbb96 do you have time to:

stefvonb commented 4 years ago

Thanks @banagale Just FYI, my setup is:

Python 3.8.3 Django 3.0.7 django-address 0.2.3 (not 0.2.5, I have the pip release)

Benbb96 commented 4 years ago

@stefvonb It should be fixed in #112 but yes @banagale I think I'll have time this week to create a PR with some tests on it 😉

stefvonb commented 4 years ago

Fantastic, thanks @Benbb96, it worked after specifying 0.2.4 in the pip install. Not sure why I was getting an older version. A quick look at the migration now and it correctly sets on_delete=django.db.models.deletion.SET_NULL.

Cheers!

banagale commented 4 years ago

@stefvonb Ah, okay. Thanks for the update. @Benbb96 Thanks for that quick validation check. No big need for this test, unless you've already made it. Otherwise there are other issues that might move the needle more for the project I might try to steer you toward. :)

Benbb96 commented 4 years ago

@banagale Yep, I tried to take a look at the test but I didn't understand how to run them from the package itself. Should I use the manage.py from the example project ?

Alright, I also wanted to add an answer to your thread on how I use django-address but I didn't take the time to do it for now..

banagale commented 4 years ago

@Benbb96 I just realized there is no documentation on how to run tests.

I've added #123, along with some brief notes to include that in the Readme for this next release.

If you have a moment, please try using the steps and letting me know if they are complete enough.

I did notice that one of the tests is currently failing. You're welcome to try to address that or not. If you do, feel free to create an issue for it. (ah, the delightful overhead)

I hope to add Github Actions to make them available for CI on django-address also. (I've been working with them on another project and hope to bring over some of that knowledge)

And thanks for your intent to add to the how you use thread, I think that will be helpful to understand longer term development priorities.