neulab/docprompting-conala huggingface dataset:
class YearMixin  
A mixin that can be used to retrieve and provide parsing information for a year component of a date. Methods and Attributes  
year_format  
The strftime() format to use when parsing the year. By default, this is '%Y'. 
  
year  
Optional The value for the year, as a string. By default, set to None, which means the year will be determined using other means. 
  
get_year_format()  
Returns the strftime() format to use when parsing the year. Returns year_format by default. 
  
get_year()  
Returns the year for which this view will display data, as a string. Tries the following sources, in order:  The value of the YearMixin.year attribute. The value of the year argument captured in the URL pattern. The value of the year GET query argument.  Raises a 404 if no valid year specification can be found. 
  
get_next_year(date)  
Returns a date object containing the first day of the year after the date provided. This function can also return None or raise an Http404 exception, depending on the values of allow_empty and allow_future. 
  
get_previous_year(date)  
Returns a date object containing the first day of the year before the date provided. This function can also return None or raise an Http404 exception, depending on the values of allow_empty and allow_future.
get_next_year(date)  
Returns a date object containing the first day of the year after the date provided. This function can also return None or raise an Http404 exception, depending on the values of allow_empty and allow_future.
get_previous_year(date)  
Returns a date object containing the first day of the year before the date provided. This function can also return None or raise an Http404 exception, depending on the values of allow_empty and allow_future.
get_year()  
Returns the year for which this view will display data, as a string. Tries the following sources, in order:  The value of the YearMixin.year attribute. The value of the year argument captured in the URL pattern. The value of the year GET query argument.  Raises a 404 if no valid year specification can be found.
get_year_format()  
Returns the strftime() format to use when parsing the year. Returns year_format by default.
year  
Optional The value for the year, as a string. By default, set to None, which means the year will be determined using other means.
year_format  
The strftime() format to use when parsing the year. By default, this is '%Y'.
class django.views.generic.detail.BaseDetailView  
A base view for displaying a single object. It is not intended to be used directly, but rather as a parent class of the django.views.generic.detail.DetailView or other views representing details of a single object. Ancestors (MRO) This view inherits methods and attributes from the following views:  django.views.generic.detail.SingleObjectMixin django.views.generic.base.View  Methods  
get(request, *args, **kwargs)  
Adds object to the context.
class django.views.generic.detail.DetailView  
While this view is executing, self.object will contain the object that the view is operating upon. Ancestors (MRO) This view inherits methods and attributes from the following views:  django.views.generic.detail.SingleObjectTemplateResponseMixin django.views.generic.base.TemplateResponseMixin django.views.generic.detail.BaseDetailView django.views.generic.detail.SingleObjectMixin django.views.generic.base.View  Method Flowchart  setup() dispatch() http_method_not_allowed() get_template_names() get_slug_field() get_queryset() get_object() get_context_object_name() get_context_data() get() render_to_response()  Example myapp/views.py: from django.utils import timezone
from django.views.generic.detail import DetailView

from articles.models import Article

class ArticleDetailView(DetailView):

    model = Article

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['now'] = timezone.now()
        return context
 Example myapp/urls.py: from django.urls import path

from article.views import ArticleDetailView

urlpatterns = [
    path('<slug:slug>/', ArticleDetailView.as_view(), name='article-detail'),
]
 Example myapp/article_detail.html: <h1>{{ object.headline }}</h1>
