Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango Error Page not found (404)
    primarykey
    data
    text
    <p>I'm been working on this Photo Organizer and Sharing App Part I at <a href="http://lightbird.net/dbe/photo.html" rel="nofollow">http://lightbird.net/dbe/photo.html</a>. I'm trying to add a picture and when I do . I get this error.</p> <pre><code> Page not found (404) Request Method: GET Request URL: http://donkey123.pythonanywhere.com/admin/photo/image/1/images/Penguins_7.jpg/ image object with primary key u'1/images/Penguins_7.jpg' does not exist. You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page. </code></pre> <p>My Models is </p> <pre><code>from django.db import models from django.contrib.auth.models import User from django.contrib import admin from string import join import os from PIL import Image as PImage from mysite.settings import MEDIA_ROOT class Album(models.Model): title = models.CharField(max_length=60) public = models.BooleanField(default=False) def __unicode__(self): return self.title class Tag(models.Model): tag = models.CharField(max_length=50) def __unicode__(self): return self.tag class Image(models.Model): title = models.CharField(max_length=60, blank=True, null=True) image = models.FileField(upload_to="images/") tags = models.ManyToManyField(Tag, blank=True) albums = models.ManyToManyField(Album, blank=True) created = models.DateTimeField(auto_now_add=True) rating = models.IntegerField(default=50) width = models.IntegerField(blank=True, null=True) height = models.IntegerField(blank=True, null=True) user = models.ForeignKey(User, null=True, blank=True) def __unicode__(self): return self.image.name def save(self, *args, **kwargs): """Save image dimensions.""" super(Image, self).save(*args, **kwargs) im = PImage.open(os.path.join(MEDIA_ROOT, self.image.name)) self.width, self.height = im.size super(Image, self).save(*args, ** kwargs) def size(self): """Image size.""" return "%s x %s" % (self.width, self.height) def __unicode__(self): return self.image.name def tags_(self): lst = [x[1] for x in self.tags.values_list()] return str(join(lst, ', ')) def albums_(self): lst = [x[1] for x in self.albums.values_list()] return str(join(lst, ', ')) def thumbnail(self): return """&lt;a href="/media/%s"&gt;&lt;img border="0" alt="" src="/media/%s" height="40" /&gt;&lt;/a&gt;""" % ( (self.image.name, self.image.name)) thumbnail.allow_tags = True class AlbumAdmin(admin.ModelAdmin): search_fields = ["title"] list_display = ["title"] class TagAdmin(admin.ModelAdmin): list_display = ["tag"] class ImageAdmin(admin.ModelAdmin): search_fields = ["title"] list_display = ["__unicode__", "title", "user", "rating", "size", "tags_", "albums_","thumbnail","created"] list_filter = ["tags", "albums","user"] def save_model(self, request, obj, form, change): obj.user = request.user obj.save() </code></pre> <p>I think My Models,py is fine but I think the problem lay at the <code>MEDIA_ROOT=</code> and <code>MEDIA URL=</code></p> <p>My <code>MEDIA_ROOT = '/home/donkey123/mysite/photo'</code></p> <p>and my <code>MEDIA_URL</code> is "" which is blank.</p> <p>I don't know what to put for my <code>MEDIA_URL</code> which is the problem.</p> <p>Thanks in advance </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload