Git Product home page Git Product logo

Comments (13)

Tyrdall avatar Tyrdall commented on July 17, 2024 1

@MAkcanca The object_id argument is empty. Add the ID or PK of the object to be reviewed.

from django-review.

Tyrdall avatar Tyrdall commented on July 17, 2024 1

@MAkcanca The content_typeshould really exist (the object ID also).

from django-review.

Tyrdall avatar Tyrdall commented on July 17, 2024 1

@MAkcanca Load the book into the template context and do something like this:

<a href="{% url "review_create" content_type='book' object_id=book.pk %}">{% trans "Review this book" %}

Do not hardcode IDs and stuff.
If you want to know how this app works, please take a look at the source code.

Please understand that this is an issue tracker for this re-usable app. If you're new to Django/Python please use a more proper channel for your questions. Thanks!

from django-review.

MAkcanca avatar MAkcanca commented on July 17, 2024

Ah, a wild mistake appeared. Fixed that but now it gives 404 error. Is it because of my object or ? How should I set my object up ? Or is it because urls.py ? ( I can provide that if you think so)

from django-review.

MAkcanca avatar MAkcanca commented on July 17, 2024
class Book(models.Model):
    name = models.CharField(max_length=400)
    description = models.TextField()
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = GenericForeignKey()

    def __str__(self):
        return (self.name)

This is my current class.
How should I set up my urls.py ? Really appreciated !

from django-review.

Tyrdall avatar Tyrdall commented on July 17, 2024

@MAkcanca Please check out the README and follow the guide: https://github.com/bitlabstudio/django-review/blob/master/README.rst

Let me know, if there are issues.

from django-review.

MAkcanca avatar MAkcanca commented on July 17, 2024

Well I followed the guide but there was only one step to create review. So I wanted to try it and made a template file like this

{% load i18n %}
<!DOCTYPE html>
<html>
<head>
    <title>{% block title %}{% endblock %}</title>
</head>
<body>

{% block main %}
<a href="{% url "review_create" content_type='book' object_id=1 %}">{% trans "Review this book" %}</a>

{% endblock %}

</body>
</html>

Not sure what else can I do ? I may sound a little silly. Thanks for helping me through.

from django-review.

Tyrdall avatar Tyrdall commented on July 17, 2024

@MAkcanca Is there a book with an ID of 1 in the database?

from django-review.

MAkcanca avatar MAkcanca commented on July 17, 2024

Yes

id | name | description | content_type_id | object_id
----+-------------------+-------------+-----------------+-----------
2 | Test Book | test | 17 | 1

from django-review.

Tyrdall avatar Tyrdall commented on July 17, 2024

@MAkcanca :) First row -> ID -> 2.

from django-review.

MAkcanca avatar MAkcanca commented on July 17, 2024

It was 1, I then deleted the row and created one again. Tried with ID 2, still doesn't work and gives 404.

from django-review.

MAkcanca avatar MAkcanca commented on July 17, 2024

Thanks a lot again. Not hardcoding it and handling it with PK solved it.

from django-review.

Tyrdall avatar Tyrdall commented on July 17, 2024

@MAkcanca You're welcome :)

from django-review.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.