Answer the question
In order to leave comments, you need to log in
How to implement modules to reuse Python/Django code?
Hello, please help me understand.
I am writing an application for the sake of interest and practice, a small social network in Python 3.4 - Django 1.7
As always and everywhere in the social. networks have:
User page:
- Photos
- Videos
- Wall with comments
Communities:
- Photos
- Videos
- Wall with comments
- Discussions where there is a question and answers to them in the form of comments
Photos have their own comments, videos have their own comments
. For example, the functionality of photos - adding / deleting / editing / outputting - is the same everywhere on the user's page, in the community
. Also, all comments have the same functionality.
Of course, you can create for all comments, photos, videos on 1 table where there will be item_id and app_label fields,
item_id - the identifier of the owned record
app_label - the application to which the record belongs to
do for each application view - adding / deleting, etc., which will accept item_id and app_label to use them everywhere.
This option, I think, will be a little wrong, since the tables will be too clogged.
I would like each application to have its own tables in the database, for example:
user_page_comments
user_photo_comments
user_video_comments
community_comments
community_photo_comments
...
but there was only one code responsible for business logic.
Do you have any ideas?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question