Skip to content

Commit 5a17a2c

Browse files
Package version 0.1.1 and add images some cleanup make ready for pypi publishing
1 parent d08c127 commit 5a17a2c

File tree

13 files changed

+53
-38
lines changed

13 files changed

+53
-38
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
.idea/
2+
demoproject/__pycache__/
3+
student/__pycache__/
4+
venv
5+
venv/*
16
db.sqlite3
27
django server/mysite/polls/__init__.py
38
django server/mysite/polls/admin.py

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ Instructions to start the Django server
33
2. Run the command "python3 manage.py migrate --run-syncdb" (if this did not work you can also try,
44
"python3 manage.py migrate --run-syncdb")
55
3. You should see something like,
6+
7+
8+
![Example Use](static/assets/edit_example.png)
9+
610
```
711
Operations to perform:
812
Synchronize unmigrated apps: corsheaders, messages, staticfiles, tables
@@ -49,9 +53,13 @@ The currently accessible links are:
4953

5054

5155
6. LICENSE
52-
- the Django JTables project is licensed under the MIT License as well like the JTables widget.
53-
- the original JTables widget is distributed in this package but not part of this project
56+
- the Django JTable project is licensed under the MIT License as well like the JTable widget.
57+
- the original JTable widget is distributed in this package but not part of this project
5458
jTable is developed by Halil İbrahim Kalkan and licensed under MIT License. See: https://www.jtable.org/Home/About
5559

56-
8/3/2022.
57-
12/11/2023.
60+
7. Works with jTable 2.4.0; please download and install this package; it is not distributed with the pypi package.
61+
62+
Notes
63+
-----
64+
- Created: 8/3/2022
65+
- Last updated: 11/17/2025

demoproject/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
# Application definition
3838

3939
INSTALLED_APPS = [
40-
"django_jtables.apps.TablesConfig",
40+
"django_jtable.apps.TablesConfig",
4141
"student.apps.StudentConfig",
4242
"django.contrib.admin",
4343
"django.contrib.auth",

django_jtable/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VERSION="0.1.1"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
class TablesConfig(AppConfig):
55
default_auto_field = "django.db.models.BigAutoField"
6-
name = "django_jtables"
6+
name = "django_jtable"
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from django.db.models import Model, F
55
from django.http import JsonResponse, HttpRequest
66

7+
DEBUG = False
78
class ModelViewBuilder:
89
def __init__(self, ModelClass: Model, fields, editable, modifier={}, datefields=[]):
910
self.pk_name = ModelClass.__name__ + "Id"
@@ -14,18 +15,18 @@ def __init__(self, ModelClass: Model, fields, editable, modifier={}, datefields=
1415
self._datefields = datefields
1516

1617
def update(self, request: Request):
17-
print("UPDATE ACTION")
18+
if DEBUG: print("UPDATE ACTION")
1819

1920
r = request.POST
20-
import pprint
21-
pprint.pprint(r)
22-
#breakpoint()
21+
if DEBUG:
22+
import pprint
23+
pprint.pprint(r)
2324
target = self._ModelClass.objects.get(id=r.get(self.pk_name))
2425

2526
kwargs = {name: r.get(fieldname) for name, fieldname in self._editable.items()}
2627
for name, modifier in self._modifier.items():
2728
kwargs[name] = modifier(kwargs[name])
28-
kwargs.pop('id')
29+
kwargs.pop('id',None)
2930
for _field,_value in kwargs.items():
3031
setattr(target,_field,_value)
3132
target.save()
@@ -35,12 +36,12 @@ def update(self, request: Request):
3536
return None
3637

3738
def read(self, request: Request):
38-
print("LIST ACTION")
39+
if DEBUG: print("LIST ACTION")
3940
# '-' means descending
40-
print(request.POST)
41+
if DEBUG: print(request.POST)
4142
r = request.POST
4243
kwargs = {fieldname: F(name) for name, fieldname in self._fields.items()}
43-
print(kwargs)
44+
if DEBUG: print(kwargs)
4445
kwargs.update({"Id": F("id")})
4546
s = self._ModelClass.objects.values(**kwargs)
4647

@@ -70,13 +71,13 @@ def read(self, request: Request):
7071
# list(s) -> "Records"
7172
data = {"Result": "OK", "Records": records}
7273

73-
print(records)
74+
if DEBUG: print(records)
7475
return JsonResponse(
7576
data, safe=False
7677
) # safe=False means types other than dict can be sent
7778

7879
def create(self, request: Request):
79-
print("CREATE ACTION")
80+
if DEBUG: print("CREATE ACTION")
8081
r = request.POST
8182
kwargs = {name: r.get(fieldname) for name, fieldname in self._fields.items()}
8283
for name, modifier in self._modifier.items():
@@ -93,13 +94,13 @@ def create(self, request: Request):
9394
return JsonResponse(data)
9495

9596
def delete(self, request: HttpRequest):
96-
print("DELETE ACTION")
97-
print(request)
98-
print(request.POST)
97+
if DEBUG: print("DELETE ACTION")
98+
if DEBUG: print(request)
99+
if DEBUG: print(request.POST)
99100

100101
r = request.POST
101102
target = self._ModelClass.objects.filter(id=r.get(self.pk_name))
102-
print(target)
103+
if DEBUG: print(target)
103104
target.delete()
104105

105106
data = {"Result": "OK"}

django_jtables/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)