I am learning Django. I have 2 functions in my app, one for cats
, and another for dogs
(as an example). I have the following folder structure:
/myproject/templates <-- dogs.html, cats.html
/myproject/dogs/ <-- views.py, models.py etc
/myproject/cats/ <-- views.py, models.py etc
Now both cats
and dogs
have shared views, etc, but currently I am just repeating these in each views.py
file. Is there a way to "import" views and definitions from one view to another quickly?
This would save me cut and pasting a lot of the work.
What are the dangers of this? E.g. could conflicts arise? etc.