django-rea / rea-project

A way to discuss and collaborate on the django-rea organization umbrella
1 stars 0 forks source link

Django features or non-features that might affect refactoring #3

Open bhaugen opened 7 years ago

bhaugen commented 7 years ago

Can Abstract Base Classes include Foreign Keys?

@escanda writes:

The issue I think with ABC classes is you can't use them in relationships if I am not mistaken. Thus you can't create a base schema to extend, we'd need to push up the foreign keys to all forks.

That would be a problem. But it looks like, starting with version 1.9, we can do it: https://docs.djangoproject.com/en/1.9/ref/models/fields/#foreignkey

I haven't tried this, so can't swear it will work, or that it will not have unexpected side effects (that is, bugs).

__init__.py

This tells you how much I know about Python and Django (although this is a python feature): I was not aware that adding a bunch of import statements to __init__.py would make the contents of a bunch of models.py files importable without needing to call out each of the models files in tests and (I assume) views. (That's a nice feature.)

Can we override particular files without forking a whole repo?

For example, if we wanted to substitute our EconomicResourceType, could we substitute just our types.py file, instead of forking the whole https://github.com/django-rea/nrp repo?

I don't know the answer, but doubt it. Which means that separating e.g. models.py into smaller files might not help with the issues of a common core that everybody can use vs each group's special features.

Any other Django or Python features or non-features that would help us or get in our way?

ghost commented 7 years ago

Any other Django or Python features or non-features that would help us or get in our way?

swappable models seems to have semi figured out :) As @XaviP mentions in this comment, users of swapped models need to define its settings before creating any migrations.

bhaugen commented 7 years ago

If we get to 1.9 and can have abstract base classes with foreign keys, do we need swappable models?

ghost commented 7 years ago

I think we don't. Ideally we'd have a cookiecutter template with defaults for the ABC classes, views, and everything in between. Swappable models are nice if you want omit this skeleton and provide the default implementation in the base package. For simplicity shake, and following Django's spirit, I'd advocate as well for ABC and a template for new projects.