redhat-beyond / JobSeeker

https://github.com/redhat-beyond/JobSeeker
MIT License
2 stars 5 forks source link

πŸ“ Arrangement Of App Folders In Django #33

Closed taljacob2 closed 2 years ago

taljacob2 commented 2 years ago

Hi all! πŸ₯‡ πŸ… All of our 5 "feature"-apps will make use of some "global" files. For example: base_template.html, icons folder main.css and more...

We should arrange our Django Application such that the jobseeker-app is a "global" app that is being injected into each "feature"-app. This way, we could make use of "global" shared files together in a modular way!

This is the Django Application Rendering Flow that will help us share data between our "feature"-apps:

Practically said, the way to create this modular structure is by doing the following:

Urls

Static


paOmer commented 2 years ago

Hi @taljacob2, The new arrangement that you suggest looks awesome. I'll make it happen, but I’m thinking to make #20 a draft for now and do the new arrangement in a new PR.

taljacob2 commented 2 years ago

Hi @taljacob2, The new arrangement that you suggest looks awesome. I'll make it happen, but I’m thinking to make #20 a draft for now and do the new arrangement in a new PR.

Sounds great! :+1:

taljacob2 commented 2 years ago

Thanks for @paOmer for excellent work! Each team member can now create his own "feature"-app based on #34.

taljacob2 commented 2 years ago

@ShirleyFichman @paOmer @DeanBiton @amittcohen

GUIDE: How To Render The View In Your "Feature"-App

Say YOUR_FEATURE_APP_NAME is one of the following names:

Once you have created your "feature"-app:

  1. Create a templates/YOUR_FEATURE_APP_NAME folder in your "feature"-app, and place there all your .html files. (For example: YOUR_FEATURE_APP_NAME.html)
  2. Navigate to app/settings.py, and in line 60 add your templates folder to your "feature"-app you have created. For example: (added the line: os.path.join(BASE_DIR, 'YOUR_FEATURE_APP_NAME', 'templates', 'YOUR_FEATURE_APP_NAME'))
        'DIRS': [os.path.join(BASE_DIR, 'templates'),
                 os.path.join(BASE_DIR, 'jobseeker', 'templates', 'jobseeker'),
                 os.path.join(BASE_DIR, 'YOUR_FEATURE_APP_NAME', 'templates', 'YOUR_FEATURE_APP_NAME')],
  3. To render a .html, navigate to YOUR_FEATURE_APP_NAME/views.py, and make it look like so: (for example)

    from django.shortcuts import render
    
    def YOUR_FEATURE_APP_NAME(request):
        return render(request, 'YOUR_FEATURE_APP_NAME.html')
    
  4. Render your "feature"-app URLs by creating a YOUR_FEATURE_APP_NAME/urls.py file, with the following content:

    from django.urls import path
    from . import views
    
    urlpatterns = [
        path('YOUR_FEATURE_APP_NAME/', views.YOUR_FEATURE_APP_NAME, name='YOUR_FEATURE_APP_NAME'),
    ]
  5. Make sure jobseeker/urls.py is rendering your YOUR_FEATURE_APP_NAME/urls.py. You need to enable the path to YOUR_FEATURE_APP_NAME/urls.py in the jobseeker/urls.py file:

    from django.urls import path, include
    from . import views
    
    urlpatterns = [
        path('about/', views.about, name='about'),
        path('', include('YOUR_FEATURE_APP_NAME.urls')),
    ]
  6. You're done! The .html of your "feature"-app can be accessed at: http://localhost:8000/YOUR_FEATURE_APP_NAME/