Created
May 28, 2014 02:16
-
-
Save actongorton/f2fe40927ebeed1549ee to your computer and use it in GitHub Desktop.
Housing Inspections
This file contains 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 housing.models import HouseInformation, InspectionReport | |
class InspectionReportInline(admin.TabularInline): | |
model = InspectionReport | |
class InspectionReportAdmin(admin.ModelAdmin): | |
inlines = [ | |
InspectionReportInline | |
] | |
class HouseInformationAdmin(admin.ModelAdmin): | |
fieldsets = ( | |
(None, { | |
'fields': ('house_name', 'house_type') | |
}), | |
('Location', { | |
'fields': ('address', 'longitude', 'latitude') | |
}), | |
) | |
inlines = [ | |
InspectionReportInline | |
] | |
admin.site.register(HouseInformation, HouseInformationAdmin) | |
admin.site.register(InspectionReport) |
This file contains 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 HouseInformation(models.Model): | |
house_name = models.CharField(max_length=200) | |
house_type = models.CharField(max_length=40) | |
address = models.CharField(max_length=200) | |
latitude = models.CharField(max_length=200) | |
longitude = models.CharField(max_length=200) | |
def __str__(self): | |
return self.house_name | |
class InspectionReport(models.Model): | |
house_name = models.ForeignKey(HouseInformation) | |
is_reinspection = models.BooleanField() | |
inspection_date = models.DateField(null=True, blank=True) | |
inspection_violations = models.IntegerField(null=True, blank=True) | |
file_name = models.FileField(upload_to='/housing/inspection_reports', null=True, blank=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment