Here is my problem as using powerful raw,
User.objects.raw('SELECT usr.*, em.added as latest_email_added,
em.success as latest_email_success, em.subject as latest_email_subject
FROM auth_user AS usr LEFT JOIN dmusic_useremail as em ON em.user_id =
usr.id GROUP BY usr.id HAVING Max(em.added)')
User != UserEmail
User does not have subject, thus it will raise AttributeError: 'User'
object has no attribute 'subject'
Secondly, I do not want to create 1+N queries (where N is number of
users), with creating a query per user this would be simple but very
inefficient.
On Jan 16, 12:16 pm,
*First of all did you try accessing the email subject with a dotted
notation?*
try
u = User.objects.all()
and
u[0].subject
On Sun, Jan 16, 2011 at 12:53 PM, Jari Pennanen wrote:
> Hi!
>
> Suppose following model:
>
> class UserEmail(models.Model):
>"""User email"""
Hi!
Suppose following model:
class UserEmail(models.Model):
"""User email"""
user = models.ForeignKey(User, db_index=True,
null=True, blank=True, editable=False)
"""User recieving the email"""
added = models.DateTimeField(_("added"),
4 matches
Mail list logo