You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fork_app.rst 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ==============
  2. Forking an app
  3. ==============
  4. This guide explains how to fork an app in Oscar.
  5. .. note::
  6. The following steps are now automated by the ``oscar_fork_app`` management
  7. command. They're explained in detail so you get an idea of what's going on.
  8. But there's no need to do this manually anymore!
  9. Create Python module with same label
  10. ====================================
  11. You need to create a Python module with the same "app label" as the Oscar app
  12. you want to extend. E.g., to create a local version of ``oscar.apps.order``,
  13. do the following::
  14. $ mkdir yourproject/order
  15. $ touch yourproject/order/__init__.py
  16. Reference Oscar's models
  17. ========================
  18. If the original Oscar app has a ``models.py``, you'll need to create a
  19. ``models.py`` file in your local app. It should import all models from
  20. the Oscar app being overridden::
  21. # yourproject/order/models.py
  22. # your custom models go here
  23. from oscar.apps.order.models import *
  24. If two models with the same name are declared within an app, Django will only
  25. use the first one. That means that if you wish to customise Oscar's models, you
  26. must declare your custom ones before importing Oscar's models for that app.
  27. If you're using South, you have to copy the ``migrations`` directory
  28. from ``oscar/apps/order`` and put it into your ``order`` app. Detailed
  29. instructions are available in :doc:`/howto/how_to_customise_models`.
  30. Get the Django admin working
  31. ============================
  32. When you replace one of Oscar's apps with a local one, Django admin integration
  33. is lost. If you'd like to use it, you need to create an ``admin.py`` and import
  34. the core app's ``admin.py`` (which will run the register code)::
  35. # yourproject/order/admin.py
  36. import oscar.apps.order.admin
  37. This isn't great but we haven't found a better way as of yet.
  38. Django 1.7+: Use supplied app config
  39. ====================================
  40. Oscar ships with an app config for each app, which sets app labels and
  41. runs startup code. You need to make sure that happens.
  42. .. code-block: django
  43. # yourproject/order/config.py
  44. from oscar.apps.order import config
  45. class OrderConfig(config.OrderConfig):
  46. name = 'yourproject.order'
  47. # yourproject/order/__init__.py
  48. default_app_config = 'yourproject.order.config.OrderConfig'