I'm a bit confused, why I cannot retrieve members of following Wikipedia Category:
http://dbpedia.org/page/List_of_members_of_the_17th_Bundestag
My query, which is easy and absolutely basic:
prefix dbc: <http://dbpedia.org/resource/Category:>
prefix dcterms: <http://purl.org/dc/terms/>
select ?member {
?member dcterms:subject dbc:List_of_members_of_the_17th_Bundestag
}
However for an other wikipedia category like
http://dbpedia.org/page/Category:American_physicists or many others I tried, it shows easily its members.
Thanks for any help in advance.
Related
I am trying to write a regexp to use with Crazyegg that will allow me to only gather data from my product pages.
My site structure is:
category page: www.sitename.com/categoryname/sub-categoryname
product page: www.sitename.com/productname/
My regex so far is:
^https?://([A-Za-z0-9.-]*\.)?sitename\.com/[A-Za-z0-9.-]*(/|/\?|)$
This allows everything that isnt at the sub category level (2nd level folder?)
the issue is that this allow top level categories so I need to exclude these by their name for example:
^https?://([A-Za-z0-9.-]*\.)?sitename\.com/(?!\babout\b|\bcheckout\b)(/|/\?|)$
Could you please help me get the exclusion correct? ive also tried doing using [^\babout\b|\bcheckout\b]
if you only want product pages, the regex for capture product pages is:
".*productname"
For capture category pages: ".*categoryname/sub-categoryname"
I hope help you. If you have more questions, ask me!
How would one pass parameters to a has_many association ?
Let's say we have categories and posts, associated with a join table, category_posts
category has_many category_posts
category_has_many posts, through category_posts
and reverse for the post (not the right syntax, to make it quick here)
Let's say we got this basic syntax for adding :
category.posts << post
The join table category_posts has a specific field that I'd like to fill when creating the above association.
I'm looking for a one-liner syntax to do it, if that'd ever be possible
Thanks for your advance experience feedback
(totally different, but this is what I mean by "one-liner syntax" Rails4 // append strong_parameters with other params : the kind of thing that tend to be done with many more lines of code)
You'd have to do it by adding to the category_posts relation directly, e.g.:
category.category_posts << CategoryPost.create(post: post, other_field: other_value)
or, slightly more condensed:
category.category_posts.create(post: post, other_field: other_value)
What I am trying to do is to find the earliest article that has no related article_history.
Here is what I tried, but isn't working:
the_article = Article.objects.filter(cowcode=country).filter(pubdate__range=(start_date,end_date)).exclude(article_history_set__id > 0).order_by('pubdate')[0]
My thinking behind this was that the query is working until the exclude: I get all the articles that match the condition. Since I want to find the earliest article that has no article history attached yet, excludeing all articles that have articles with an article_history id > 0 should work. Why isn't it?
Would be awesome if someone could help me out here.
try
...end_date)).filter(article_history_set__isnull=True).order_by...
or
...end_date)).exclude(article_history_set__isnull=False).order_by…
and if you have self-relational foreign key as parent-children you can do that:
....filter(children__isnull=True).order_by...
or
....exclude(children__isnull=False).order_by...
I'm trying to order a list of items in django by the number of comments they have. However, there seems to be an issue in that the Count function doesn't take into account the fact that django comments also uses a content_type_id to discern between comments for different objects!
This gives me a slight problem in that the comment counts for all objects are wrong using the standard methods; is there a 'nice' fix or do I need to drop back to raw sql?
Code to try and ge the correct ordering:
app_list = App.objects.filter(published=True)
.annotate(num_comments=Count('comments'))
.order_by('-num_comments')
Sample output from the query (note no mention of the content type id):
SELECT "apps_app"."id", "apps_app"."name",
"apps_app"."description","apps_app"."author_name", "apps_app"."site_url",
"apps_app"."source_url", "apps_app"."date_added", "apps_app"."date_modified",
"apps_app"."published", "apps_app"."published_email_sent", "apps_app"."created_by_id",
"apps_app"."rating_votes", "apps_app"."rating_score", COUNT("django_comments"."id") AS
"num_comments" FROM "apps_app" LEFT OUTER JOIN "django_comments" ON ("apps_app"."id" =
"django_comments"."object_pk") WHERE "apps_app"."published" = 1 GROUP BY
"apps_app"."id", "apps_app"."name", "apps_app"."description", "apps_app"."author_name",
"apps_app"."site_url", "apps_app"."source_url", "apps_app"."date_added",
"apps_app"."date_modified", "apps_app"."published", "apps_app"."published_email_sent",
"apps_app"."created_by_id", "apps_app"."rating_votes", "apps_app"."rating_score" ORDER
BY num_comments DESC LIMIT 4
Think I found the answer: Django Snippet
Recently i have implemented django-sphinx search on my website.
It is working fine of each separate model.
But now my client requirement has changed.
To implement that functionality i need field name to whom search is made.
suppose my query is:
"select id, name,description from table1"
and search keyword is matched with value in field "name". So i need to return that field also.
Is it possible to get field name or any method provided by django-sphinx which return field name.
Please help me...
As far as I know, this isn't possible. You might look at the contents of _sphinx though.
Well from django-sphinx it might not be possible. But there is a solution -
Make different indexes, each index specifying the field that you need to search.
In your django-sphinx models while searching do this -
search1 = SphinxSearch(index='index1')
search2 = SphinxSearch(index='index2')
...
After getting all the search results, you aggregate them & you have the info of from where they have come.