0

I am trying to make a project "pinterest clone". I am following the bellow link - https://github.com/sobriquette/pinclone . When I try to add a pinner I am getting this error - "NoReverseMatch at /admin/pinterest/pinner/add/" . I don't understand what's the problem. Please help me to find out.

This is my models.py

from __future__ import unicode_literals
import uuid

from django.db import models
import django.utils.encoding

class Pinner(models.Model):
    pinner_id = models.CharField(primary_key=True, editable=False, max_length=255)
    avatar = models.URLField(blank=True)
    full_name = models.CharField(max_length=128)
    username = models.CharField(max_length=20)

    def print_attr(self):
        for k, v in self.__dict__.items():
            if '__' not in k:
                print("{}: {}".format(k, v))

    def __str__(self):
        return self.username

class Board(models.Model):
    board_id = models.CharField(primary_key=True, editable=False, max_length=255)
    name = models.CharField(max_length=20)
    pinner = models.ForeignKey(Pinner, on_delete=models.CASCADE)
    url = models.URLField()

    def print_arrt(self):
        for k, v in self.__dict__.items():
            if '__' not in k:
                print("{}: {}".format(k, v))

    def __str__(self):
        return self.name

class Pin(models.Model):
    pin_id = models.CharField(primary_key=True, editable=False, max_length=255)
    board = models.ForeignKey(Board, on_delete=models.CASCADE)
    description = models.CharField(max_length=255, blank=True)
    link_count = models.IntegerField(blank=True)
    link = models.URLField(blank=True, null=True)
    title = models.CharField(max_length=128, blank=True)

    def print_attr(self):
        for k, v in self.__dict__.items():
            if '__' not in k:
                print("{}: {}".format(k, v))

    def __str__(self):
        return self.title

class Image(models.Model):
    image_id = models.CharField(primary_key=True, editable=False, max_length=255)
    pin = models.ForeignKey(Pin, related_name='images', on_delete=models.CASCADE)
    url = models.URLField(blank=True, null=True)

    def print_attr(self):
        for k, v in self.__dict__.items():
            if '__' not in k:
                print("{}: {}".format(k, v))

    def __self__(self):
        return self.url

and this is the admin.py

from __future__ import unicode_literals

from django.contrib import admin
from .models import Pinner
from .models import Board
from .models import Pin
from .models import Image

admin.site.register(Pinner)
admin.site.register(Board)
admin.site.register(Pin)
admin.site.register(Image)
Sharif
  • 533
  • 2
  • 6
  • 11
  • 1
    Can you please post your urls.py and your views.py? [What is a NoReverseMatch error, and how do I fix it?](https://stackoverflow.com/questions/38390177/what-is-a-noreversematch-error-and-how-do-i-fix-it) – Paolo Apr 05 '19 at 16:32
  • whats the URL you are visitng when you see this error? – Walucas Apr 05 '19 at 18:01
  • this is my urls.py `from django.conf.urls import url, include from django.contrib import admin urlpatterns = [ url(r'^pinterest/', include('pinterest.urls')), url(r'^admin/', admin.site.urls), ]` and this is the views.py `from __future__ import unicode_literals from django.shortcuts import render from django.http import HttpResponse from django.template import loader from .models import Pin def index(request): contex = {'pins_list': Pin.objects.all()} return render(request, 'pinterest/index.html', contex)` – Sharif Apr 06 '19 at 04:38
  • when I try to add new pinner the url is (http://localhost:8000/admin/pinterest/pinner/add/) @Walucas – Sharif Apr 06 '19 at 04:50
  • whats your django version? – Walucas Apr 06 '19 at 21:29
  • django version 1.11.20 @Walucas – Sharif Apr 10 '19 at 16:49

0 Answers0