Hi,
-- There are a couple of things to think about here.
First of all - just because you put an item on your computer doesn't mean that the icon can be served. For example, if you are running windows and you enter 'C:\pictures\icon.jpg' as the source for the icon, your server won't be able to find it, because the reference 'C:\pictures\icon.jpg' doesn't mean anything for the web browser. The reason the image links you are inputting work is because they probably contain all information, ie http://www.example.com/pictures/icon.jpg.
So you can get that sorted and everything should work. HOWEVER, I really think you should use the media storage functionality of Django for this. Checkout : https://docs.djangoproject.com/en/1.11/topics/files/.
If you add the settings required (MEDIA_ROOT in the settings file) and then change you logo from a CharField to an ImageField AND upload your file via django admin, you should be able to show your file.
Regards,
Andréas
2017-09-25 14:38 GMT+02:00 tango ward <tangoward15@gmail.com>:
--Any tips please?Problem is, I can't load the images to my html file My logo images are currently stored in my computer. The images will load properly if I grab an image link online and paste the image location to the Logo field in Admin but if I used the absolute path of the images in my computer, the images wont load. When I tried to inspect the page, I am getting "Image could not load".I am writing my pet project which will display a Team name and their logo. I used these lines for my Team class in mode.spy
Hi guys, I am new to django currently stuck in these two.
class Team(models.Model):
name = models.CharField(max_length=150)
logo = models.CharField(null=True, max_length=1000)
def __str__(self):
return self.name
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com .
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users .
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ .CAA6wQLJ6kjsd80%2BcmFOZhPB5C_ 1Ugnu%3Ds51aisfNgK%3DambvJUg% 40mail.gmail.com
For more options, visit https://groups.google.com/d/optout .
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCfrBi-0XwcHQLJHWRcfbZHDuXR-ciBx6xB1TR_AR82h%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment