Looks like the lines in your code, from # forms onwards need to be
outdented (so the "class" statements are at matching levels).
On Monday, 11 July 2016 08:34:44 UTC+2, Ikram Ulhaq wrote:
>
> hi everyone!
> i am new in django web development.i want to insert data into my database
> using following code but i got error like this.
> model = Incident
> NameError: name 'Incident' is not defined
>
> please help.
>
>
>
>
> my code is below
> class Incident(models.Model):
> subject = models.CharField(max_length=256)
> severity = models.IntegerField(choices=SEVERITY)
> status = models.CharField(max_length=20, choices=STATUS,
> default=_("Open"))
> detection = models.IntegerField(choices=DETECTION, default='1')
> plan = models.IntegerField(choices=PLAN, default='1')
> confidentiality = models.IntegerField(choices=CONFIDENTIALITY,
> default='1')
> date = models.DateTimeField(default=datetime.datetime.now, blank=True)
> is_starred = models.BooleanField(default=False)
> description = models.TextField()
> def get_absolute_url(self):
> return receiver('incident:detail',kwargs={'pk':self.pk})
>
> def __unicode__(self):
> return self.subject
>
>
> # forms ===============================================================
>
>
> class IncidentForm(ModelForm):
>
> def __init__(self, *args, **kwargs):
> super(ModelForm, self).__init__(*args, **kwargs)
> self.fields['subject'].error_messages['required'] = 'This field
> is required.'
> self.fields['category'].error_messages['required'] = 'This field
> is required.'
>
> self.fields['concerned_business_lines'].error_messages['required'] = 'This
> field is required.'
> self.fields['detection'].error_messages['required'] = 'This field
> is required.'
>
> self.fields['severity'].error_messages['required'] = 'This field
> is required.'
> self.fields['is_major'].error_messages['required'] = 'This field
> is required.'
>
> self.fields['is_major'].label = 'Major?'
>
> class Meta:
> model = Incident
>
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/825414fe-35d0-4084-abef-934a5195cd0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.