from django.db import models
# Create your models here.
class Employees(models.Model):
user = models.CharField('Сотрудник:', max_length=300)
email = models.EmailField('Email сотрудника:', default=None)
is_active_status = models.BooleanField('Активен',default=True,)
def __str__(self):
return '%s' % self.user
class Meta:
verbose_name = 'Сотрудник'
verbose_name_plural = 'Сотрудники'
class Equipment(models.Model):
inventory_number = models.IntegerField('Инвентарный номер:')
user = models.ForeignKey('Employees', name='Сотрудник:', blank=True, null=True, default="Склад")
name = models.TextField('Оборудование:',max_length=300)
is_active = models.BooleanField('Активен:',default=True,)
def __str__(self):
return '%s' % self.name
class Meta:
verbose_name = 'Оборудование'
verbose_name_plural = 'Обрудование'
from django.contrib import admin
from .models import *
class EqmAdminInline(admin.TabularInline):
model = Equipment
extra = 1
class UserAdmin(admin.ModelAdmin):
list_display = [ field.name for field in Employees._meta.fields]
search_fields = [ search.name for search in Employees._meta.fields]
inlines = [EqmAdminInline]
class Meta:
model = Employees
admin.site.register(Employees, UserAdmin)
class EqmAdmin(admin.ModelAdmin):
list_display = [ field.name for field in Equipment._meta.fields]
search_fields = [search.name for search in Equipment._meta.fields]
class Meta:
model = Equipment
admin.site.register(Equipment,EqmAdmin)
from .models import *
@login_required()
def management_views(request):
equipment = Equipment.objects.all()
return render(request,'panel.html', locals())
<div class="container tabl">
<div class="row ">
<div class="col-xs-0 col-md-2"></div>
<div class="col-xs-0 col-md-1">Инв.номер:</div>
<div class="col-xs-0 col-md-3">Оборудование:</div>
<div class="col-xs-0 col-md-3">Сотрудник:</div>
<div class="col-xs-0 col-md-1">Статус:</div>
<div class="col-xs-0 col-md-2"></div>
</div>
{% for management in equipment%}
<div class="row ">
<div class="col-xs-0 col-md-2"></div>
<div class="col-xs-0 col-md-1">{{ management.inventory_number }}</div>
<div class="col-xs-0 col-md-3">{{ management.name }}</div>
<div class="col-xs-0 col-md-3">{{ management.user }}</div>
<div class="col-xs-0 col-md-1">{{ management.is_active }}</div>
<div class="col-xs-0 col-md-2"></div>
</div>
{% endfor %}
</div>
</div>
{% endblock %}