<p>{{ object.content }}</p>
<p>Reporter: {{ object.reporter }}</p>
<p>Published: {{ object.pub_date|date }}</p>
<p>Date: {{ now|date }}</p>
context_object_name  
Designates the name of the variable to use in the context.
get_context_data(**kwargs)  
Returns context data for displaying the object. The base implementation of this method requires that the self.object attribute be set by the view (even if None). Be sure to do this if you are using this mixin without one of the built-in views that does so. It returns a dictionary with these contents:  
object: The object that this view is displaying (self.object). 
context_object_name: self.object will also be stored under the name returned by get_context_object_name(), which defaults to the lowercased version of the model name.   Context variables override values from template context processors Any variables from get_context_data() take precedence over context variables from context processors. For example, if your view sets the model attribute to User, the default context object name of user would override the user variable from the django.contrib.auth.context_processors.auth() context processor. Use get_context_object_name() to avoid a clash.
get_context_object_name(obj)  
Return the context variable name that will be used to contain the data that this view is manipulating. If context_object_name is not set, the context name will be constructed from the model_name of the model that the queryset is composed from. For example, the model Article would have context object named 'article'.
get_object(queryset=None)  
Returns the single object that this view will display. If queryset is provided, that queryset will be used as the source of objects; otherwise, get_queryset() will be used. get_object() looks for a pk_url_kwarg argument in the arguments to the view; if this argument is found, this method performs a primary-key based lookup using that value. If this argument is not found, it looks for a slug_url_kwarg argument, and performs a slug lookup using the slug_field. When query_pk_and_slug is True, get_object() will perform its lookup using both the primary key and the slug.
get_queryset()  
Returns the queryset that will be used to retrieve the object that this view will display. By default, get_queryset() returns the value of the queryset attribute if it is set, otherwise it constructs a QuerySet by calling the all() method on the model attribute’s default manager.
get_slug_field()  
Returns the name of a slug field to be used to look up by slug. By default this returns the value of slug_field.
model  
The model that this view will display data for. Specifying model
= Foo is effectively the same as specifying queryset =
Foo.objects.all(), where objects stands for Foo’s default manager.
pk_url_kwarg  
The name of the URLConf keyword argument that contains the primary key. By default, pk_url_kwarg is 'pk'.
query_pk_and_slug  
If True, causes get_object() to perform its lookup using both the primary key and the slug. Defaults to False. This attribute can help mitigate insecure direct object reference attacks. When applications allow access to individual objects by a sequential primary key, an attacker could brute-force guess all URLs; thereby obtaining a list of all objects in the application. If users with access to individual objects should be prevented from obtaining this list, setting query_pk_and_slug to True will help prevent the guessing of URLs as each URL will require two correct, non-sequential arguments. Using a unique slug may serve the same purpose, but this scheme allows you to have non-unique slugs.
queryset  
A QuerySet that represents the objects. If provided, the value of queryset supersedes the value provided for model.  Warning queryset is a class attribute with a mutable value so care must be taken when using it directly. Before using it, either call its all() method or retrieve it with get_queryset() which takes care of the cloning behind the scenes.
slug_field  
The name of the field on the model that contains the slug. By default, slug_field is 'slug'.
slug_url_kwarg  
The name of the URLConf keyword argument that contains the slug. By default, slug_url_kwarg is 'slug'.
class django.views.generic.detail.SingleObjectTemplateResponseMixin  
A mixin class that performs template-based response rendering for views that operate upon a single object instance. Requires that the view it is mixed with provides self.object, the object instance that the view is operating on. self.object will usually be, but is not required to be, an instance of a Django model. It may be None if the view is in the process of constructing a new instance. Extends  TemplateResponseMixin  Methods and Attributes  
template_name_field  
The field on the current object instance that can be used to determine the name of a candidate template. If either template_name_field itself or the value of the template_name_field on the current object instance is None, the object will not be used for a candidate template name. 
  
template_name_suffix  
The suffix to append to the auto-generated candidate template name. Default suffix is _detail. 
  
get_template_names()  
Returns a list of candidate template names. Returns the following list:  the value of template_name on the view (if provided) the contents of the template_name_field field on the object instance that the view is operating upon (if available) <app_label>/<model_name><template_name_suffix>.html
get_template_names()  
Returns a list of candidate template names. Returns the following list:  the value of template_name on the view (if provided) the contents of the template_name_field field on the object instance that the view is operating upon (if available) <app_label>/<model_name><template_name_suffix>.html
template_name_field  
The field on the current object instance that can be used to determine the name of a candidate template. If either template_name_field itself or the value of the template_name_field on the current object instance is None, the object will not be used for a candidate template name.
template_name_suffix  
The suffix to append to the auto-generated candidate template name. Default suffix is _detail.
class django.views.generic.edit.BaseCreateView  
A base view for creating a new object instance. It is not intended to be used directly, but rather as a parent class of the django.views.generic.edit.CreateView. Ancestors (MRO) This view inherits methods and attributes from the following views:  django.views.generic.edit.ModelFormMixin django.views.generic.edit.ProcessFormView  Methods  
get(request, *args, **kwargs)  
Sets the current object instance (self.object) to None. 
  
