zhannamatuzak / lizard-my-pet

CI PP4
1 stars 1 forks source link

USER STORY: View a Single Post #12

Open zhannamatuzak opened 10 months ago

zhannamatuzak commented 10 months ago

A s USER, I would like to view a single post with well-readable and structured information by clicking on the blog post.


ECCEPTANCE CRITERIA:

✅When I click on a blog post, I should be directed to a dedicated page showing the full well-readable and structured content of that specific blog post.

zhannamatuzak commented 10 months ago

I faced the issue where 'crispy_forms_tags' is not a registered tag library. The problem is that the Crispy Forms tags are not being recognized in your Django template.

Steps to resolve the issue:

  1. Install Crispy Forms: Install it using the following command:
pip install django-crispy-forms
  1. Add 'crispy_forms' to INSTALLED_APPS: In settings.py file, ensure that 'crispy_forms' is added to the INSTALLED_APPS setting:
INSTALLED_APPS = [
    # ...
    'crispy_forms',
    # ...
]

Image

zhannamatuzak commented 10 months ago

Issue: Unclosed tag on line 6: 'block'. Looking for one of:

{% endblock %}

Image

Image

zhannamatuzak commented 10 months ago

Issue: I have got the integer value:

DIET = ((0, "Not defined"), (1, "Omnivorous"), (2, "Herbivorous"), (3, "Insectivorous"))

BUT I need a string value.


SOLUTION:

DIET = [
        ("0", "Not defined"),
        ("1", "Omnivorous"),
        ("2", "Herbivorous"),
        ("3", "Insectivorous"),
    ]

Image

Image

zhannamatuzak commented 10 months ago

Then I had to change the "diet" variable field from Integer to CharField:

BEFORE:

diet = models.IntegerField(choices=DIET, default=0)

AFTER:

    diet = models.CharField(max_length=25, choices=DIET, default="0")

Image

zhannamatuzak commented 10 months ago

And I had to make changes in HTML file to display the human-readable labels:

 <p>Feeding habits: {{ lizard.get_diet_display }} </p>

Image

zhannamatuzak commented 10 months ago

Image

zhannamatuzak commented 9 months ago

Image