import export for User and Student model

This commit is contained in:
karthikmurakonda 2022-08-05 01:39:50 +05:30 committed by Gowtham Sai
parent 91794a4174
commit a7c9a51d47
3 changed files with 24 additions and 4 deletions

View File

@ -1,13 +1,18 @@
from django.contrib import admin
from simple_history.admin import SimpleHistoryAdmin
from django.contrib.admin.templatetags.admin_urls import admin_urlname
from django.shortcuts import resolve_url
from django.utils.html import format_html
from django.utils.safestring import SafeText
from simple_history.admin import SimpleHistoryAdmin
from import_export.admin import ImportExportMixin
from .models import *
admin.site.register(User, SimpleHistoryAdmin)
class UserAdmin(ImportExportMixin, SimpleHistoryAdmin):
pass
admin.site.register(User,UserAdmin)
admin.site.register(Admin, SimpleHistoryAdmin)
admin.site.site_header = "CDC Recruitment Portal"
@ -18,8 +23,11 @@ def model_admin_url(obj, name=None) -> str:
return format_html('<a href="{}">{}</a>', url, name or str(obj))
class StudentAdmin(ImportExportMixin, SimpleHistoryAdmin):
pass
@admin.register(Student)
class Student(SimpleHistoryAdmin):
class Student(StudentAdmin):
list_display = ("roll_no", "name", "batch", "branch", "phone_number", 'can_apply')
search_fields = ("roll_no", "name", "phone_number")
ordering = ("roll_no", "name", "batch", "branch", "phone_number")

View File

@ -46,6 +46,7 @@ INSTALLED_APPS = [
'django_db_logger',
'background_task',
'simple_history',
'import_export',
]
MIDDLEWARE = [

View File

@ -5,6 +5,8 @@ certifi==2021.10.8
chardet==4.0.0
charset-normalizer==2.0.12
colorama==0.4.4
defusedxml==0.7.1
diff-match-patch==20200713
dill==0.3.5.1
dj-database-url==0.5.0
Django==3.2.13
@ -12,8 +14,10 @@ django-background-tasks==1.2.5
django-compat==1.0.15
django-cors-headers==3.11.0
django-db-logger==0.1.12
django-import-export==2.8.0
django-simple-history==3.1.1
djangorestframework==3.13.1
et-xmlfile==1.1.0
google-auth==2.6.6
gunicorn==20.1.0
idna==3.3
@ -22,7 +26,10 @@ isort==5.10.1
jsonfield==3.1.0
lazy-object-proxy==1.7.1
Markdown==3.3.6
MarkupPy==1.14
mccabe==0.7.0
odfpy==1.4.1
openpyxl==3.0.10
pdfkit==1.0.0
platformdirs==2.5.1
psycopg2-binary==2.9.3
@ -32,14 +39,18 @@ PyJWT==2.4.0
pylint==2.13.5
python-dotenv==0.20.0
pytz==2022.1
PyYAML==6.0
requests==2.27.1
rsa==4.8
six==1.16.0
sqlparse==0.4.2
tablib==3.2.1
toml==0.10.2
tomli==2.0.1
typing-extensions==4.1.1
typing_extensions==4.1.1
urllib3==1.26.9
whitenoise==6.0.0
wrapt==1.14.0
xlrd==2.0.1
xlwt==1.3.0
zipp==3.8.0