This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tempfile | |
| from itertools import chain | |
| from django.contrib import admin | |
| from django.contrib.admin.utils import NestedObjects | |
| from django.core import serializers | |
| from django.http import HttpResponse | |
| from example_app.models import * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db import models | |
| class PersonManager(models.Manager): | |
| def get_by_natural_key(self, first_name, last_name): | |
| return self.get(first_name=first_name, last_name=last_name) | |
| class Person(models.Model): | |
| first_name = models.CharField(max_length=100) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tempfile | |
| from itertools import chain | |
| from django.contrib import admin | |
| from django.contrib.admin.utils import NestedObjects | |
| from django.core import serializers | |
| from django.http import HttpResponse | |
| from example_app.models import * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tempfile | |
| from django.contrib import admin | |
| from django.core import serializers | |
| from django.http import HttpResponse | |
| from example_app.models import * | |
| @admin.action(description="Export Model") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.contrib import admin | |
| from example_app.models import * | |
| class PersonAdmin(admin.ModelAdmin): | |
| pass | |
| admin.site.register(Person, PersonAdmin) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db import models | |
| class Person(models.Model): | |
| first_name = models.CharField(max_length=100) | |
| last_name = models.CharField(max_length=100) | |
| class Book(models.Model): | |
| name = models.CharField(max_length=100) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.core import serializers | |
| data = serializers.serialize("json", SomeModel.objects.all()) |