Skip to main content

Django View and Serializer Generator This Django management command automatically generates views.py and serializers.py files with basic viewsets and serializers for each model defined in the project’s models.py file. It saves development time by creating boilerplate code for API views and serializers based on your models.

Features Automatically generates views.py and serializers.py files based on models defined in a specified Django app. Creates a ModelViewSet for each model in views.py to enable CRUD operations. Generates a ModelSerializer for each model in serializers.py, including all model fields. Installation To install this library, use pip:

bash Copy code pip install django-view-serializer-generator Then, add the app to your Django project's INSTALLED_APPS:

python Copy code

settings.py

INSTALLED_APPS = [ # Other installed apps 'view_serializer_generator', # Add the generator app ] Usage Navigate to your Django project directory where manage.py is located.

Run the command to generate views and serializers:

bash Copy code python manage.py generate_views_and_serializers The command will look for models defined in the app specified in the code and generate views.py and serializers.py with the appropriate viewsets and serializers.

Example Output The command creates views.py and serializers.py in the specified app (e.g., Paypal), with code similar to:

serializers.py

python Copy code from rest_framework import serializers from .models import YourModel

class YourModelSerializer(serializers.ModelSerializer): class Meta: model = YourModel fields = 'all' views.py

python Copy code from rest_framework import viewsets from .models import YourModel from .serializers import YourModelSerializer

class YourModelViewSet(viewsets.ModelViewSet): queryset = YourModel.objects.all() serializer_class = YourModelSerializer Folder Structure To follow best practices, maintain the following folder structure:

markdown Copy code myproject/ ├── myapp/ │ ├── management/ │ │ └── commands/ │ │ └── generate_views_and_serializers.py │ ├── migrations/ │ ├── init.py │ ├── models.py │ ├── serializers.py │ ├── views.py │ ├── urls.py ├── manage.py ├── settings.py Customizing the Command By default, this command looks for an app named Paypal. If your app has a different name, update the app_name variable in generate_views_and_serializers.py:

python Copy code app_name = 'YourAppName' License This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for auto-view-generator 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for auto-view-generator 0.1.5
File Size Uploaded Provenance
auto_view_generator-0.1.5.tar.gz 4.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for auto-view-generator 0.1.5
File Interpreter ABI Platform
auto_view_generator-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 10.3 kB

Release files / auto_view_generator-0.1.5.tar.gz

Download URL auto_view_generator-0.1.5.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3097df8385204f060e8645d64b99c8fd73b382db319daec973aa60043d8f1cf6
BLAKE2b-256 checksum
How to use checksums
aa8553eed70795aa1f17e022f5020f980f6f25d42603b04a1e573c3cc8b42351
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / auto_view_generator-0.1.5-py3-none-any.whl

Download URL auto_view_generator-0.1.5-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9b38f4277e1305a7c9e1154525f986924fb4bf59031af9f65cdd8fc94b67a628
BLAKE2b-256 checksum
How to use checksums
436ef84750604d089a1a0b95f30dcf5cbad8ca6a8dbd4ad26f07b6cd137b2527
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Security for auto-view-generator 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page