The staff management is a simple Django app to perform crud commands on employees.
# Steps are incoherent, do not follow, need to rewrite
- This web-app requires django 2.0 and python 3.5.
- No DB settings is needed as sqlite3 is used by default.
- create a virtual env.
-> python3 -m venv vp or virtualenv -p python3.5 venv
Activate vp and run "pip install -e staffmanager_package"
Create a project, "django-admin startproject staffmanager"
Add "staffapp.apps.StaffAppConfig" to your INSTALLED_APPS setting like this:
- INSTALLED_APPS = [
'staffapp.apps.StaffAppConfig', ...
]
- Add the following settings in your settings.py
-> MEDIA_URL = '/media/' -> MEDIA_ROOT = os.path.join(BASE_DIR, 'staffapp/media')
Include the following into URLconf in your project urls.py like this:
from django.urls import path, include from django.contrib import admin from django.conf import settings from django.conf.urls.static import static from staffmanager import views urlpatterns = [ path('admin/', admin.site.urls), path('', views.redirect_employee), path('staff_management', views.redirect_employee), path('staff_management/', include('staffapp.urls')), ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)create a views.py in your project and add the following:
from django.shortcuts import redirect, reverse
- def redirect_employee(request):
""" :param request: :return: Redirects the user to a valid page """ return redirect(reverse('emp:view_employees'))
Run python manage.py makemigrattions.
Run python manage.py migrate to create the employee models.
Run python manage.py insert_test_users to create the forecast models.
Visit http://127.0.0.1:8000 to view the site.