django

I'm getting a NoReverseMatch error in my home page

◇◆丶佛笑我妖孽 提交于 2021-02-11 16:55:49
问题 I'm getting a NoReverseMatch error in my home page. It is from the html that I injected from my announcement app. It says that the reverse of the link is cannot be found. When I removed that line It shows the card but the text with template tag. _announcement_home.html : <div class="container"> <div class="card announcement-card" style="width: 18rem;"> <h5 class="card-header">Announcement</h5> <div class="card-body"> <h5 class="card-title">{{announcement.title}}</h5> <p class="card-text">{

I'm getting a NoReverseMatch error in my home page

末鹿安然 提交于 2021-02-11 16:54:25
问题 I'm getting a NoReverseMatch error in my home page. It is from the html that I injected from my announcement app. It says that the reverse of the link is cannot be found. When I removed that line It shows the card but the text with template tag. _announcement_home.html : <div class="container"> <div class="card announcement-card" style="width: 18rem;"> <h5 class="card-header">Announcement</h5> <div class="card-body"> <h5 class="card-title">{{announcement.title}}</h5> <p class="card-text">{

Django Aggregate Query Include Zero Count

末鹿安然 提交于 2021-02-11 16:11:27
问题 In my Django application, I'm trying to get a Count of all Student submitted Paper s, including students who have submitted NO papers (represented as count=0). models.py class Student(models.Model): idstudent = models.AutoField(primary_key=True) student_name = models.CharField(max_length=250, null=False, blank=False, verbose_name='Student Name') class Paper(models.Model): idpaper = models.AutoField(primary_key=True) student = models.ForeignKey(Student, on_delete=models.PROTECT, null=False,

Django 3.0: Reverse for 'product' with no arguments not found. 1 pattern(s) tried: ['product/(?P<slug>[^/]+)/$']

痞子三分冷 提交于 2021-02-11 16:01:47
问题 I have model named Book in models.py file. And this model has slug field to display details of books Books are being displayed in home.html template and product.html template is to display details of selected book. I really don't know much about slugs, and how they work. Models.py: class Book(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) title = models.CharField('Title', max_length=255) authors = models.ManyToManyField(Author, related_name='books

Creating a PostgreSQL database backup via psql on macOS

白昼怎懂夜的黑 提交于 2021-02-11 16:00:36
问题 I'm trying to create a PostgreSQL local db dump via Terminal on macOS using psql . My next step is to upload/import my entire db to my Amazon RDS PostgreSQL db instance. Can anyone help me with the Terminal command to create a dump file 'mydbdump.sql' for my 'mydb' database. I've sorted through existing questions, searched forums (tried similar Stack Overflow question), even Amazon RDS docs (above, link), and am having no luck with the commands from any of these docs. What am I doing wrong?

Django 3.0: Reverse for 'product' with no arguments not found. 1 pattern(s) tried: ['product/(?P<slug>[^/]+)/$']

亡梦爱人 提交于 2021-02-11 15:59:40
问题 I have model named Book in models.py file. And this model has slug field to display details of books Books are being displayed in home.html template and product.html template is to display details of selected book. I really don't know much about slugs, and how they work. Models.py: class Book(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) title = models.CharField('Title', max_length=255) authors = models.ManyToManyField(Author, related_name='books

Found elements with non-unique id

南笙酒味 提交于 2021-02-11 15:58:55
问题 I have 3 posts on homepage and each have a comment form, I am using one form for all posts. I am using jQuery to disabled submit button if there are no text in input and also enable submit button if there is text in input. The problem is that each post submit button have same ID, how do i make button a unique id for each post ID? <span class="md-form"> <form enctype="multipart/form-data" class="feeds-form form-inline md-form form-sm" method="POST" action="{% url 'site:home' %}"> {% csrf_token

Found elements with non-unique id

喜欢而已 提交于 2021-02-11 15:58:05
问题 I have 3 posts on homepage and each have a comment form, I am using one form for all posts. I am using jQuery to disabled submit button if there are no text in input and also enable submit button if there is text in input. The problem is that each post submit button have same ID, how do i make button a unique id for each post ID? <span class="md-form"> <form enctype="multipart/form-data" class="feeds-form form-inline md-form form-sm" method="POST" action="{% url 'site:home' %}"> {% csrf_token

How to get count of friends of friends

家住魔仙堡 提交于 2021-02-11 15:54:55
问题 i am building a website like instagram where users can follow friends, i have been able to implement follow friend and also displaying friends of friends (mutual friend). I was not able to get the count of friends of friends; this is what i tried: Model: class Profile(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL,on_delete=models.CASCADE,blank=True,null=True) friends = models.ManyToManyField('Profile', related_name="my_friends",blank=True) view: @login_required def

how can I convert an incorrectly-saved bytes object back to bytes? (python/django)

你。 提交于 2021-02-11 15:49:57
问题 I've downloaded some web pages with requests and saved the content in a postgres database [in a text field] using Django's ORM. For some sudocode of what's going on, here ya go: art = Article() page = requests.get("http://example.com") art.raw_html = page.content art.save() I verified that page.content is a bytes object, and I guess I assumed that this object would automatically be decoded upon saving, but it doesn't seem to be... it has been converted to some weird string representation of a