post(request, *args, **kwargs)  
Sets the current object instance (self.object) to None.
get(request, *args, **kwargs)  
Sets the current object instance (self.object) to None.
post(request, *args, **kwargs)  
Sets the current object instance (self.object) to None.
class django.views.generic.edit.BaseDeleteView  
A base view for deleting an object instance. It is not intended to be used directly, but rather as a parent class of the django.views.generic.edit.DeleteView. Ancestors (MRO) This view inherits methods and attributes from the following views:  django.views.generic.edit.DeletionMixin django.views.generic.edit.FormMixin django.views.generic.detail.BaseDetailView   Changed in Django 4.0: In older versions, BaseDeleteView does not inherit from FormMixin.
class django.views.generic.edit.BaseFormView  
A base view for displaying a form. It is not intended to be used directly, but rather as a parent class of the django.views.generic.edit.FormView or other views displaying a form. Ancestors (MRO) This view inherits methods and attributes from the following views:  django.views.generic.edit.FormMixin django.views.generic.edit.ProcessFormView
class django.views.generic.edit.BaseUpdateView  
A base view for updating an existing object instance. It is not intended to be used directly, but rather as a parent class of the django.views.generic.edit.UpdateView. Ancestors (MRO) This view inherits methods and attributes from the following views:  django.views.generic.edit.ModelFormMixin django.views.generic.edit.ProcessFormView  Methods  
get(request, *args, **kwargs)  
Sets the current object instance (self.object). 
  
post(request, *args, **kwargs)  
Sets the current object instance (self.object).
get(request, *args, **kwargs)  
Sets the current object instance (self.object).
post(request, *args, **kwargs)  
Sets the current object instance (self.object).
class django.views.generic.edit.CreateView  
A view that displays a form for creating an object, redisplaying the form with validation errors (if there are any) and saving the object. Ancestors (MRO) This view inherits methods and attributes from the following views:  django.views.generic.detail.SingleObjectTemplateResponseMixin django.views.generic.base.TemplateResponseMixin django.views.generic.edit.BaseCreateView django.views.generic.edit.ModelFormMixin django.views.generic.edit.FormMixin django.views.generic.detail.SingleObjectMixin django.views.generic.edit.ProcessFormView django.views.generic.base.View  Attributes  
template_name_suffix  
The CreateView page displayed to a GET request uses a template_name_suffix of '_form'. For example, changing this attribute to '_create_form' for a view creating objects for the example Author model would cause the default template_name to be 'myapp/author_create_form.html'. 
  
object  
When using CreateView you have access to self.object, which is the object being created. If the object hasn’t been created yet, the value will be None. 
 Example myapp/views.py: from django.views.generic.edit import CreateView
from myapp.models import Author

class AuthorCreateView(CreateView):
    model = Author
    fields = ['name']
 Example myapp/author_form.html: <form method="post">{% csrf_token %}
    {{ form.as_p }}
    <input type="submit" value="Save">
</form>
object  
When using CreateView you have access to self.object, which is the object being created. If the object hasn’t been created yet, the value will be None.
template_name_suffix  
The CreateView page displayed to a GET request uses a template_name_suffix of '_form'. For example, changing this attribute to '_create_form' for a view creating objects for the example Author model would cause the default template_name to be 'myapp/author_create_form.html'.
class django.views.generic.edit.DeleteView  
A view that displays a confirmation page and deletes an existing object. The given object will only be deleted if the request method is POST. If this view is fetched via GET, it will display a confirmation page that should contain a form that POSTs to the same URL. Ancestors (MRO) This view inherits methods and attributes from the following views:  django.views.generic.detail.SingleObjectTemplateResponseMixin django.views.generic.base.TemplateResponseMixin django.views.generic.edit.BaseDeleteView django.views.generic.edit.DeletionMixin django.views.generic.edit.FormMixin django.views.generic.base.ContextMixin django.views.generic.detail.BaseDetailView django.views.generic.detail.SingleObjectMixin django.views.generic.base.View  Attributes  
form_class  
 New in Django 4.0.  Inherited from BaseDeleteView. The form class that will be used to confirm the request. By default django.forms.Form, resulting in an empty form that is always valid. By providing your own Form subclass, you can add additional requirements, such as a confirmation checkbox, for example. 
  
template_name_suffix  
The DeleteView page displayed to a GET request uses a template_name_suffix of '_confirm_delete'. For example, changing this attribute to '_check_delete' for a view deleting objects for the example Author model would cause the default template_name to be 'myapp/author_check_delete.html'. 
 Example myapp/views.py: from django.urls import reverse_lazy
from django.views.generic.edit import DeleteView
from myapp.models import Author

class AuthorDeleteView(DeleteView):
    model = Author
    success_url = reverse_lazy('author-list')
 Example myapp/author_confirm_delete.html: <form method="post">{% csrf_token %}
    <p>Are you sure you want to delete "{{ object }}"?</p>
    {{ form }}
    <input type="submit" value="Confirm">
</form>
form_class  
 New in Django 4.0.  Inherited from BaseDeleteView. The form class that will be used to confirm the request. By default django.forms.Form, resulting in an empty form that is always valid. By providing your own Form subclass, you can add additional requirements, such as a confirmation checkbox, for example.
template_name_suffix  
The DeleteView page displayed to a GET request uses a template_name_suffix of '_confirm_delete'. For example, changing this attribute to '_check_delete' for a view deleting objects for the example Author model would cause the default template_name to be 'myapp/author_check_delete.html'.
class django.views.generic.edit.DeletionMixin  
Enables handling of the DELETE HTTP action. Methods and Attributes  
success_url  
The url to redirect to when the nominated object has been successfully deleted. success_url may contain dictionary string formatting, which will be interpolated against the object’s field attributes. For example, you could use success_url="/parent/{parent_id}/" to redirect to a URL composed out of the parent_id field on a model. 
  
delete(request, *args, **kwargs)  
Retrieves the target object and calls its delete() method, then redirects to the success URL. 
  
get_success_url()  
Returns the url to redirect to when the nominated object has been successfully deleted. Returns success_url by default.
delete(request, *args, **kwargs)  
Retrieves the target object and calls its delete() method, then redirects to the success URL.
get_success_url()  
Returns the url to redirect to when the nominated object has been successfully deleted. Returns success_url by default.
success_url  
The url to redirect to when the nominated object has been successfully deleted. success_url may contain dictionary string formatting, which will be interpolated against the object’s field attributes. For example, you could use success_url="/parent/{parent_id}/" to redirect to a URL composed out of the parent_id field on a model.
class django.views.generic.edit.FormMixin  
A mixin class that provides facilities for creating and displaying forms. Mixins  django.views.generic.base.ContextMixin  Methods and Attributes  
initial  
A dictionary containing initial data for the form. 
  
form_class  
The form class to instantiate. 
  
success_url  
The URL to redirect to when the form is successfully processed. 
  
prefix  
The prefix for the generated form. 
  
get_initial()  
Retrieve initial data for the form. By default, returns a copy of initial. 
  
get_form_class()  
Retrieve the form class to instantiate. By default form_class. 
  
get_form(form_class=None)  
Instantiate an instance of form_class using get_form_kwargs(). If form_class isn’t provided get_form_class() will be used. 
  
get_form_kwargs()  
Build the keyword arguments required to instantiate the form. The initial argument is set to get_initial(). If the request is a POST or PUT, the request data (request.POST and request.FILES) will also be provided. 
  
get_prefix()  
Determine the prefix for the generated form. Returns prefix by default. 
  
get_success_url()  
Determine the URL to redirect to when the form is successfully validated. Returns success_url by default. 
  
