Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Uploading django app to digitalocean server, cannot upgrade django, resulting in 502 bad gateway
When I try to upgrade django on my digital ocean server using: pip install --upgrade django I get the following error: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-HzJGUP/django/ I tried to use Python 3.5 instead of 2, however I get the same error. -
passing args and kwargs to parent class with extra content in django CreateView
I've made a django form in which I want to pass some context I need to display (mainly database entries in tags so the user can choose from them). I therefor made a get_context_data function where I add the context to the existing context like this: def get_context_data(self, **kwargs): context = super(UploadView, self).get_context_data(**kwargs) context['categories'] = Category.objects.all() context['form'] = VideoForm return context however the form is not saving the information passed to the database. Why would that not work? Here is part of my code! forms.py: class VideoForm(forms.ModelForm): category = forms.ModelChoiceField(queryset=Category.objects.all(), empty_label=None) class Meta: model = Video fields = [ 'title', 'description', 'description_short', 'category', 'time', 'thumbnail', 'type', ] def clean_thumbnail(self): picture = self.cleaned_data.get("thumbnail") if not picture: raise forms.ValidationError("No Image") else: w, h = get_image_dimensions(picture) if w/h != (16/9): raise forms.ValidationError("Image in wrong aspect ratio (should be 16:9)") return picture upload.html (it's pretty long so it's better to upload it to pastebin) views.py: class UploadView(LoginRequiredMixin, CreateView): form_class = VideoForm template_name= 'upload.html' def form_valid(self, form): instance = form.save(commit=False) instance.uploader=self.request.user return super(UploadView, self).form_valid(form) def get_context_data(self, **kwargs): context = super(UploadView, self).get_context_data(**kwargs) context['categories'] = Category.objects.all() context['form'] = VideoForm return context I'm using a custom form so I can set classes which I use for editing the … -
Nothing is shown in a tag
Nothing is shown in a tag. I wrote in views.py def top(request): content = POST.objects.order_by('-created_at')[:5] category_content = Category.objects.order_by('-created_at')[:5] return render(request, 'top.html',{'content':content,'category_content':category_content}) in models.py class Category(models.Model): name = models.CharField(max_length=100) created_at = models.DateTimeField(auto_now_add=True) def __str__(self): return self.name in top.html <ul class="list-group"> <li class="list-group-item active text-center">category</li> <div class="collapse"> {% for category in category_content %} <a href="" class="list-group-item"> {{ category.name }} </a> {% endfor %} </div> </ul> Now output is like so category.name is not shown.My ideal output is I really cannot understand why category.name is not shown.I print out print(category_content) in views.py's top method,so , ]> is shown.How should I fix this?What is wrong in my codes? -
Page not found: http://127.0.0.1:8000/sitemap.xml/
Here are the codes to create the sitemap for one of my app 'blog' in my site: settings.py INSTALLED_APPS += [ 'django.contrib.sites', 'django.contrib.sitemaps', ] TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] urls.py from django.urls import include, path from django.contrib.sitemaps.views import sitemap from blog.sitemaps import PostSiteMap sitemaps = {'posts': PostSiteMap} urlpatterns += [ path('sitemap.xml', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap') ] sitempas.py (under 'blog' app directory) from django.contrib.sitemaps import Sitemap from .models import Post class PostSiteMap(Sitemap): changefreq = 'weekly' priority = 0.5 def items(self): return Post.published.all() def lastmod(self, obj): return obj.publish The sitemap.xml doesn't appear: http://127.0.0.1:8000/sitemap.xml/ There is the url (the eighth) matching my inputted one. Why it says 'not match'? -
{{ user }} not working in my template in Django
Here is my template : {% load static %} <div class="header clearfix"> <nav> <ul class="nav nav-pills nav-fill float-right "> {% for button in buttons %} {{ user.id }} {{ request.user.id }} {% endfor %} </ul> </nav> </div> And here is my template tag : from django import template from menu.models import Button register = template.Library() @register.inclusion_tag('menu/home.html', takes_context=True) def show_menu(context): request = context.get('request') if request.user.is_authenticated: buttons = Button.objects.filter(button_noco = False) return {'buttons': buttons} In my template tag, request.user.is_authenticated is working fine. The problem is that in my template, I can't display user.id, request.user.id or anything like to the user (like request.user.is_authenticated for example). Why ? -
PostgreSql/Django/OAuth can't adapt type 'OAuth2Credentials'
I was setting up Oauth2 Web Server Flow and have come accross a problem. What I have done till now , 1) Initialized the Oauth WebServerFlow 2) Retrieved and redirected the user to the url for Google's OAuth2 server 3) The user gives me the necessary permissions. 4) Received the authorization code to get the oauth credentials. 5) Now I use the authorization code and using the webserver flow I retrieve the credentials. Now , the credentials returned are of type OAuth2Credentials. when I attempt to insert the credentials into my DB I get the following error I know that this error is due to datatype mismatch. So can anyone tell me , what datatype should my postgreSql column be to accept a value of this datatype. I looked up on this but couldnt find anything Any help is appreciated! Ask me if you want any further details. -
developing a reminder app in django project
Basically, what i am trying to create is a reminder app that creates a notification when the user's driving license gets expired. The remainder should arrive at 30 days before the date of expiry so that user can take appropriate action. Please tell me how i can implement this task. Do i have to use celery or can it be done without celery. My best catch is if not using celery, a custom middleware can trigger the function that calculates the expiry date. But it;s not likely to be a best solution. Please suggest me some solutions. -
How can i do to get good queryset with manytomany field
That's my models: class Mission(models.Model): id = models.CharField( _('Mission Reference'), max_length=14, primary_key=True, blank=True)) domain = models.ForeignKey(sector.Domain) thematic = ChainedForeignKey( sector.Thematic, chained_field="domain", chained_model_field="domain", show_all=False, sort=True, ) activity = ChainedForeignKey( sector.Activity, chained_field="thematic", chained_model_field="thematic", show_all=False, sort=True, ) author = models.ForeignKey(Profile) miss_description = models.TextField( _('Desc'),) miss_address = models.CharField( _('Address'), max_length=200, blank=True, ) location = LocationField( based_fields=['miss_address'], zoom=8, default=Point(1.0, 1.0),) objects = models.GeoManager() class Subscriber(models.Model): profile = models.OneToOneField(membre.Profile) susb_bio = models.TextField( _('Bio'),) susb_comp = models.ManyToManyField(sector.Activity) Subscriber have many activities. Now my question is how can i construct my queryset if i want to get all missions according to Suscriber activity ? e.g: Suppose i have Mr smith Subscriber and he have 3 activity choosen now i have 300 missions and i want all missions have this 3 activities for Mr smith Subscriber. -
Passing variables to a Django template extended by several views
I have a Django template base.html that I extend in several views. Each view adds a content block and provides the information needed to render that block. Now I want to change base.html to show some system status information. Does this mean I need to update every single view to request this info from the DB and pass it into the template, or is there some better way to do it? base.html <body> <div> {{ system.status }} </div> <div> {% block content %} {% endblock %} </div> </body> view1.html, view2.html, view3.html, etc. {% extends 'base.html' %} {% block content %} <div> {{ view_specific.info }} </div> {% endblock %} Should every view be made to provide the system object? -
SSH Connect to AWS EC2 failed after using lets-encrypt update my website
Yesterday, I updated my Django website (on AWS EC2) to HTTPS by using lets-encrypt. Everything works well. The website has HTTPS green icon as expected. Today when I try to connect my instance by using SSH. The connection failed. It give some message like "ssh: Could not resolve hostname blog_project.pem: Name or service not known". I thought it might be security group problem of this instance. So I double checked my security group setting of this instance, the SSH, HTTP and HTTPS port are all open correctly. I created another instance to test if there is any problem on my local. The new instance connected successfully. Now I am really confused. My local machine is Windows subsystem of Linux. My EC2 instance is Ubuntu 16. I am using Nginx as web server. My ssh "command is ssh -i blog_project.pem root@ec2-34-202-93-189.compute-1.amazonaws.com" Thank you for the help. -
Filter foo_set in django-mptt
Existing 3 models: class Category(MPTTModel): title = models.CharField(_("Title"), max_length=128) parent = TreeForeignKey('self', null=True, blank=True, related_name='children', db_index=True) class Contract(models.Model): category = models.ManyToManyField(Category, verbose_name=_("Category")) class Task(models.Model): category = models.ForeignKey(Category, verbose_name=_("Category"), blank=True, null=True) contract = models.ForeignKey(Contract, verbose_name=_("Contract")) I want to get via mptt dicts with foo_set model: [ if has parent category here will be wrapper dict, and level above, etc. { "id": 15, "name": "title", "children": { "task": [{"id": 6}, {"id": 7}], "id": 14, "name": "and title" }, } { "id": 10, "name": "title", "children": { "task": [{"id": 2}, {"id": 3}, {"id": 4}], "id": 16, "name": "any title" }, } ... ] or simple [ category 1.1, category 2.1, category 2.2, category 3.1, category.foo_set.filter(any) [1,2,3...] ... category 2.3, category 1.2 ] And i want to get different filter with different data. One data by contract, second by category via IF. def view(request): contract = request.GET.get('contract', None) category = request.GET.get('category', None) if contract: obj = get_object_or_404(Contract, id=contract) category_ids = [n.category_id for n in obj.task_set.filter(contract=obj.id).select_related('contract')] nodes = Category.objects.filter(id__in=[n.id for n in obj.category.all()]).prefetch_related('task_set') if category: obj = get_object_or_404(Category, id=category) nodes = obj.get_descendants().prefetch_related('task_set') def recursive_node_to_dict(node): result = { 'id': node.pk, 'name': node.title, 'task': [] } if for c in node.get_descendants(): result['children'] = recursive_node_to_dict(c) if contract: result['task'] … -
Getting a private chat-room based on either one of two users
I understand I need to add users into a specific Group to allow the users within that group to message each other, but I can't wrap my head around more dynamic access. For example, if I'm trying to hold a private chat room with the two allowed users into the chat-room to be predetermined, allowing access to nobody else, how would I do this within the consumer(or helper function)? I have this (project specific) model that designates two users of a "Pair": class Pair(models.Model): requester = models.ForeignKey(Profile, related_name='is_requester') accepter = models.ForeignKey(Profile, related_name='is_accepter') And the models for a chat Room and the Message: class Room(models.Model): pair = models.ForeignKey(Pair, related_name='pair_to') date_started = models.DateTimeField(auto_now_add=True) title = models.CharField(max_length=255) @property def websocket_group(self): """ Returns the Channels Group that sockets should subscribe to to get sent messages as they are generated. """ return Group("room-%s" % self.id) # def send_message(self, message, user, msg_type=MSG_TYPE_MESSAGE): # """ # Called to send a message to the room on behalf of a user. # """ # final_msg = {'room': str(self.id), 'message': message, 'username': user.username, 'msg_type': msg_type} # # Send out the message to everyone in the room # self.websocket_group.send( # {"text": json.dumps(final_msg)} # ) class Message(models.Model): chat = models.ForeignKey(Chat) sender = … -
Page not found when linking to a PDF in Django
How do I link to a pdf file in Django? I get an error message when I try and link to a PDF in a Django project. I'm not sure if its a problem with the code or if the virtual environment has to be configured to display pdf's. Error message Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/writing/static/writing/CatsSongbook.pdf Using the URLconf defined in myproject.urls, Django tried these URL patterns, in this order: ^admin/ ^ ^$ [name='index'] ^ ^contact/ [name='contact'] ^blog/ ^writing/ ^$ [name='writing'] ^writing/ ^$ [name='book1'] The current path, writing/static/writing/CatsSongbook.pdf, didn't match any of these. writing urls.py from django.conf.urls import url, include from django.contrib import admin from . import views urlpatterns = [ url(r'^$', views.writing, name='writing'), url(r'^$', views.book1, name='book1'), ] Urls.py from django.shortcuts import render def writing(request): return render(request, 'writing/writing.html') def book1(request): return HttpResponse(pdf, '.static/writing/pdf/CatsSongbook.pdf') Link in writing template. <a href="./static/writing/CatsSongbook.pdf" target="_top">book1</a> -
Failed to install pandas 0.22 version with pip
Tried to install pandas 0.22 to pythonanywhere and other linux server but failed. My command used: pip install pandas==0.22 pip install pandas Error Message: Running setup.py bdist_wheel for pandas ... -^error Failed building wheel for pandas We installed requirements.txt. Only pandas fail and other success. Django==2.0 django-chartjs==1.2 mysqlclient==1.3.12 Cython numpy==1.13.3 python-dateutil==2.6.1 pytz==2017.3 six==1.11.0 xlrd==1.1.0 gunicorn==19.7.1 dj-database-url whitenoise pandas==0.22.0 So any solution to install pandas? Don't wanna use conda due to limited environment. -
Django URL pattern for an unusual address
Which regular expression do I write in my URLs to give me this 'host:8000/"?page=1" ' in my browser address -
django queryset group by field
i have a listview and want to group by based on foreign key id views.py class SelectListView(ListView): model=MyModel template_name = "/select_list.html" context_object_name = 'selectlist' queryset = MyModel.objects.all().values('ItemType_id') paginate_by = 10 def get_context_data(self, **kwargs): context = super(SelectListView, self).get_context_data(**kwargs) context['range'] = range(context["paginator"].num_pages) return context models.py class ItemType(models.Model): ItemType=models.CharField(unique=True,max_length=40) class MyModel(models.Model): Type=models.ForeignKey(ItemType) ItemName=models.CharField(unique=True,max_length=40) Question: I would like to group by the queryset by ItemType_id in the MyModel Expectation: select * from MyModel group by ItemType_id -
ValueError at /app/recomment/1/
I got an error,ValueError at /app/recomment/1/ Cannot assign "": "ReComment.target" must be a "POST" instance.The error is happened when I put Recomment button.I wanna make a page which is shown comment&recomment.I wrote codes in views.py class DetailView(generic.DetailView): model = POST template_name = 'detail.html' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['comment_form'] = CommentCreateForm() context['recomment_form'] = ReCommentCreateForm() return context class CommentCreateView(generic.View): def post(self, request, *args, **kwargs): form = CommentCreateForm(request.POST) post = POST.objects.get(pk=kwargs['post_pk']) if form.is_valid(): obj = form.save(commit=False) obj.target = post obj.save() return redirect('detail', pk=post.pk) class ReCommentCreateView(generic.View): def post(self, request, *args, **kwargs): form = ReCommentCreateForm(request.POST) comment = Comment.objects.get(pk=kwargs['comment_pk']) if form.is_valid(): obj = form.save(commit=False) obj.target = comment obj.save() return redirect('detail', pk=comment.target.pk) def recomment(self, form): comment_pk = self.kwargs['pk'] comment = Comment.objects.get(pk=comment_pk) self.object = form.save(commit=False) self.object.target = comment self.object.save() return redirect('detail', pk=comment.target.pk) in urls.py from django.urls import path from django.conf import settings from . import views urlpatterns = [ path('detail/<int:pk>/', views.DetailView.as_view(), name='detail'), path('comment/<int:post_pk>/',views.CommentCreateView.as_view(), name='comment'), path('recomment/<int:comment_pk>/', views.ReCommentCreateView.as_view(), name='recomment'), ] in detail.html {% load static %} <html lang="en"> <head> <meta charset="UTF-8"> <title>DETAIL</title> </head> <body> <div id="comment-area"> {% for comment in post.comment_set.all %} <div class="media m-3"> <div class="media-body"> <h5 class="mt-0"> <span class="badge badge-primary badge-pill">{% by_the_time comment.created_at %}</span> {{ comment.name }} <span class="lead text-muted">{{ comment.created_at }}</span> <a href="{% url 'recomment' … -
is any way to use a 32bit anaconda in anaconda 64bit ver without download it
Could you get me some help? My os is window7 64bit I already downloaded anaconda 64bit to develope some web project with django. And sure I've runned other practices in here by myself. While using anaconda in this enviroment I wanna try an stock firm api with anaconda, but the matter is it only supplys for 32bit anaconda. Should I have to download 32 ver again, using a 64bit anaconda though? if there's way to use anaconda 32bit ver in 64 bit anaconda? Could you teach me how to do that? Please tell me if somebody knows. -
Update the instance after save, using signals by conditionally refference back to the instance in some cases
I have the following abstract class: class UserStamp(models.Model): created_by = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, related_name='%(app_label)s_%(class)s_created_by', on_delete=models.CASCADE) updated_by = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True, related_name='%(app_label)s_%(class)s_updated_by', on_delete=models.CASCADE) class Meta: abstract = True I have a custom User that inherits from User. class User(AbstractBaseUser,PermissionsMixin, UserStamp): account = models.ForeignKey(Account, blank=True, null=True, related_name='owner',on_delete=models.CASCADE) The User can create/update himself or by other user. When the user create/update himself I don't have anything for created_by, update_by. I thought on using a post_save signal, get the instance and update/those value, but I don't know in a post_save signal when is create or update. The post_save signal I don't need it if is create by another user, can be called conditional ? In a form that I create I can check if is created/updated by other user in the View, but that is not the case for Django Admin. -
Django 2.0 - YearArchiveView doesn't return all dates
Using the examples of the official documentation on YearArchiveView, I can't retrieve all dates from <ul> {% for date in date_list %} <li>{{ date|date }}</li> {% endfor %} this code. It only returns me the first date. I'm sure I have at least four more dates in my database because the following part <div> <h1>All Articles for {{ year|date:"Y" }}</h1> {% for obj in object_list %} <p> {{ obj.title }} - {{ obj.pub_date|date:"F j, Y" }} </p> {% endfor %} </div> returns me all the objects I have. My views.py file is like this: ... class ChatYearArchiveView(YearArchiveView): queryset = Chat.objects.all() date_field = "created_at" make_object_list = True allow_future = True Note: In my models.py, I made "created_at" as a DateTimeField(), not DateField() as the example said. Is this the problem? If so how should I change the code? -
Where to import stuff for a template in Django?
Sorry for the dumb question, I'm lost. I got a template and a templatetags with this : menu_tags.py from django import template from menu.models import Button register = template.Library() @register.inclusion_tag('menu/home.html') def show_menu(): buttons = Button.objects.all() return {'buttons': buttons} And this : home.html {% for button in buttons %} {% if user.is_authenticated %} stuff {% endif %} {% endfor %} I would like to know, how can I make user.is_authenticated work ? I know I have to import something, but where ? Importing it in menu_tags does not seems to work. Thanks ! -
Transfering a Digital ocean droplet to bluehost website
My name is omar. I have a django project that i created on my local machine. I created a docker image and container for my project and then ran the container that was created in my digital ocean droplet. I now want to have my website that I own to host the digital ocean droplet that was created. I have looked around but couldnt really find anything that helped me out in getting it running. I also had a few question that I couldnt find the answers to and was wondering if there was anyone that can help me out in any way find a solution or advice. How can i get my website to host the droplet that I created? When going from local machine to digital ocean droplet, does the database transfer over or is a new database created in the digital ocean droplet? If I have a live container and while it is live, information is stored in the database that is creates, and I update the container with a newer image with newer code, does the content from the original database go away and a new one is created, or is the database in a container … -
Nothing is happened when I put comment button
Nothing is happened when I put comment button.I wanna make a page which is shown comment&recomment.I wrote codes in views.py class DetailView(generic.DetailView): model = POST template_name = 'detail.html' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['comment_form'] = CommentCreateForm() context['recomment_form'] = ReCommentCreateForm() return context class CommentCreateView(generic.View): def post(self, request, *args, **kwargs): form = CommentCreateForm(request.POST) post = POST.objects.get(pk=kwargs['post_pk']) if form.is_valid(): obj = form.save(commit=False) obj.target = post obj.save() return redirect('detail', pk=post.pk) class ReCommentCreateView(generic.View): def post(self, request, *args, **kwargs): form = ReCommentCreateForm(request.POST) comment = Comment.objects.get(pk=kwargs['comment_pk']) if form.is_valid(): obj = form.save(commit=False) obj.target = comment obj.save() return redirect('detail', pk=comment.target.pk) in urls.py from django.urls import path from django.conf import settings from . import views urlpatterns = [ path('detail/<int:pk>/', views.DetailView.as_view(), name='detail'), path('comment/<int:post_pk>/',views.CommentCreateView.as_view(), name='comment'), path('recomment/<int:comment_pk>/', views.ReCommentCreateView.as_view(), name='recomment'), ] in detail.html {% load static %} <html lang="en"> <head> <meta charset="UTF-8"> <title>DETAIL</title> </head> <body> <div id="comment-area"> {% for comment in post.comment.all %} <div class="media m-3"> <div class="media-body"> <h5 class="mt-0"> <span class="badge badge-primary badge-pill">{% by_the_time comment.created_at %}</span> {{ comment.name }} <span class="lead text-muted">{{ comment.created_at }}</span> <a href="{% url 'recomment' comment.pk %}">Recomment</a> </h5> {{ comment.text | linebreaksbr }} {% for recomment in comment.recomment.all %} <div class="media m-3"> <div class="media-body"> <h5 class="mt-0"> {{ recomment.name }} <span class="lead text-muted">{{ recomment.created_at }}</span> </h5> {{ recomment.text | linebreaksbr … -
How to setup django on apache
I've been trying to run django on apache but I keep on getting 504 Gateway Timeout. Here is the site conf. I've placed it in /etc/apache2/sites-available/ directory. <VirtualHost *:80> ServerName orounds.localhost DocumentRoot /var/www/html/orounds_pro WSGIScriptAlias / /var/www/html/orounds_pro/orounds_pro/wsgi.py WSGIDaemonProcess orounds processes=2 threads=15 display-name=%{GROUP} python-home=/var/www/html/orounds_pro/venv/bin/python3 WSGIProcessGroup orounds <directory /var/www/html/orounds_pro> AllowOverride all Require all granted Options FollowSymlinks </directory> Alias /static/ /var/www/html/orounds_pro/static/ <Directory /var/www/html/orounds_pro/static> Require all granted </Directory> </VirtualHost> I'm using python3.6 and apache 2.4.29. I installed mod_wsgi for apache with sudo apt-get install libapache2-mod-wsgi-py3. Is there anything I'm doing wrong or is there anything else I should do? Regards. -
OperationalError at /app/comment/3/
I got an error,OperationalError at /app/comment/3/ table app_comment has no column named created_at.I wrote codes in views.py class DetailView(generic.DetailView): model = POST template_name = 'detail.html' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['comment_form'] = CommentCreateForm() context['recomment_form'] = ReCommentCreateForm() return context class CommentCreateView(generic.View): def post(self, request, *args, **kwargs): form = CommentCreateForm(request.POST) post = POST.objects.get(pk=kwargs['post_pk']) if form.is_valid(): obj = form.save(commit=False) obj.target = post obj.save() return redirect('detail', pk=post.pk) class ReCommentCreateView(generic.View): def post(self, request, *args, **kwargs): form = ReCommentCreateForm(request.POST) comment = Comment.objects.get(pk=kwargs['comment_pk']) if form.is_valid(): obj = form.save(commit=False) obj.target = comment obj.save() return redirect('detail', pk=comment.target.pk) in urls.py from django.urls import path from django.conf import settings from . import views urlpatterns = [ path('detail/<int:pk>/', views.DetailView.as_view(), name='detail'), path('comment/<int:post_pk>/',views.CommentCreateView.as_view(), name='comment'), path('recomment/<int:comment_pk>/', views.ReCommentCreateView.as_view(), name='recomment'), ] in detail.html {% load static %} <html lang="en"> <head> <meta charset="UTF-8"> <title>DETAIL</title> </head> <body> <form action="{% url 'comment' post_pk=post.id %}" method="post"> {{comment_form}} {% csrf_token %} <input class="btn btn-primary" type="submit" value="comment"> </form> </body> </html> in models.py class Comment(models.Model): name = models.CharField(max_length=100, blank=True) text = models.TextField() target = models.ForeignKey(POST, on_delete=models.CASCADE) created_at = models.DateTimeField(auto_now_add=True) def __str__(self): return self.name When I put comment button, the error happens.I wrote created_at in Comment model, so I really cannot understand why this error happens.I designated detail.html in DetailView's class so I cannot …