[Answer]-Contact Form in django

1đź‘Ť

There is short and better way of doing this,

class Subject(models.Model):
        question_  = 0
        question_one = 1
        question_two = 2
        question__three = 3

    STATUS_CHOICES = (
        (question_, ''),
        (question_one, 'I have a question'),
        (question_two, 'Help/Support'),
        (question__three, 'Please give me a call'),
        )

You don’t need new class, just this, where you see 0,1,2,3 is what will recognise each choice, you can put anything in the first section, e.g. 0,1,2,3, or “IHAQ” short for “I have a question”

STATUS_CHOICES = (
        ("0", ""),
        ("1", "I have a question"),
        ("2", "Help/Support"),
        ("3", "Please give me a call"),
        )
👤nope

0đź‘Ť

There may be an issue with this part:

recipient_list=[settings.LIST_OF_EMAIL_RECIPIENTS],

If settings.LIST_OF_EMAIL_RECIPIENTS is already a list, then you are nesting it in another list.

Anyway, as a general rule, when something doesn’t work, you should step through the code in your debugger or put print statements to see what is happening when the code runs. That will make the process much easier for you.

👤RexE

Leave a comment