django join querysets from multiple tables -


If I have questions on several tables such as:

  d = Relations.objects.filter (follow = request.user) .filter (date_follow__lt = last_checked) R = Reply.objects.filter (REPLY_TO = request.user) .filter (date_reply__lt = last_checked) article = New.objects.filter (created_by = request.user) votes = Votekobjectskfilter (vote = article) .filter (date__lt = last_checked)  

and I do not mean I have all the listings you want to display the results sorted by date all of them ( Answer, all votes, etc.) Either way, I want to be involved in all these results in a single query. Is it possible?

In addition to Sebastian Offer No. 2: In the Jengo some built-in functionality that you "abuse it " can do; The administrator is already a user's actions and reference objects connected through a common foreign key relationship is a model, I think you can just sub-class of this model and use it for their purposes:

  Import to import Django.contrib.admin.models, import additional import django.contrib.contenttypes.models from django.utils.encoding import force import ContentType class MyLog (LogEntry): class meta (LogEntry.Meta): db_table_name = 'my_log_table' and not In here def log_addition (request object) #use: LogEntry.objects.log_action (user_id = request.user.pk, content_type_id = .pk ContentType.objects.get_for_model (object), object_id = object.pk, object_repr = force_unicode (object ), action_flag = addition)  

you can now access all your notifications etc., where log_addition (request object) to get along with and log Table Filters Compared to Your Objectives! If you want to enter change / extinction etc. then you can do some helpful work for it!


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -