Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Customer(models.Model):
- customer_id = models.AutoField(primary_key=True, db_column='CustomerId', verbose_name='Customer ID') # Field name made lowercase.
- first_name = models.CharField(max_length=40, db_column='FirstName')
- last_name = models.CharField(max_length=20, db_column='LastName')
- birthdate = models.DateTimeField(null=True, db_column=u'BirthDate', blank=True)
- company = models.CharField(max_length=80, db_column='Company', blank=True)
- address = models.CharField(max_length=70, db_column='Address', blank=True)
- city = models.CharField(max_length=40, db_column='City', blank=True)
- state = models.CharField(max_length=40, db_column='State', blank=True)
- country = models.CharField(max_length=40, db_column='Country', blank=True)
- postalcode = models.CharField(max_length=10, db_column='PostalCode', blank=True)
- phone = models.CharField(max_length=24, db_column='Phone', blank=True)
- fax = models.CharField(max_length=24, db_column='Fax', blank=True)
- email = models.CharField(max_length=60, db_column='Email')
- support_rep = models.ForeignKey("Employee", null=True, db_column='SupportRepId', blank=True) # Field name made lowercase.
- created_on = models.DateTimeField(auto_now_add=True)
- created_by = models.EmailField(verbose_name='Created By', max_length=512, null=True, blank=True)
- updated_on = models.DateTimeField(auto_now=True)
- updated_by = models.EmailField(verbose_name='Updated By', max_length=512, null=True, blank=True)
- def __unicode__(self):
- return u"%s, %s" % (self.first_name, self.last_name)
- class Meta:
- db_table = 'Customer'
- ordering = ['-created_on']
- get_latest_by = "created_on"
- verbose_name = "Country"
- verbose_name_plural = "Country"
- class CustomerAdmin(admin.ModelAdmin):
- list_display = ['first_name', 'last_name', 'created_on', 'created_by', 'updated_on', 'updated_by', ]
- list_filter = ['gender', 'profile_policy', ]
- search_fields = ['first_name', 'last_name', 'company', 'city', 'email', 'phone', ]
- date_hierarchy = 'created_on'
- def save_model(self, request, obj, form, change):
- if change:
- obj.updated_by = request.user.email
- else:
- obj.created_by = request.user.email
- obj.save()
- admin.site.register(Customer, CustomerAdmin)
- class Invoice(models.Model):
- invoiceid = models.IntegerField(primary_key=True, db_column=u'InvoiceId') # Field name made lowercase.
- customerid = models.IntegerField(db_column=u'CustomerId') # Field name made lowercase.
- invoicedate = models.DateTimeField(db_column=u'InvoiceDate') # Field name made lowercase.
- billingaddress = models.TextField(db_column=u'BillingAddress', blank=True) # Field name made lowercase. This field type is a guess.
- billingcity = models.TextField(db_column=u'BillingCity', blank=True) # Field name made lowercase. This field type is a guess.
- billingstate = models.TextField(db_column=u'BillingState', blank=True) # Field name made lowercase. This field type is a guess.
- billingcountry = models.TextField(db_column=u'BillingCountry', blank=True) # Field name made lowercase. This field type is a guess.
- billingpostalcode = models.TextField(db_column=u'BillingPostalCode', blank=True) # Field name made lowercase. This field type is a guess.
- total = models.TextField(db_column=u'Total') # Field name made lowercase. This field type is a guess.
- created_on = models.DateTimeField(auto_now_add=True)
- created_by = models.EmailField(verbose_name='Created By', max_length=512, null=True, blank=True)
- updated_on = models.DateTimeField(auto_now=True)
- updated_by = models.EmailField(verbose_name='Updated By', max_length=512, null=True, blank=True)
- class Meta:
- db_table = 'Invoice'
- ordering = ['-created_on']
- get_latest_by = "created_on"
- verbose_name = "Invoice"
- verbose_name_plural = "Invoice"
- class Invoiceline(models.Model):
- invoicelineid = models.IntegerField(primary_key=True, db_column=u'InvoiceLineId') # Field name made lowercase.
- invoiceid = models.IntegerField(db_column=u'InvoiceId') # Field name made lowercase.
- trackid = models.IntegerField(db_column=u'TrackId') # Field name made lowercase.
- unitprice = models.TextField(db_column=u'UnitPrice') # Field name made lowercase. This field type is a guess.
- quantity = models.IntegerField(db_column=u'Quantity') # Field name made lowercase.
- class Meta:
- db_table = u'InvoiceLine'
- class Playlist(models.Model):
- playlistid = models.IntegerField(primary_key=True, db_column=u'PlaylistId') # Field name made lowercase.
- name = models.TextField(db_column=u'Name', blank=True) # Field name made lowercase. This field type is a guess.
- class Meta:
- db_table = u'Playlist'
- class Playlisttrack(models.Model):
- playlistid = models.IntegerField(primary_key=True, db_column=u'PlaylistId') # Field name made lowercase.
- trackid = models.IntegerField(primary_key=True, db_column=u'TrackId') # Field name made lowercase.
- class Meta:
- db_table = u'PlaylistTrack'
- class Track(models.Model):
- trackid = models.IntegerField(primary_key=True, db_column=u'TrackId') # Field name made lowercase.
- name = models.TextField(db_column=u'Name') # Field name made lowercase. This field type is a guess.
- albumid = models.IntegerField(null=True, db_column=u'AlbumId', blank=True) # Field name made lowercase.
- mediatypeid = models.IntegerField(db_column=u'MediaTypeId') # Field name made lowercase.
- genreid = models.IntegerField(null=True, db_column=u'GenreId', blank=True) # Field name made lowercase.
- composer = models.TextField(db_column=u'Composer', blank=True) # Field name made lowercase. This field type is a guess.
- milliseconds = models.IntegerField(db_column=u'Milliseconds') # Field name made lowercase.
- bytes = models.IntegerField(null=True, db_column=u'Bytes', blank=True) # Field name made lowercase.
- unitprice = models.TextField(db_column=u'UnitPrice') # Field name made lowercase. This field type is a guess.
- class Meta:
- db_table = u'Track'
- class TrackInline(admin.TabularInline):
- model = PlaylistTrack
- class PlaylistAdmin(admin.ModelAdmin):
- inlines = (TrackInline, )
- admin.site.register(Playlist, PlaylistAdmin)
- admin.site.register(Track)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement