Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8490625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:10:53+00:00 2026-06-10T22:10:53+00:00

i know you will say that this question is asked before many times but

  • 0

i know you will say that this question is asked before many times but i havent solved it yet…

models.py

class Doc(UploadModel):
    doc_no =  models.CharField(max_length=100, verbose_name = "No", blank=True)
    date_added = models.DateTimeField(verbose_name="Date", default=datetime.now,
                 editable=False)

class DocImage(models.Model):
    property = models.ForeignKey(Doc, related_name='images')
    image = FileBrowseField("Docs", max_length=200,
            directory="doc_img/%Y/%m/%d/%H/%M/%S/", 
            extensions=[".jpg",".tif"], blank=True, null=True)

views.py

def doc_detail(request, dosc_no):

    res = Doc.objects.filter(doc_no = dosc_no)        
    return render_to_response("doc/doc_detail.html",  {"result": res})

templates:

{% for i in docimage.property_set.all %}

{{ i.image.url }}  

{% endfor %}

i have tried above template but i didnt get any result. so i want to get imageurl adress in DocImage class…

all helps

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:10:54+00:00Added an answer on June 10, 2026 at 10:10 pm

    If you review the foreign key documentation, if you have a relationship like

    Doc -> has many DocImages
    

    you need to define your foreign key on the DocImages class like so:

    class DocImage(models.Model):
        property = models.ForeignKey(Doc, related_name='images')
    

    If you don’t set related names, you can access the DocImages from the Doc like:

    Doc.docimage_set.all()
    

    Docs on Related Objects

    But setting related_name in the property field lets you do

    Doc.images.all()
    

    Just make sure whatever you pass to the template in the view context matches what is used in the template, e.g.

    # in the view
    return render_to_response('mytemplate.html', { 'mydoc' : doc, 'mydocimage' : img }
    

    This can then be used in the template as follows:

    # and in your template to get the images attached to the document
    {% for i in mydoc.images.all %}
        ...
    {% endfor %}
    
    # or to get the document the image belongs to
    {{ mydocimage.property.date_added }}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question may be asked many times but most of them suggests
I know that this question might have been asked like 100 times, but, believe
I know that this question has been asked previously, but before you give me
I know this question have been asked lot of times that how to track
I know, variations of this question had been asked before. But my case may
I know that this type of question has been asked over and over again,
This question I have asked before and just got answer that there is an
I know this question has been asked before, example , and I do agree
I know this question as been asked over and over but it's still quite
I know this question was asked by many people and there are several discussions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.