Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to know the owner who shared this file in this context in Django?
    primarykey
    data
    text
    <p>I have a table like this:</p> <pre><code>+----+----------+----------+----------------+----------------------------------+ | id | users_id | files_id | shared_user_id | shared_date | +----+----------+----------+----------------+----------------------------------+ | 3 | 1 | 1 | 2 | 2013-01-31 14:27:06.523908+00:00 | | 2 | 1 | 1 | 2 | 2013-01-31 14:25:37.760192+00:00 | | 4 | 1 | 3 | 2 | 2013-01-31 14:46:01.089560+00:00 | | 5 | 1 | 1 | 3 | 2013-01-31 14:50:54.917337+00:00 | </code></pre> <p>Now I want to know the owner of each files who shared the file. For file 1, users_id is 1. I want to get the name of users_id 1 from the default Django auth_user table. I want to get the usernames for each file. How can I do that?</p> <pre><code>#models.py from django.db import models from django.contrib.auth.models import User class File(models.Model): users = models.ForeignKey(User) file_name = models.CharField(max_length=100) type = models.CharField(max_length=10) source = models.CharField(max_length=100) start_date = models.TextField() end_date = models.TextField() duration = models.TextField() size_overview = models.IntegerField() size = models.TextField() flag = models.TextField() #delete_date = models.CharField(max_length=100, null=True, blank=True) class Share(models.Model): users = models.ForeignKey(User) files = models.ForeignKey(File) shared_user_id = models.IntegerField() shared_date = models.TextField() class Host(models.Model): name = models.TextField() full_path = models.TextField() </code></pre>
    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.
    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