dairy package

dairy.forms module

class dairy.forms.BaseFeedAdditiveDoseFormSet(data=None, files=None, auto_id='id_%s', prefix=None, queryset=None, *, initial=None, **kwargs)

Bases: coolfarmtool.forms.BaseModelFormSet

clean()

Hook for doing any extra formset-wide cleaning after Form.clean() has been called on every form. Any ValidationError raised by this method will not be associated with a particular form; it will be accessible via formset.non_form_errors()

class dairy.forms.BeddingForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)

Bases: floppyforms.__future__.models.ModelForm

property media

Return all media required to render the widgets on this form.

class dairy.forms.DairyBatchImportForm(*args, **kwargs)

Bases: farm.forms.BaseBatchImportForm

property media

Return all media required to render the widgets on this form.

class dairy.forms.DairyGeneralForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)

Bases: coolfarmtool.forms.ConditionalModelForm

property media

Return all media required to render the widgets on this form.

class dairy.forms.EnergyForm(*args, **kwargs)

Bases: floppyforms.__future__.models.ModelForm

property media

Return all media required to render the widgets on this form.

save(commit=True, *args, **kwargs)

Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.

class dairy.forms.EnergyUsageForm(*args, **kwargs)

Bases: farm.forms.EnergyUsageForm

property media

Return all media required to render the widgets on this form.

class dairy.forms.FeedAdditiveDoseForm(*args, **kwargs)

Bases: cattle.forms.BaseCattleFeedAdditiveDoseForm

property media

Return all media required to render the widgets on this form.

class dairy.forms.FeedComponentForm1(*args, **kwargs)

Bases: cattle.forms.BaseCattleFeedComponentForm1

has_changed()

Return True if data differs from initial.

property media

Return all media required to render the widgets on this form.

class dairy.forms.FeedComponentForm2(*args, **kwargs)

Bases: cattle.forms.BaseCattleFeedComponentForm2

has_changed()

Return True if data differs from initial.

property media

Return all media required to render the widgets on this form.

class dairy.forms.FeedForm(*args, **kwargs)

Bases: cattle.forms.BaseCattleFeedForm

property media

Return all media required to render the widgets on this form.

class dairy.forms.FertiliserApplicationForm(*args, **kwargs)

Bases: cattle.forms.BaseCattleFertiliserApplicationForm

property media

Return all media required to render the widgets on this form.

class dairy.forms.GrazingForm(*args, **kwargs)

Bases: floppyforms.__future__.models.ModelForm

property media

Return all media required to render the widgets on this form.

save(commit=True, *args, **kwargs)

Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.

class dairy.forms.GrazingSectionForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)

Bases: floppyforms.__future__.models.ModelForm

has_changed()

Ensure that forms with un-changed initial data are still saved

property media

Return all media required to render the widgets on this form.

class dairy.forms.HerdForm(*args, **kwargs)

Bases: floppyforms.__future__.models.ModelForm

property media

Return all media required to render the widgets on this form.

save(commit=True, *args, **kwargs)

Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.

class dairy.forms.HerdSectionForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)

Bases: floppyforms.__future__.models.ModelForm

has_changed()

Return True if data differs from initial.

property media

Return all media required to render the widgets on this form.

class dairy.forms.ManureForm(*args, **kwargs)

Bases: cattle.forms.BaseCattleManureForm

property media

Return all media required to render the widgets on this form.

class dairy.forms.ManureManagementForm(*args, **kwargs)

Bases: cattle.forms.BaseCattleManureManagementForm

property media

Return all media required to render the widgets on this form.

class dairy.forms.MilkProductionForm(*args, **kwargs)

Bases: coolfarmtool.forms.ConditionalModelForm

clean()

Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.

property media

Return all media required to render the widgets on this form.

save(commit=True, *args, **kwargs)

Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.

class dairy.forms.TransportForm(*args, **kwargs)

Bases: floppyforms.__future__.models.ModelForm

property media

Return all media required to render the widgets on this form.

save(commit=True, *args, **kwargs)

Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.

dairy.models module

class dairy.models.Bedding(id, type, amount_value, amount_unit, product)

Bases: cattle.models.BaseCattleBedding

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

class dairy.models.DairyLifePhase(filter=(<object object>, ), item=<object object>, grouped=False)

Bases: dj.choices.Choices

