diff --git a/.gitignore b/.gitignore
index 3649d6d..52a670b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,77 +1,159 @@
-# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
-# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
-# User-specific stuff
-.idea/**/workspace.xml
-.idea/**/tasks.xml
-.idea/**/usage.statistics.xml
-.idea/**/dictionaries
-.idea/**/shelf
-# AWS User-specific
-.idea/**/aws.xml
+# C extensions
+*.so
-# Generated files
-.idea/**/contentModel.xml
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+share/python-wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
-# Sensitive or high-churn files
-.idea/**/dataSources/
-.idea/**/dataSources.ids
-.idea/**/dataSources.local.xml
-.idea/**/sqlDataSources.xml
-.idea/**/dynamic.xml
-.idea/**/uiDesigner.xml
-.idea/**/dbnavigator.xml
+# PyInstaller
+# Usually these files are written by a python script from a template
+# before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
-# Gradle
-.idea/**/gradle.xml
-.idea/**/libraries
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
-# Gradle and Maven with auto-import
-# When using Gradle or Maven with auto-import, you should exclude module files,
-# since they will be recreated, and may cause churn. Uncomment if using
-# auto-import.
-# .idea/artifacts
-# .idea/compiler.xml
-# .idea/jarRepositories.xml
-# .idea/modules.xml
-# .idea/*.iml
-# .idea/modules
-# *.iml
-# *.ipr
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.nox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+*.py,cover
+.hypothesis/
+.pytest_cache/
+cover/
-# CMake
-cmake-build-*/
+# Translations
+*.mo
+*.pot
-# Mongo Explorer plugin
-.idea/**/mongoSettings.xml
+# Django stuff:
+*.log
+local_settings.py
+db.sqlite3
+db.sqlite3-journal
-# File-based project format
-*.iws
+# Flask stuff:
+instance/
+.webassets-cache
-# IntelliJ
-out/
+# Scrapy stuff:
+.scrapy
-# mpeltonen/sbt-idea plugin
-.idea_modules/
+# Sphinx documentation
+docs/_build/
-# JIRA plugin
-atlassian-ide-plugin.xml
+# PyBuilder
+.pybuilder/
+target/
-# Cursive Clojure plugin
-.idea/replstate.xml
+# Jupyter Notebook
+.ipynb_checkpoints
-# SonarLint plugin
-.idea/sonarlint/
+# IPython
+profile_default/
+ipython_config.py
-# Crashlytics plugin (for Android Studio and IntelliJ)
-com_crashlytics_export_strings.xml
-crashlytics.properties
-crashlytics-build.properties
-fabric.properties
+# pyenv
+# For a library or package, you might want to ignore these files since the code is
+# intended to run in multiple environments; otherwise, check them in:
+# .python-version
-# Editor-based Rest Client
-.idea/httpRequests
+# pipenv
+# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
+# However, in case of collaboration, if having platform-specific dependencies or dependencies
+# having no cross-platform support, pipenv may install dependencies that don't work, or not
+# install all needed dependencies.
+#Pipfile.lock
-# Android studio 3.1+ serialized cache file
-.idea/caches/build_file_checksums.ser
+# poetry
+# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
+# This is especially recommended for binary packages to ensure reproducibility, and is more
+# commonly ignored for libraries.
+# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
+#poetry.lock
+
+# pdm
+# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
+#pdm.lock
+# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
+# in version control.
+# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
+.pdm.toml
+.pdm-python
+.pdm-build/
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
+__pypackages__/
+
+# Celery stuff
+celerybeat-schedule
+celerybeat.pid
+
+# SageMath parsed files
+*.sage.py
+
+# Environments
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+.dmypy.json
+dmypy.json
+
+# Pyre type checker
+.pyre/
+
+# pytype static type analyzer
+.pytype/
+
+# Cython debug symbols
+cython_debug/
+
+.idea/
+.vscode/
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c6baf6e..e5c8df4 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,7 +5,12 @@
+
+
+
+
+
@@ -36,21 +41,21 @@
- {
+ "keyToString": {
+ "ASKED_ADD_EXTERNAL_FILES": "true",
+ "RunOnceActivity.OpenDjangoStructureViewOnStart": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "git-widget-placeholder": "main",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable",
+ "vue.rearranger.settings.migration": "true"
}
-}]]>
+}
@@ -95,6 +100,7 @@
1719511805110
+
diff --git a/.vscode/settings.json b/.vscode/settings.json
index ab27b3d..af09d9b 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,4 +1,7 @@
{
+ "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
+ "python.analysis.indexing": true,
+ "python.analysis.packageIndexDepths":[["rest_framework", 5, true]],
"cSpell.words": [
"viewsets"
]
diff --git a/db.sqlite3 b/db.sqlite3
index c97bd7b..81f1ebb 100644
Binary files a/db.sqlite3 and b/db.sqlite3 differ
diff --git a/tJango/__pycache__/settings.cpython-312.pyc b/tJango/__pycache__/settings.cpython-312.pyc
index cab51b7..ae4f952 100644
Binary files a/tJango/__pycache__/settings.cpython-312.pyc and b/tJango/__pycache__/settings.cpython-312.pyc differ
diff --git a/tJango/__pycache__/urls.cpython-312.pyc b/tJango/__pycache__/urls.cpython-312.pyc
index 9459729..83447af 100644
Binary files a/tJango/__pycache__/urls.cpython-312.pyc and b/tJango/__pycache__/urls.cpython-312.pyc differ
diff --git a/tJango/settings.py b/tJango/settings.py
index a84ce1e..bfe3921 100644
--- a/tJango/settings.py
+++ b/tJango/settings.py
@@ -38,6 +38,8 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
+ 'hello',
+ 'user',
]
REST_FRAMEWORK = {
diff --git a/tJango/urls.py b/tJango/urls.py
index ef70de5..bda835f 100644
--- a/tJango/urls.py
+++ b/tJango/urls.py
@@ -17,23 +17,17 @@ Including another URLconf
from django.contrib import admin
from django.urls import path, include
from django.contrib.auth.models import User
-from rest_framework import routers, serializers, viewsets
+from rest_framework.routers import DefaultRouter
+from user.views import UserViewSet
-class UserSerializer(serializers.HyperlinkedModelSerializer):
- class Meta:
- model = User
- fields = ['url', 'username', 'email', 'is_staff']
-class UserViewSet(viewsets.ModelViewSet):
- queryset = User.objects.all()
- serializer_class = UserSerializer
-
-router = routers.DefaultRouter()
+router = DefaultRouter()
router.register(r'users', UserViewSet)
urlpatterns = [
path('api-auth/', include('rest_framework.urls')),
- path('hello', include("hello.urls")),
+ path('hello/', include("hello.urls")),
path('', include(router.urls)),
path('admin/', admin.site.urls),
+ path('user/', include((router.urls, 'user'), namespace='user'))
]
diff --git a/user/__init__.py b/user/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/user/admin.py b/user/admin.py
new file mode 100644
index 0000000..779867f
--- /dev/null
+++ b/user/admin.py
@@ -0,0 +1,5 @@
+from django.contrib import admin
+from .models import User
+# Register your models here.
+
+admin.site.register(User)
\ No newline at end of file
diff --git a/user/apps.py b/user/apps.py
new file mode 100644
index 0000000..36cce4c
--- /dev/null
+++ b/user/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class UserConfig(AppConfig):
+ default_auto_field = 'django.db.models.BigAutoField'
+ name = 'user'
diff --git a/user/migrations/0001_initial.py b/user/migrations/0001_initial.py
new file mode 100644
index 0000000..f818f54
--- /dev/null
+++ b/user/migrations/0001_initial.py
@@ -0,0 +1,22 @@
+# Generated by Django 5.0.6 on 2024-06-28 00:23
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='User',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('username', models.CharField(max_length=15)),
+ ('date_created', models.DateTimeField(auto_now_add=True)),
+ ],
+ ),
+ ]
diff --git a/user/migrations/__init__.py b/user/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/user/models.py b/user/models.py
new file mode 100644
index 0000000..01fd2f3
--- /dev/null
+++ b/user/models.py
@@ -0,0 +1,12 @@
+from django.db import models
+
+
+# Create your models here.
+
+class User(models.Model):
+ username = models.CharField(max_length=15, unique=True)
+ date_created = models.DateTimeField(auto_now_add=True)
+
+ def __str__(self):
+ return self.username
+
\ No newline at end of file
diff --git a/user/serializers.py b/user/serializers.py
new file mode 100644
index 0000000..5a8dfed
--- /dev/null
+++ b/user/serializers.py
@@ -0,0 +1,8 @@
+from rest_framework import serializers
+from .models import User
+
+class UserSerializer(serializers.ModelSerializer):
+ class Meta:
+ model = User
+ fields = ['username', 'date_created']
+ read_only_fields = ['date_created']
\ No newline at end of file
diff --git a/user/tests.py b/user/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/user/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/user/views.py b/user/views.py
new file mode 100644
index 0000000..76276fe
--- /dev/null
+++ b/user/views.py
@@ -0,0 +1,16 @@
+from django.shortcuts import render
+from rest_framework import viewsets
+from rest_framework.decorators import action
+from .models import User
+from .serializers import UserSerializer
+
+
+# Create your views here.
+
+class UserViewSet(viewsets.ModelViewSet):
+ queryset = User.objects.all()
+ serializer_class = UserSerializer
+
+ @action(detail=True, methods=['get'])
+ def print_this(self, request, pk=None):
+ print(self.get_object())