diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 9c95db2..8edebc2 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -36,7 +36,7 @@ You want to contribute some code? Great! Here are a few steps to get you started $ virtualenv venv $ source venv/bin/activate (venv) $ pip install -e .[validation] - (venv) $ pip install -rrequirements/dev.txt -rrequirements/test.txt + (venv) $ pip install -rrequirements/dev.txt -rrequirements/test.txt "Django>=1.11.7" #. **Make your changes and check them against the test project** @@ -44,7 +44,7 @@ You want to contribute some code? Great! Here are a few steps to get you started (venv) $ cd testproj (venv) $ python manage.py migrate - (venv) $ cat createsuperuser.py | python manage.py shell + (venv) $ python manage.py shell -c "import createsuperuser" (venv) $ python manage.py runserver (venv) $ firefox localhost:8000/swagger/ diff --git a/README.rst b/README.rst index fab5d2c..d86e08c 100644 --- a/README.rst +++ b/README.rst @@ -334,6 +334,26 @@ You can use the specification outputted by this library together with See the github page linked above for more details. +.. _readme-testproj: + +6. Example project +================== + +For additional usage examples, you can take a look at the test project in the ``testproj`` directory: + +.. code:: console + + $ git clone https://github.com/axnsan12/drf-yasg.git + $ cd drf-yasg + $ virtualenv venv + $ source venv/bin/activate + (venv) $ cd testproj + (venv) $ pip install -r requirements.txt + (venv) $ python manage.py migrate + (venv) $ python manage.py shell -c "import createsuperuser" + (venv) $ python manage.py runserver + (venv) $ firefox localhost:8000/swagger/ + ********** Background ********** diff --git a/requirements/test.txt b/requirements/test.txt index 762fcb9..c2b4502 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -6,10 +6,4 @@ pytest-cov>=2.5.1 git+https://github.com/pytest-dev/pytest-django.git@94cccb956435dd7a719606744ee7608397e1eafb datadiff==2.0.0 -# test project requirements -Pillow>=4.3.0 -pygments>=2.2.0 -django-cors-headers>=2.1.0 -django-filter>=1.1.0,<2.0; python_version == "2.7" -django-filter>=1.1.0; python_version >= "3.4" -djangorestframework-camel-case>=0.2.0 +-r testproj.txt diff --git a/requirements/testproj.txt b/requirements/testproj.txt new file mode 100644 index 0000000..731c23b --- /dev/null +++ b/requirements/testproj.txt @@ -0,0 +1,7 @@ +# test project requirements +Pillow>=4.3.0 +pygments>=2.2.0 +django-cors-headers>=2.1.0 +django-filter>=1.1.0,<2.0; python_version == "2.7" +django-filter>=1.1.0; python_version >= "3.4" +djangorestframework-camel-case>=0.2.0 diff --git a/testproj/createsuperuser.py b/testproj/createsuperuser.py index eb000e9..ce76187 100644 --- a/testproj/createsuperuser.py +++ b/testproj/createsuperuser.py @@ -1,4 +1,11 @@ +from __future__ import print_function + from django.contrib.auth.models import User -User.objects.filter(username='admin').delete() -User.objects.create_superuser('admin', 'admin@admin.admin', 'passwordadmin') +username = 'admin' +email = 'admin@admin.admin' +password = 'passwordadmin' +User.objects.filter(username=username).delete() +User.objects.create_superuser(username, email, password) + +print("Created superuser '%s <%s>' with password '%s'" % (username, email, password)) diff --git a/testproj/requirements.txt b/testproj/requirements.txt new file mode 100644 index 0000000..3b10677 --- /dev/null +++ b/testproj/requirements.txt @@ -0,0 +1,3 @@ +drf-yasg[validation] +Django>=1.11.7 +-r ../requirements/testproj.txt