class dairy.models.DairyProduct(id, creation_date, last_updated, slug, farm, reporting_year, name, has_co_products, has_waste_water, oxygen_demand_type, water_treatment_type, comments, cost_data, result_output, is_closed, verification_status, product_dry_value, product_dry_unit, waste_water_production_value, waste_water_production_unit, oxygen_demand_value, oxygen_demand_unit, product_ptr, livestock_type, variety, livestock_progress, evaluation_method, livestockproduct_ptr, feed_approach, date_time, date_month, progress, protein_measure, fat_content, protein_content, fertilisation_approach, grazing_area_value, grazing_area_unit)

Bases: cattle.models.CattleProduct, dairy.models.APIDairyResultsMixin

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

class FertilisationApproach(filter=(<object object>, ), item=<object object>, grouped=False)

Bases: dj.choices.Choices

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

class ProteinMeasures(filter=(<object object>, ), item=<object object>, grouped=False)

Bases: dj.choices.Choices

_emissions(skip_negative=False, emissions_without_weighting=None, **kwargs)

Calculate emissions across all input_sources, with overrides

Parameters

skip_negative (bool) – replace negative results with NaN

Returns

dict of emissions results

For each item in input_sources, this method adds a corresponding key to the results dictionary from the relevant _emissions_SOURCE property, e.g.

>>> class Foo(EmissionsModel):
>>>     input_sources = ['foo',]
>>>     @property
>>>     def _emissions_foo(self):
>>>         return quantity('kg CO2e', Decimal('50.0'))
>>> f = Foo()
>>> f._emissions()
{'foo': <Quantity: 50.000 kg CO2e>}

Items in kwargs which exist in the input_sources list are assumed to have their own _emissions_total property (or be an iterable where each item has one) following the above example:

>>> class Bar(object):
>>>     emissions_total = quantity('kg CO2e', 5)
>>>
>>> a = Bar(); b = Bar(); c= Bar()
>>> f._emissions(foo=[a, b, c])  # sum emissions from `a`, `b`, and `c`
{'foo': <Quantity: 15.000 kg CO2e>}
>>> f._emissions(foo=a)  # just use a.emissions_total
{'foo': <Quantity: 5.000 kg CO2e>}

This is used e.g. for temporarily over-riding farm.models.Product.direct_energy when calculating live results.

If a kwarg item matches the name of an _emissions_SOURCE property on self, it is assumed to be a quantity.Quantity object, and is then used directly – instead of that property – in the result:

