Changes between Initial Version and Version 1 of Ticket #34025


Ignore:
Timestamp:
Sep 20, 2022, 4:21:55 PM (2 years ago)
Author:
Alexandre da Silva
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34025 – Description

    initial v1  
    22
    331. create a model Person.
    4 
    5 {{{
    6 class Person(models.Model):
    7     name= models.CharField(max_length=255)
    8 }}}
    94
    1052. create a model Order with 2 fks pointing to person, for example: supplier and customer
     
    127
    138{{{
     9from django.db import models
     10
     11# Create your models here.
     12class Person(models.Model):
     13    name = models.CharField(max_length=255)
     14
     15    def __str__(self):
     16        return self.name
     17
    1418class Order(models.Model):
    1519    supplier = models.ForeignKey(Person, related_name='the_supplier', on_delete=models.PROTECT)
     
    2226
    2327{{{
     28from django.contrib import admin
     29from sales.models import *
     30
     31
     32class PersonAdmin(admin.ModelAdmin):
     33    search_fields = ['name']
     34
    2435class OrderAdmin(admin.ModelAdmin):
    2536    autocomplete_fields = ['supplier', 'customer']
     37
     38
     39admin.site.register(Person, PersonAdmin)
     40admin.site.register(Order, OrderAdmin)
    2641}}}
    2742
Back to Top