How to get an entry in Django's database via a field ?

Hi everyone !

I’m currently learning Django and how to play with the Django’s API for managing SQL entries.

Thus, I don’t know how to get a SQL entry via its name.

Indeed, in the following example, I create a “Forum” model :

class Forum(models.Model):
    forum_name = models.CharField(max_length=20)
    forum_description = models.CharField(max_length=100)

This model has two fields, forum_name and forum_description.

I’ve successfully created Forum objects/entries inside my app through the shell but, how can I make a SQL query via the “forum_name” attribute like

"SELECT the entry FROM TABLE “Forum” that has the FIELD “forum_name” equals to “something” " ?

I’ve tried :


But the shell won’t accept this query…

How can I fix this issue ?

Thank you in advance for your help

Your basic syntax is right.
You say “But the shell won’t accept this query…” Why not?
Can you please copy/paste the complete error message you’re getting when you try this?

Did you run from myproject.models import Forum first?

Hi guys ! Thanks for your answers !

I fgured it out, it was a case sensitive issue :

The solution was to use :