>>> f._emissions(_emissions_foo=quantity('kg CO2e', Decimal('100.0'))
{'foo': <Quantity: 100.000 kg CO2e>}

CropProductTreatmentView uses this version to pre-calculate fertiliser, management and paddy field emissions for live updates.

average_pke_per_animal

average kg of PKE per animal per day

average_pke_per_fpcm

average kg of PKE per fpcm

average_soy_per_animal

average kg of soy per animal per day

average_soy_per_animal_per_day

ef kg of soy per animal per day

Total soy whole farm consumed by herd Kg/year divided by number of total Herd by 365 days

average_soy_per_cows_per_day

Average kg soy / (milking + dry cow) / day

Total soy consumed by herd Kg/year divided by (Milking cows + dry cows) / 365 days

average_soy_per_fpcm

average kg of PKE per fpcm

average_soy_per_year_per_fpcm

average kg of soy per fpcm

fpcm

Fat and protein corrected milk

Property which calculates fat and protein corrected milk value Returns:

Fat and True Protein corrected milk (kg year^-1)

is_true_protein_content

Property for checking whether the Protein Content user input is True or Crude

net_energy_lactation_allocation

Energy for lactation [MJ/kg of milk produced]

pke_per_milking_cow

kg of PKE per milking cow per day

soy_per_milking_cow

kg of soy per milking cow per day

property total_soy_consumption_on_farm

calculate as follows (number of animals in section * feed total dry matter) * reference period days (default 365) append the result to totals

Returns

sum of totals

total_soy_dmi_whole_year

calculate as follows (number of animals in section * (feed total dry matter * (soy percentage / 100))) * reference period days

this takes into account that some products are not entirely soy and factorises the percentages in order to account for the mixture append the result to totals

Returns

sum of totals

total_soy_per_day

Total soy whole farm consumed by herd Kg/year divided by 365 days

true_protein_content

Property which retrieves protein content depending on whether ProteinMeasures is set to True or Crude

update_feed_dmi_estimates()

Update automatically calculated feed dry matter intakes based on new estimates

weighting

Meat Allocation Factor combined_list is a list of lists, each containing the weight of the animal and the net_energy_growth value as per : 3.2.2. Meat Allocation Factor -> AF_Milk

class dairy.models.FeedAdditiveDose(id, days, herd_section_percentage, ndf, crude_fat, dose_value, dose_unit, herd_section, feed_additive_type)

Bases: cattle.models.BaseCattleFeedAdditiveDose

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

class dairy.models.FeedComponent(id, percentage, certified, calculated, item_customised, dry_matter_value, dry_matter_unit, custom_dry_matter_content_value, custom_dry_matter_content_unit, custom_de_cattle_value, custom_de_cattle_unit, custom_protein_content_value, custom_protein_content_unit, product, section, item, region, crop_product)

Bases: cattle.models.BaseCattleFeedComponent

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

class dairy.models.FeedItem(id, name, name_feedprint, order, category, certified, dry_matter, gross_energy, de_cattle, protein_content, on_farm, soy_percentage, y_m, system_boundary)

Bases: django.db.models.base.Model

class Category(filter=(<object object>, ), item=<object object>, grouped=False)

Bases: dj.choices.Choices

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

class SystemBoundary(filter=(<object object>, ), item=<object object>, grouped=False)

Bases: dj.choices.Choices

de_cattle

Digestible energy for cattle, MJ / kg dry matter

dry_matter

Dry matter content, g / kg

gross_energy

Energy content, MJ / kg dry matter

order

Sort order

protein_content

Crude protein content, g / kg dry matter

y_m

Methane conversion factor

class dairy.models.FeedItemRegion(*args, **kwargs)

Bases: django.db.models.base.Model

GFLI Regions

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

class dairy.models.FeedItemVersion(id, creation_date, last_updated, ef_n2o, ef_ch4, ef_co2, luluc_co2, dry_matter, gross_energy, de_cattle, protein_content, soy_percentage, y_m, version, feed_item, region)

Bases: coolfarmtool.mixins.LastUpdatedMixin

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

de_cattle

Digestible energy for cattle, MJ / kg dry matter

dry_matter

Dry matter content, g / kg

ef_ch4

CH4 emissions, kg CO2-eq / kg

ef_n2o

N2O emissions, kg N2O / kg

gross_energy

Energy content, MJ / kg dry matter

luluc_co2

Land use & land-use change emissions, kg CO2-eq / kg

protein_content

Crude protein content, g / kg dry matter

y_m

Methane conversion factor

class dairy.models.FertiliserApplication(id, date, rate_measure, custom_ingredients, inhibition, rate_value, rate_unit, production, product, type)

Bases: cattle.models.BaseCattleFertiliserApplication

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

class dairy.models.Grazing(id, days, hours, category, quality, section)

Bases: cattle.models.BaseCattleGrazing

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

class dairy.models.HerdSection(id, animals, sold_animals, purchased_animals, live_weight_value, live_weight_unit, sold_weight_value, sold_weight_unit, purchased_weight_value, purchased_weight_unit, product, phase)

Bases: cattle.models.BaseCattleHerdSection

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

property _emissions_manure_ch4

CH4 emissions kg CH4 / head / day

_energy_growth

MJ / head / day

_energy_lactation

MJ / head / day

_frac_gasMS

Percent of managed manure for livestock

Volatilizes as NH3 and NOx from manure management system

gross_energy

Gross energy intake / requirement, MJ / head / day

main_manure_types

main manure types allocated

n_retention

kg N2O-N / head / day

class dairy.models.LiveWeight(id, variety, phase, weight, weight_gain)

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

class dairy.models.LivestockProperties(id, phase, c_f, c, c_pregnancy)

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

class dairy.models.ManureManagement(id, type, allocation, herd_section)

Bases: livestock.models.BaseManureManagement

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

class dairy.models.MilkProperties(id, variety, fat_content, protein_content)

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

dairy.views module

class dairy.views.CloseDairyMixin

Bases: dairy.views.DairyMixin

class dairy.views.CropFeedView(**kwargs)

Bases: braces.views._access.LoginRequiredMixin, django.views.generic.detail.SingleObjectMixin, braces.views._ajax.JSONResponseMixin, farm.views.AjaxResponseMixin, django.views.generic.base.View

dispatch(request, *args, **kwargs)

Make request.is_ajax return True if “ajax” is given in GET

form_invalid(form)

Return a dict of form.errors

get_object(queryset=None)

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

model

alias of crop.models.CropProduct

class dairy.views.DairyBatchImportCompleteView(**kwargs)

Bases: farm.views.FarmMixin, django.views.generic.base.TemplateView

class dairy.views.DairyBatchImportView(**kwargs)

Bases: farm.views.FarmMixin, django.views.generic.edit.FormView

form_class

alias of dairy.forms.DairyBatchImportForm

form_valid(form)

If the form is valid, redirect to the supplied URL.

get_form_kwargs()

Return the keyword arguments for instantiating the form.

class dairy.views.DairyCloseView(**kwargs)

Bases: farm.views.ProductCloseViewMixin, dairy.views.DairyMixin, django.views.generic.detail.SingleObjectMixin, django.views.generic.base.View

get_success_url()

Return the URL to redirect to after closing the product.

class dairy.views.DairyDebugView(**kwargs)

Bases: dairy.views.DairyMixin, farm.views.AjaxResponseMixin, braces.views._ajax.JSONResponseMixin, farm.views.CSVResponseMixin, django.views.generic.detail.DetailView

class dairy.views.DairyEnergyView(**kwargs)

Bases: dairy.views.CloseDairyMixin, farm.views.AjaxResponseMixin, braces.views._ajax.JSONResponseMixin, django.views.generic.edit.UpdateView

form_class

alias of dairy.forms.EnergyForm

form_valid(form)

If the form is valid, save the associated model.

get_context_data(**kwargs)

overidden get_context_data to inject a custom form onto certain page contexts in order to allow dynamic fields when using the save as feature e.g. dairy product and crop product would have different forms but this saves us having to create two forms just for the sake of one field

we only use this form on GET because the POST is managed by the ProductSaveAsView

Returns

dictionary of keyword arguements

get_form(form_class=<class 'dairy.forms.EnergyForm'>)

Return an instance of the form to be used in this view.

get_success_url()

Return the URL to redirect to after processing a valid form.

class dairy.views.DairyExportView(**kwargs)

Bases: dairy.views.DairyMixin, farm.views.ProductExportView

class dairy.views.DairyFeedView(**kwargs)

Bases: dairy.views.CloseDairyMixin, farm.views.AjaxResponseMixin, braces.views._ajax.JSONResponseMixin, django.views.generic.edit.UpdateView

dispatch(request, *args, **kwargs)

Make request.is_ajax return True if “ajax” is given in GET

form_class

alias of dairy.forms.FeedForm

form_valid(form)

If the form is valid, save the associated model.

get_context_data(**kwargs)

overidden get_context_data to inject a custom form onto certain page contexts in order to allow dynamic fields when using the save as feature e.g. dairy product and crop product would have different forms but this saves us having to create two forms just for the sake of one field

we only use this form on GET because the POST is managed by the ProductSaveAsView

Returns

dictionary of keyword arguements

get_form(form_class=<class 'dairy.forms.FeedForm'>)

Return an instance of the form to be used in this view.

get_success_url()

Return the URL to redirect to after processing a valid form.

class dairy.views.DairyGeneralView(**kwargs)

Bases: dairy.views.CloseDairyMixin, django.views.generic.edit.FormMixin, django.views.generic.detail.DetailView

form_class

alias of dairy.forms.DairyGeneralForm

get_object(queryset=None)

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

class dairy.views.DairyGrazingView(**kwargs)

Bases: dairy.views.CloseDairyMixin, farm.views.AjaxResponseMixin, braces.views._ajax.JSONResponseMixin, django.views.generic.edit.UpdateView

dispatch(request, *args, **kwargs)

Make request.is_ajax return True if “ajax” is given in GET

form_class

alias of dairy.forms.GrazingForm

form_valid(form)

If the form is valid, save the associated model.

get_context_data(**kwargs)

overidden get_context_data to inject a custom form onto certain page contexts in order to allow dynamic fields when using the save as feature e.g. dairy product and crop product would have different forms but this saves us having to create two forms just for the sake of one field

we only use this form on GET because the POST is managed by the ProductSaveAsView

Returns

dictionary of keyword arguements

get_form(form_class=<class 'dairy.forms.GrazingForm'>)

Return an instance of the form to be used in this view.

get_success_url()

Return the URL to redirect to after processing a valid form.

class dairy.views.DairyHerdView(**kwargs)

Bases: dairy.views.CloseDairyMixin, farm.views.AjaxResponseMixin, braces.views._ajax.JSONResponseMixin, django.views.generic.edit.UpdateView

form_class

alias of dairy.forms.HerdForm

form_valid(form)

If the form is valid, save the associated model.

get_context_data(**kwargs)

overidden get_context_data to inject a custom form onto certain page contexts in order to allow dynamic fields when using the save as feature e.g. dairy product and crop product would have different forms but this saves us having to create two forms just for the sake of one field

we only use this form on GET because the POST is managed by the ProductSaveAsView

Returns

dictionary of keyword arguements

get_form(form_class=<class 'dairy.forms.HerdForm'>)

Return an instance of the form to be used in this view.

get_success_url()

Return the URL to redirect to after processing a valid form.

class dairy.views.DairyJsonExportView(**kwargs)

Bases: dairy.views.DairyMixin, braces.views._ajax.JSONResponseMixin, django.views.generic.detail.DetailView

model

alias of dairy.models.DairyProduct

class dairy.views.DairyJsonResultsExportView(**kwargs)

Bases: dairy.views.DairyMixin, braces.views._ajax.JSONResponseMixin, django.views.generic.detail.DetailView

model

alias of dairy.models.DairyProduct

class dairy.views.DairyManureView(**kwargs)

Bases: dairy.views.CloseDairyMixin, farm.views.AjaxResponseMixin, braces.views._ajax.JSONResponseMixin, django.views.generic.edit.UpdateView

form_class

alias of dairy.forms.ManureForm

form_valid(form)

If the form is valid, save the associated model.

get_context_data(**kwargs)

overidden get_context_data to inject a custom form onto certain page contexts in order to allow dynamic fields when using the save as feature e.g. dairy product and crop product would have different forms but this saves us having to create two forms just for the sake of one field

we only use this form on GET because the POST is managed by the ProductSaveAsView

Returns

dictionary of keyword arguements

get_form(form_class=<class 'dairy.forms.ManureForm'>)

Return an instance of the form to be used in this view.

get_success_url()

Return the URL to redirect to after processing a valid form.

class dairy.views.DairyMilkView(**kwargs)

Bases: farm.views.ProductCreationMixin, dairy.views.CloseDairyMixin, farm.views.AjaxResponseMixin, braces.views._ajax.JSONResponseMixin, django.views.generic.edit.CreateView, django.views.generic.edit.UpdateView

form_class

alias of dairy.forms.MilkProductionForm

form_valid(form)

If the form is valid, save the associated model.

get_context_data(**kwargs)

overidden get_context_data to inject a custom form onto certain page contexts in order to allow dynamic fields when using the save as feature e.g. dairy product and crop product would have different forms but this saves us having to create two forms just for the sake of one field

we only use this form on GET because the POST is managed by the ProductSaveAsView

Returns

dictionary of keyword arguements

get_form_kwargs()

Return the keyword arguments for instantiating the form.

get_object(queryset=None)

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

get_success_url()

Return the URL to redirect to after processing a valid form.

class dairy.views.DairyMixin

Bases: farm.views.FarmMixin

Pull dairy product from the URL

TODO: redirect to create instead of 404

get_context_data(**kwargs)

overidden get_context_data to inject a custom form onto certain page contexts in order to allow dynamic fields when using the save as feature e.g. dairy product and crop product would have different forms but this saves us having to create two forms just for the sake of one field

we only use this form on GET because the POST is managed by the ProductSaveAsView

Returns

dictionary of keyword arguements

model

alias of dairy.models.DairyProduct

class dairy.views.DairyPartialResultsView(**kwargs)

Bases: dairy.views.DairyMixin, farm.views.AjaxResponseMixin, braces.views._ajax.JSONResponseMixin, django.views.generic.detail.DetailView

class dairy.views.DairyResultsView(**kwargs)

Bases: dairy.views.DairyMixin, farm.views.AjaxResponseMixin, braces.views._ajax.JSONResponseMixin, django.views.generic.detail.DetailView

Full results view, now only used for API

class dairy.views.DairySaveAsView(**kwargs)

Bases: dairy.views.DairyMixin, farm.views.ProductSaveAsView

get_context_data(**kwargs)

overidden get_context_data to inject a custom form onto certain page contexts in order to allow dynamic fields when using the save as feature e.g. dairy product and crop product would have different forms but this saves us having to create two forms just for the sake of one field

we only use this form on GET because the POST is managed by the ProductSaveAsView

Returns

dictionary of keyword arguements

class dairy.views.DairySummaryCompare(**kwargs)

Bases: dairy.views.DairySummaryMixin, farm.views.SummaryCompareMixin, django.views.generic.detail.DetailView

class dairy.views.DairySummaryCosts(**kwargs)

Bases: dairy.views.DairySummaryMixin, farm.views.SummaryCostsMixin, django.views.generic.detail.DetailView

get_items_expenditure()

Return a list of (section_key, name, [items]). See “get_product_income”, above, for return full definition.

class dairy.views.DairySummaryData(**kwargs)

Bases: dairy.views.DairySummaryMixin, django.views.generic.detail.DetailView

class dairy.views.DairySummaryGHGs(**kwargs)

Bases: dairy.views.DairySummaryMixin, django.views.generic.detail.DetailView

get_context_data(**kwargs)

overidden get_context_data to inject a custom form onto certain page contexts in order to allow dynamic fields when using the save as feature e.g. dairy product and crop product would have different forms but this saves us having to create two forms just for the sake of one field

we only use this form on GET because the POST is managed by the ProductSaveAsView

Returns

dictionary of keyword arguements

class dairy.views.DairySummaryMixin

Bases: dairy.views.DairyMixin

get_context_data(**kwargs)

overidden get_context_data to inject a custom form onto certain page contexts in order to allow dynamic fields when using the save as feature e.g. dairy product and crop product would have different forms but this saves us having to create two forms just for the sake of one field

we only use this form on GET because the POST is managed by the ProductSaveAsView

Returns

dictionary of keyword arguements

class dairy.views.DairySummaryMore(**kwargs)

Bases: dairy.views.DairySummaryMixin, django.views.generic.detail.DetailView

class dairy.views.DairySummaryPerformance(**kwargs)

Bases: dairy.views.DairySummaryMixin, django.views.generic.detail.DetailView

class dairy.views.DairySummaryShare(**kwargs)

Bases: dairy.views.DairySummaryMixin, farm.views.SummaryShareMixin, django.views.generic.detail.DetailView

class dairy.views.DairyTransportView(**kwargs)

Bases: dairy.views.CloseDairyMixin, farm.views.AjaxResponseMixin, braces.views._ajax.JSONResponseMixin, django.views.generic.edit.UpdateView

form_class

alias of dairy.forms.TransportForm

form_valid(form)

If the form is valid, save the associated model.

get_context_data(**kwargs)

overidden get_context_data to inject a custom form onto certain page contexts in order to allow dynamic fields when using the save as feature e.g. dairy product and crop product would have different forms but this saves us having to create two forms just for the sake of one field

we only use this form on GET because the POST is managed by the ProductSaveAsView

Returns

dictionary of keyword arguements

get_form(form_class=<class 'dairy.forms.TransportForm'>)

Return an instance of the form to be used in this view.

get_success_url()

Return the URL to redirect to after processing a valid form.

class dairy.views.FeedItemDetailView(**kwargs)

Bases: farm.views.FarmMixin, farm.views.AjaxResponseMixin, braces.views._ajax.JSONResponseMixin, django.views.generic.detail.DetailView

model

alias of dairy.models.FeedItem

class dairy.views.FeedItemRegionDetailView(**kwargs)

Bases: farm.views.FarmMixin, farm.views.AjaxResponseMixin, braces.views._ajax.JSONResponseMixin, django.views.generic.detail.DetailView

model

alias of dairy.models.FeedItemRegion

class dairy.views.VarietyMilkView(**kwargs)

Bases: farm.views.FarmMixin, farm.views.AjaxResponseMixin, braces.views._ajax.JSONResponseMixin, django.views.generic.detail.DetailView

model

alias of livestock.models.LivestockVariety