14 lines
430 B
Python
14 lines
430 B
Python
from django import forms
|
|
from .models import Incident, Brand
|
|
|
|
class IncidentForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Incident
|
|
fields = ['brand', 'incident_type', 'source_url', 'content']
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
user = kwargs.pop('user', None)
|
|
super(IncidentForm, self).__init__(*args, **kwargs)
|
|
if user:
|
|
self.fields['brand'].queryset = user.brands.all()
|