I’m curious, why do you think we should rewrite or copy/paste the documentation when the specific answer to a question is in that documentation?
You asked the question:
The documentation linked to so kindly by @marcorichetta answers your question. If you’re having a specific problem with something in that document, you can always ask for clarification here. But yes, the expectation is that you will do your part and read it first.
In your particular case, your comment is factually incorrect considering the following:
and if not, from security perspective what should I do - besides disabling the debug mode - when development is finished?
Hi,
I prefer to learn things by example.
Here’s my current view to retrieve a single post:
def post_detail(request, year, month, day, post):
post = get_object_or_404(Post, slug=post, status='published', publish__year=year, publish__month=month,
publish__day=day)
return render(request, 'blog/post/detail.html', {'post': post})
How to convert it to class-based?
Hello,
I have a simple “newsletter” signup form. It is defined as below:
The model is created like this:
class Subscriber(models.Model):
email = models.EmailField(max_length=254)
def __str__(self):
return self.email
This is the form to subscribe:
<form action="" id="newsletterForm" method="post" role="form">
{% csrf_token %}
<input type="email" name="email" required><input type="submit" value="Subscribe">
…
Hello,
I’m writing a Blog app with the help of a book.
I have this in my urls.py:
path('<int:year>/<int:month>/<int:day><slug:post>/', views.post_detail, name='post_detail'),
and in the models.py this function generates the link to each blog post:
def get_absolute_url(self):
return reverse('blog:post_detail', args=[self.publish.year, self.publish.month, self.publish.day, self.slug])
However, the link is generated like “2020/12/9slug” not “2020/12/9/slug”.
As far as I know, the reverse …
Hello,
In many tutorials they talk about PROJECT_PATH, but I don’t have it in my settings.py, neither I can find it in the official documentation. Is this depreciated? If not, how it should be defined?
Hello,
I need to have just one base.html template shared between all apps. What I’m thinking now is to have a “templates” folder under project, and put the base.html inside that.
For each app I’ll follow the standard method (appname/templates/appname).
But I don’t know how to put that into work.
Hello,
I am following this tutorial
After switching to generic views, I receive NoReverseMatch
The error message: Reverse for ‘vote’ with arguments ‘(1,)’ not found. 1 pattern(s) tried: [‘polls/<int:question_id/vote/$’]
And the error line is 5.
<h1>{{ question.question_text }}</h1>
2
3 {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
4
5 <form action="{% url 'polls:vote' question.id %}" method=post>
6 {% csrf_token %}
7 {% for choice in question.choice_set.all …
2 Likes