Skip to content

Commit

Permalink
- refactor django_jtables as a simple module for Django
Browse files Browse the repository at this point in the history
  • Loading branch information
arcturusannamalai committed Feb 25, 2024
1 parent d3086fe commit 42c1fcf
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 46 deletions.
1 change: 1 addition & 0 deletions demoproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

INSTALLED_APPS = [
"django_jtables.apps.TablesConfig",
"student.apps.StudentConfig",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
Expand Down
2 changes: 1 addition & 1 deletion demoproject/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@

urlpatterns = [
path("admin/", admin.site.urls),
path("action/", include("django_jtables.urls")),
path("action/", include("student.urls")),
path("", to_home),
]
2 changes: 1 addition & 1 deletion django_jtables/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.contrib import admin

from .models import Student
from student.models import Student

# Register your models here.
admin.site.register(Student)
42 changes: 0 additions & 42 deletions django_jtables/models.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,3 @@
from django.db import models

from datetime import date

# Create your models here.


class Student(models.Model):
def __str__(self):
return self.name

name = models.CharField(max_length=200)

email_address = models.EmailField(max_length=200)

password = models.CharField(max_length=200)

class GenderChoices(models.TextChoices):
MALE = "M", "Male"
FEMALE = "F", "Female"
OTHER = "O", "Other"

gender = models.CharField(
max_length=1,
choices=GenderChoices.choices,
)

birth_date = models.DateField()

class EducationChoices(models.TextChoices):
PRIMARY = "1", "Primary school"
HIGH_SCHOOL = "2", "High school"
UNIVERSITY = "3", "University"

education = models.CharField(
max_length=1,
choices=EducationChoices.choices,
)

about = models.TextField()

is_active = models.BooleanField()

# auto_now_add sets the DateTimeField to the datetime of when the object is created.
record_date = models.DateTimeField(auto_now_add=True)
2 changes: 1 addition & 1 deletion django_jtables/viewbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.db.models import Model, F
from django.http import JsonResponse, HttpRequest

from django_jtables.models import Student
from student.models import Student


class ModelViewBuilder:
Expand Down
Empty file added student/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions student/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions student/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class StudentConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'student'
41 changes: 41 additions & 0 deletions student/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from django.db import models

# Create your models here.
class Student(models.Model):
def __str__(self):
return self.name

name = models.CharField(max_length=200)

email_address = models.EmailField(max_length=200)

password = models.CharField(max_length=200)

class GenderChoices(models.TextChoices):
MALE = "M", "Male"
FEMALE = "F", "Female"
OTHER = "O", "Other"

gender = models.CharField(
max_length=1,
choices=GenderChoices.choices,
)

birth_date = models.DateField()

class EducationChoices(models.TextChoices):
PRIMARY = "1", "Primary school"
HIGH_SCHOOL = "2", "High school"
UNIVERSITY = "3", "University"

education = models.CharField(
max_length=1,
choices=EducationChoices.choices,
)

about = models.TextField()

is_active = models.BooleanField()

# auto_now_add sets the DateTimeField to the datetime of when the object is created.
record_date = models.DateTimeField(auto_now_add=True)
3 changes: 3 additions & 0 deletions student/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
File renamed without changes.
2 changes: 1 addition & 1 deletion django_jtables/views.py → student/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.http import HttpRequest

from .models import Student
from student.models import Student

from django.http import JsonResponse
from django.middleware.csrf import get_token
Expand Down

0 comments on commit 42c1fcf

Please sign in to comment.