Changes between Initial Version and Version 1 of Ticket #34025
- Timestamp:
- Sep 20, 2022, 4:21:55 PM (2 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #34025 – Description
initial v1 2 2 3 3 1. create a model Person. 4 5 {{{6 class Person(models.Model):7 name= models.CharField(max_length=255)8 }}}9 4 10 5 2. create a model Order with 2 fks pointing to person, for example: supplier and customer … … 12 7 13 8 {{{ 9 from django.db import models 10 11 # Create your models here. 12 class Person(models.Model): 13 name = models.CharField(max_length=255) 14 15 def __str__(self): 16 return self.name 17 14 18 class Order(models.Model): 15 19 supplier = models.ForeignKey(Person, related_name='the_supplier', on_delete=models.PROTECT) … … 22 26 23 27 {{{ 28 from django.contrib import admin 29 from sales.models import * 30 31 32 class PersonAdmin(admin.ModelAdmin): 33 search_fields = ['name'] 34 24 35 class OrderAdmin(admin.ModelAdmin): 25 36 autocomplete_fields = ['supplier', 'customer'] 37 38 39 admin.site.register(Person, PersonAdmin) 40 admin.site.register(Order, OrderAdmin) 26 41 }}} 27 42