form_valid(form)  
Redirects to get_success_url(). 
  
form_invalid(form)  
Renders a response, providing the invalid form as context. 
  
get_context_data(**kwargs)  
Calls get_form() and adds the result to the context data with the name ‘form’.
get_context_data(**kwargs)  
Calls get_form() and adds the result to the context data with the name ‘form’.
get_form(form_class=None)  
Instantiate an instance of form_class using get_form_kwargs(). If form_class isn’t provided get_form_class() will be used.
get_form_class()  
Retrieve the form class to instantiate. By default form_class.
get_form_kwargs()  
Build the keyword arguments required to instantiate the form. The initial argument is set to get_initial(). If the request is a POST or PUT, the request data (request.POST and request.FILES) will also be provided.
get_initial()  
Retrieve initial data for the form. By default, returns a copy of initial.
get_success_url()  
Determine the URL to redirect to when the form is successfully validated. Returns success_url by default.
class django.views.generic.edit.FormView  
A view that displays a form. On error, redisplays the form with validation errors; on success, redirects to a new URL. Ancestors (MRO) This view inherits methods and attributes from the following views:  django.views.generic.base.TemplateResponseMixin django.views.generic.edit.BaseFormView django.views.generic.edit.FormMixin django.views.generic.edit.ProcessFormView django.views.generic.base.View  Example myapp/forms.py: from django import forms

class ContactForm(forms.Form):
    name = forms.CharField()
    message = forms.CharField(widget=forms.Textarea)

    def send_email(self):
        # send email using the self.cleaned_data dictionary
        pass
 Example myapp/views.py: from myapp.forms import ContactForm
from django.views.generic.edit import FormView

class ContactFormView(FormView):
    template_name = 'contact.html'
    form_class = ContactForm
    success_url = '/thanks/'

    def form_valid(self, form):
        # This method is called when valid form data has been POSTed.
        # It should return an HttpResponse.
        form.send_email()
        return super().form_valid(form)
 Example myapp/contact.html: <form method="post">{% csrf_token %}
    {{ form.as_p }}
    <input type="submit" value="Send message">
</form>
class django.views.generic.edit.ModelFormMixin  
A form mixin that works on ModelForms, rather than a standalone form. Since this is a subclass of SingleObjectMixin, instances of this mixin have access to the model and queryset attributes, describing the type of object that the ModelForm is manipulating. If you specify both the fields and form_class attributes, an ImproperlyConfigured exception will be raised. Mixins  django.views.generic.edit.FormMixin django.views.generic.detail.SingleObjectMixin  Methods and Attributes  
model  
A model class. Can be explicitly provided, otherwise will be determined by examining self.object or queryset. 
  
fields  
A list of names of fields. This is interpreted the same way as the Meta.fields attribute of ModelForm. This is a required attribute if you are generating the form class automatically (e.g. using model). Omitting this attribute will result in an ImproperlyConfigured exception. 
  
success_url  
The URL to redirect to when the form is successfully processed. success_url may contain dictionary string formatting, which will be interpolated against the object’s field attributes. For example, you could use success_url="/polls/{slug}/" to redirect to a URL composed out of the slug field on a model. 
  
get_form_class()  
Retrieve the form class to instantiate. If form_class is provided, that class will be used. Otherwise, a ModelForm will be instantiated using the model associated with the queryset, or with the model, depending on which attribute is provided. 
  
get_form_kwargs()  
Add the current instance (self.object) to the standard get_form_kwargs(). 
  
get_success_url()  
Determine the URL to redirect to when the form is successfully validated. Returns django.views.generic.edit.ModelFormMixin.success_url if it is provided; otherwise, attempts to use the get_absolute_url() of the object. 
  
form_valid(form)  
Saves the form instance, sets the current object for the view, and redirects to get_success_url(). 
  
form_invalid(form)  
Renders a response, providing the invalid form as context.
fields  
A list of names of fields. This is interpreted the same way as the Meta.fields attribute of ModelForm. This is a required attribute if you are generating the form class automatically (e.g. using model). Omitting this attribute will result in an ImproperlyConfigured exception.