Re: render .txt file in django template

2014-01-30 Thread Fatih Tiryakioglu
But the document says that static media isn't about django, but apache (for 
production). Loading static file contents in the view.py seems to me not 
effecient.

I am now on development phase, and I think I should render static files in 
the template now. And in the production phase, I would change just the 
shortcuts..

Am I wrong?


--


30 Ocak 2014 Perşembe 23:33:11 UTC+2 tarihinde C. Kirby yazdı:
>
> The template engine doesn't have direct access to the filesystem. You will 
> have to pass the file contents from your view to the template:
>
> 1.Load the file in your view 
> 2. Read it into a context variable.
> 3. Render the context variable in your template
>
> On Thursday, January 30, 2014 3:29:29 PM UTC-6, Fatih Tiryakioglu wrote:
>>
>> Hi all,
>>
>> Could you please show me how can I render .txt static files (they are 
>> user comments) in django template? I couldn't resolve that issue for a 
>> month..
>>
>> I appreciate your help.
>>
>>
>> --
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b73bfc84-e005-41d0-aa78-a652e0a4ccb5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


render .txt file in django template

2014-01-30 Thread Fatih Tiryakioglu
Hi all,

Could you please show me how can I render .txt static files (they are user 
comments) in django template? I couldn't resolve that issue for a month..

I appreciate your help.


--

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/711fef18-ce6b-413b-a469-fb3411a20208%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


text media files for comments

2014-01-13 Thread Fatih Tiryakioglu
Hi all,

I want to render a static media .txt file from django template, but I can't 
load it. Should I use database for text comments, or is it better statatic 
text files like image files in media folder.

Any help is appreciated.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/de60230e-bbe9-4e40-bdd4-ca29617497ae%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


how to load and render "static .txt file content" from django template

2013-12-07 Thread Fatih Tiryakioglu
Hi all,

I want to render a static .txt file from django template, but I can't load 
it. I tried some combinations. Here is some of them:

   



src="shortcut/to/text-file.txt" 

How can I load the context of this file?

Thanks all.

Note: I can render static image files, so it is not a settings problem.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b54669cb-6d8e-481a-a4f7-665fd1e0876d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: how to get count of each distinct value

2013-11-22 Thread Fatih Tiryakioglu
Thank you.


--

22 Kasım 2013 Cuma 18:07:47 UTC+2 tarihinde larry@gmail.com yazdı:
>
> On Fri, Nov 22, 2013 at 10:44 AM, Fatih Tiryakioglu 
> <fati...@gmail.com
> > wrote:
>
>> Hi all,
>>
>> How can I get distribution of values in a field? For example, I have the 
>> scores below:
>>
>>  (score)
>> (raw1)1
>> (raw2)1
>> (raw3)3
>> (raw4)4
>> (raw5)4
>> (raw6)5
>> (raw7)8
>> (raw8)8
>> (raw9)9
>> (raw10)10
>>
>> I want to have a result like that: {1: 2}, {3: 1}, {4: 2}, {5: 1}, {8: 
>> 2}, {9: 1}, {10: 1}. So it is {score: count}.
>>
>> How can I evaluate this only one db hit?
>>
>> Thanks all.
>>
>
> In SQL:
>
> SELECT score, COUNT(*) FROM foo GROUP BY score; 
>
> In Django:
>
> from django.db.models import Count
> q = Foo.objects.values('score').annotate(Count('score'))
> for r in q:
> print r, r.score__count
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/95c5956c-7ca3-4930-9ab4-25fa47b8d249%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


how to get count of each distinct value

2013-11-22 Thread Fatih Tiryakioglu
Hi all,

How can I get distribution of values in a field? For example, I have the 
scores below:

 (score)
(raw1)1
(raw2)1
(raw3)3
(raw4)4
(raw5)4
(raw6)5
(raw7)8
(raw8)8
(raw9)9
(raw10)10

I want to have a result like that: {1: 2}, {3: 1}, {4: 2}, {5: 1}, {8: 2}, 
{9: 1}, {10: 1}. So it is {score: count}.

How can I evaluate this only one db hit?

Thanks all.


--

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/301f4583-892e-4e06-b3a7-983381b95fbd%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


jquery doesn't give selected option of a dropbox

2013-05-07 Thread Fatih Tiryakioglu


Hi all,

I have a jquery js code in a template like that:


jQuery(document).ready(function(){
jQuery("select").change(function(){
var str = $('select option:selected').text();
alert(str);
});
});

and, a select form which is handled by the js code above:

class GrupEklemeFormu(forms.Form):
GORL = (
(1, ("Global")),
(2, ("Lokal")),
)
g_or_l = forms.ChoiceField(choices=GORL)

When I select Global or Local in the page, str becomes "GlobalGlobal" or 
"GlobalLokal". What is the reason for that? How can I get rid of the error. 
Thanks..

--

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how to cat'ing string in html file

2013-04-07 Thread Fatih Tiryakioglu
Thank you again Pankaj,

But evaluated string is just ".jpg" . "/media/" and i.no are absent..

On Sunday, April 7, 2013 12:16:34 PM UTC+3, psjinx wrote:
>
> On Sun, Apr 7, 2013 at 1:11 PM, Fatih Tiryakioglu 
> <fati...@gmail.com> 
> wrote: 
>
> > {% with "/media/"|add:"{{ i.no }}"|add:".jpg" as template_str %} 
> This should be 
>
> {% with "/media/"|add:i.no|add".jpg" as template_str %} 
>  
> {% endwith %} 
>
> You don't need to use `{{ }}` inside `{% %}`. 
>
> -- 
>
> Sincerely, 
> Pankaj Singh 
> http://about.me/psjinx 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




how to cat'ing string in html file

2013-04-07 Thread Fatih Tiryakioglu
Hello,

In a html template file, how can I concatenate strings:

I find the solution below:
{% with "/media/"|add:"{{ i.no }}"|add:".jpg" as template_str %}

But
When I use: , template_str is /media/{{ i.no }}.jpg
How can I evaluate
/media/8778877767767.jpg

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: couldn't render a media image via a template

2013-04-07 Thread Fatih Tiryakioglu
Thank you very much.

I think the problem is about printing variable. {{ MEDIA_URL }} doesn't 
print anything in the template. For now, I solved the problem by using 
absolute path, /media/... .


--


On Sunday, April 7, 2013 9:20:16 AM UTC+3, psjinx wrote:
>
> On Sat, Apr 6, 2013 at 4:11 PM, Fatih Tiryakioglu 
> <fati...@gmail.com> 
> wrote: 
> > MEDIA_ROOT = '/home/mehmet/internet_projeleri/site4ust/site4/media' 
> This is the absolute path to your media directory. 
> > MEDIA_URL = '/media/' 
> This means files/directories at MEDIA_ROOT directory will be 
> accessible at an url starting with /media/. For example, 
> /home/mehmet/internet_projeleri/site4ust/site4/media/hello.jpg can be 
> viewed at /media/hello.jpg 
>
> > STATIC_ROOT = ' ' 
> This should be set to absolute path of your static directory. `python 
> manage.py collectstatic` command collects static files from different 
> apps in this directory. 
> > STATIC_URL = '/unnamed/' 
> As explained above for MEDIA_URL 
>
> If you want to use an image located at 
> /home/mehmet/internet_projeleri/site4ust/unnamed/60830071673353216.jpg 
> then change 
>
> MEDIA_ROOT="/home/mehmet/internet_projeleri/site4ust/unnamed" 
> MEDIA_URL="/media/" 
>
> >  
>
> Above code will work now. 
>
> -- 
>
> Sincerely, 
> Pankaj Singh 
> http://about.me/psjinx 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: couldn't render a media image via a template

2013-04-06 Thread Fatih Tiryakioglu
It doesn't work..


--

On Saturday, April 6, 2013 2:46:05 PM UTC+3, Avnesh Shakya wrote:
>
> try it..
>
> create one more folder media and put that media folder inside this new 
> folder
> and  then run..
>
> regards,
> Avnesh Shakya
>
> On Sat, Apr 6, 2013 at 4:11 PM, Fatih Tiryakioglu 
> <fati...@gmail.com
> > wrote:
>
>> I want to render an image via a template, but the template can't show 
>> image, but only a small image symbol..
>>
>> My settings:
>>
>> MEDIA_ROOT = '/home/mehmet/internet_**projeleri/site4ust/site4/**media'
>> MEDIA_URL = '/media/'
>> STATIC_ROOT = ' '
>> STATIC_URL = '/unnamed/'
>>
>> I have a template in 
>> '/home/mehmet/internet_**projeleri/site4ust/site4/**templatelerim', 
>> which has the following line:
>> 
>>
>> I also added last pattern to the .../site4/urls.py:
>>
>> urlpatterns = patterns(' ',
>>  url(r'^giris/$', 'unnamed.views.giris'),
>>  url(r'^anasayfa/$', 'unnamed.views.anasayfa'),
>>  url(r'^upload/$', 'unnamed.views.dosya_yukle'),
>>  url(r'^media/(?P.*)$', 'django.views.static.serve', 
>> {'document_root': settings.MEDIA_ROOT}),
>> )
>>
>> What is the problem..
>>  
>>
>>
>>
>> On Saturday, April 6, 2013 1:27:54 PM UTC+3, Fatih Tiryakioglu wrote:
>>>
>>> >> src="/home/mehmet/internet_**projeleri/site4ust/unnamed/**60830071673353216"
>>>  
>>> />
>>>
>>> And in the settings:
>>>
>>> MEDIA_ROOT = '/home/mehmet/internet_**projeleri/site4ust/site4/**media'
>>> MEDIA_URL = '/media/'
>>> STATIC_ROOT = ' '
>>> STATIC_URL = '/static/'
>>>
>>> I have a template in '/home/mehmet/internet_**projeleri/site4ust/site4/*
>>> *templatelerim', which has the following line:
>>> > To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: couldn't render a media image via a template

2013-04-06 Thread Fatih Tiryakioglu
I want to render an image via a template, but the template can't show 
image, but only a small image symbol..

My settings:

MEDIA_ROOT = '/home/mehmet/internet_projeleri/site4ust/site4/media'
MEDIA_URL = '/media/'
STATIC_ROOT = ' '
STATIC_URL = '/unnamed/'

I have a template in 
'/home/mehmet/internet_projeleri/site4ust/site4/templatelerim', which has 
the following line:


I also added last pattern to the .../site4/urls.py:

urlpatterns = patterns(' ',
 url(r'^giris/$', 'unnamed.views.giris'),
 url(r'^anasayfa/$', 'unnamed.views.anasayfa'),
 url(r'^upload/$', 'unnamed.views.dosya_yukle'),
 url(r'^media/(?P.*)$', 'django.views.static.serve', 
{'document_root': settings.MEDIA_ROOT}),
)

What is the problem..




On Saturday, April 6, 2013 1:27:54 PM UTC+3, Fatih Tiryakioglu wrote:
>
>  src="/home/mehmet/internet_projeleri/site4ust/unnamed/60830071673353216" />
>
> And in the settings:
>
> MEDIA_ROOT = '/home/mehmet/internet_projeleri/site4ust/site4/media'
> MEDIA_URL = '/media/'
> STATIC_ROOT = ' '
> STATIC_URL = '/static/'
>
> I have a template in 
> '/home/mehmet/internet_projeleri/site4ust/site4/templatelerim', which has 
> the following line:
> http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




couldn't render a media image via a template

2013-04-06 Thread Fatih Tiryakioglu


And in the settings:

MEDIA_ROOT = '/home/mehmet/internet_projeleri/site4ust/site4/media'
MEDIA_URL = '/media/'
STATIC_ROOT = ' '
STATIC_URL = '/static/'

I have a template in 
'/home/mehmet/internet_projeleri/site4ust/site4/templatelerim', which has 
the following line:
http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: static file rendering help

2013-04-05 Thread Fatih Tiryakioglu
I tried both of them, but it seems it isn't the problem..


--

5 Nisan 2013 Cuma 23:14:20 UTC+3 tarihinde jondbaker yazdı:
>
> From a quick glance it appears that the file source you've included in the 
> html is not specifying a file extension.
>
> Try:
>  src="/home/mehmet/internet_projeleri/site4ust/unnamed/60830071673353216.jpg" 
> />
> ...instead of...
>  />
>
>
> On Fri, Apr 5, 2013 at 1:43 PM, Fatih Tiryakioglu 
> <fati...@gmail.com
> > wrote:
>
>> Thank you. 
>>
>> The shortcut of the picture:
>> /home/mehmet/internet_projeleri/site4ust/unnamed/60830071673353216.jpg
>>
>> In the template I have written the line below to render a jpg file. 
>>
>> > src="/home/mehmet/internet_projeleri/site4ust/unnamed/60830071673353216" />
>>
>> And in the settings:
>>
>> MEDIA_ROOT = '/home/mehmet/internet_projeleri/site4ust/unnamed'
>> MEDIA_URL = '/unnamed/'
>> STATIC_ROOT = ''
>> STATIC_URL = '/static/'
>>
>> What is wrong..
>>
>>
>> --
>>
>>
>>
>> 5 Nisan 2013 Cuma 20:26:40 UTC+3 tarihinde Navid Shaikh yazdı:
>>
>>>
>>>
>>> On Friday, April 5, 2013 11:16:00 AM UTC+5:30, Fatih Tiryakioglu wrote:
>>>>
>>>> Hi all,
>>>>
>>>> I want to render back "user uploaded images" via template. I pass the 
>>>> shortcuts to the template, but template can't show it: only small image 
>>>> symbol. How can i show it up. I tryed some 'MEDIA_ROOT', 'MEDIA_URL' 
>>>> settings, and read some info, but i couldn't figure out..
>>>>
>>>>  
>>> Might be the there is problem with the path of image.
>>> Can you post the some code, how are you rendering images? 
>>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>
>
> -- 
> Jonathan D. Baker
> Developer
> http://jonathandbaker.com
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: static file rendering help

2013-04-05 Thread Fatih Tiryakioglu
Thank you. 

The shortcut of the picture:
/home/mehmet/internet_projeleri/site4ust/unnamed/60830071673353216.jpg

In the template I have written the line below to render a jpg file. 



And in the settings:

MEDIA_ROOT = '/home/mehmet/internet_projeleri/site4ust/unnamed'
MEDIA_URL = '/unnamed/'
STATIC_ROOT = ''
STATIC_URL = '/static/'

What is wrong..


--



5 Nisan 2013 Cuma 20:26:40 UTC+3 tarihinde Navid Shaikh yazdı:
>
>
>
> On Friday, April 5, 2013 11:16:00 AM UTC+5:30, Fatih Tiryakioglu wrote:
>>
>> Hi all,
>>
>> I want to render back "user uploaded images" via template. I pass the 
>> shortcuts to the template, but template can't show it: only small image 
>> symbol. How can i show it up. I tryed some 'MEDIA_ROOT', 'MEDIA_URL' 
>> settings, and read some info, but i couldn't figure out..
>>
>>  
> Might be the there is problem with the path of image.
> Can you post the some code, how are you rendering images? 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




static file rendering help

2013-04-04 Thread Fatih Tiryakioglu
Hi all,

I want to render back "user uploaded images" via template. I pass the 
shortcuts to the template, but template can't show it: only small image 
symbol. How can i show it up. I tryed some 'MEDIA_ROOT', 'MEDIA_URL' 
settings, and read some info, but i couldn't figure out..

I appreciate your helps..


--

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: queryset minimization

2013-03-07 Thread Fatih Tiryakioglu
Thank you Nicolas,

This works:
reg = p.groupregistration_set.all().select_related('group')
name = reg[0].group.name

This also works:
name = p.groupregistration_set.all().select_related('group')[0].group.name


1) Is there any difference? Which one is beter.
2) reg = p.groupregistration_set.all().select_related('group')
name = reg[0].group.name
 does second line result in db hit???
3) name = 
p.groupregistration_set.all().select_related('group')[0].group.name
 this is 1 or 2 hit??

and an optional 10 points question:
4) If I had two members of reg list, how to modify the code above?


Thanks again..


--




--

On Thursday, March 7, 2013 6:35:14 PM UTC+2, Nikolas Stevenson-Molnar wrote:
>
> The biggest hit is probably going to be the reg.group call. You can 
> optimize that by using select_related (), which will take what is 
> currently 1 + (number of group registrations for the user) queries and 
> turn it into 2 queries: 
>
> reg = p.groupregistration_set.all().select_related('group') 
>
> More on select_related: 
> https://docs.djangoproject.com/en/dev/ref/models/querysets/#select-related 
>
> _Nik 
>
> On 3/6/2013 11:18 PM, Fatih Tiryakioglu wrote: 
> > Hi all, 
> > 
> > Is there any shortcut (minimum db hit) for the following querysets: 
> > 
> > p = Person.objects.get(mail="pers...@ex.com ") 
> > p.password & form.password comparison and it is ok. 
> > 
> > #reversing to the person's groupregisteration, for example: 
> > reg = p.groupregistration_set.all() #groupregistratin model is simply 
> > person (foreign key) and group (foreign key) 
> > 
> > #evaluating group of reg list. 
> > g = reg.group (for the every member of reg list) 
> > 
> > #and finally group name 
> > n = g.name (for the every member of g list) 
> > 
> > Which queryset or querysets hits the db, and how can I minimize it. 
> > 
> > 
> > 
> > Thanks. 
> > -- 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> > an email to django-users...@googlegroups.com . 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > Visit this group at http://groups.google.com/group/django-users?hl=en. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> >   
> >   
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




queryset minimization

2013-03-06 Thread Fatih Tiryakioglu
Hi all,

Is there any shortcut (minimum db hit) for the following querysets:

p = Person.objects.get(mail="pers...@ex.com")
p.password & form.password comparison and it is ok.

#reversing to the person's groupregisteration, for example:
reg = p.groupregistration_set.all() #groupregistratin model is simply 
person (foreign key) and group (foreign key)

#evaluating group of reg list.
g = reg.group (for the every member of reg list)

#and finally group name
n = g.name (for the every member of g list)

Which queryset or querysets hits the db, and how can I minimize it.



Thanks.
--


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: reverse foreign key relationship usage

2013-03-06 Thread Fatih Tiryakioglu
Thank you Robert, I got it.


--


6 Mart 2013 Çarşamba 12:06:06 UTC+2 tarihinde Roberto López López yazdı:
>
>
> Hi Fatih, 
>
> This is extremely useful in case you have two different relations 
> between the same model. As a rough example, consider the two following 
> models: 
>
> class Person(models.Model): 
> name = models.CharField(max_length=30) 
>
> class Car(models.Model): 
> model = models.CharField(max_length=20) 
> owner = models.OneToOne(Person, related_name='owned_car') 
> users = models.ForeignKey(Person, related_name='used_car') 
>
> In case of not having a different related_name for each of those two 
> relations, you wouldn't be able to get the person's car or the car this 
> person uses. (This person may own a car but use his company car, or a 
> friend's, a rental one...) 
>
>
>
>
>
> On 03/06/2013 08:30 AM, Fatih Tiryakioglu wrote: 
> > Hello all, 
> > 
> > In Appendix B:Database API, it says "related_name (keyword) is 
> > particularly useful if a model has two foreign keys to the same second 
> > model." which is about 'related_name' keyword used reverse foreign key 
> > relationships. 
> > e.g. blog = ForeignKey(Blog, related_name='entries'). 
> > 
> > What does it mean? Where should I use related_name instead of simply 
> > reversing by "x_set" keyword. 
> > 
> > Thanks. 
> > 
> > 
> > -- 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> > an email to django-users...@googlegroups.com . 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > Visit this group at http://groups.google.com/group/django-users?hl=en. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> >   
> >   
>
>
> -- 
> Kind regards, 
>
> Roberto L�pez L�pez 
>
>
> System Developer 
> Parallab, Uni Computing 
> H�yteknologisenteret, Thorm�hlensgate 55 
> N-5008 Bergen, Norway 
> Tel:(+47) 555 84091 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




reverse foreign key relationship usage

2013-03-05 Thread Fatih Tiryakioglu
Hello all,

In Appendix B:Database API, it says "related_name (keyword) is particularly 
useful if a model has two foreign keys to the same second model." which is 
about 'related_name' keyword used reverse foreign key relationships. 
e.g. blog = ForeignKey(Blog, related_name='entries').

What does it mean? Where should I use related_name instead of simply 
reversing by "x_set" keyword.

Thanks.


--

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




how to evaluate "cities/countries of the world" static table for an application.

2013-02-24 Thread Fatih Tiryakioglu
Hello all,

Is there any shortcut for evaluating such a database table, or should I 
collect myself all this information. Please help. If you prefer a package 
which one do you prefer, or all of them is workable.

Thanks.


--

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: poll tutorial 4

2013-01-26 Thread Fatih Tiryakioglu
I think somebody just updated the tutorial document as

return HttpResponseRedirect(reverse('polls:results', args=(p.id,)))

Thanks..


--


26 Ocak 2013 Cumartesi 13:54:04 UTC+2 tarihinde Fatih Tiryakioglu yazdı:
>
> Hi all,
>
> I have encountered following error in the django tutorial. It is a reverse 
> function error and the problematic line:
>
> return HttpResponseRedirect(reverse('polls.views.results', args=(p.id,)))
>
> In the "vote" view, I choose one of the choices, and click the vote 
> button. Instead of "results" view, I face this error. ("results" view 
> works, and the scores of the choices are also correct.)
>
> My tree:
>
> .
> ├── databaseim.db
> ├── manage.py
> ├── polls
> │   ├── admin.py
> │   ├── admin.pyc
> │   ├── __init__.py
> │   ├── __init__.pyc
> │   ├── models.py
> │   ├── models.pyc
> │   ├── tests.py
> │   ├── urls.py
> │   ├── urls.pyc
> │   ├── views.py
> │   └── views.pyc
> └── proje1
> ├── __init__.py
> ├── __init__.pyc
> ├── settings.py
> ├── settings.pyc
> ├── templatelerim
> │   ├── admin
> │   │   └── base_site.html
> │   └── polls
> │   ├── detail.html
> │   ├── index.html
> │   └── results.html
> ├── urls.py
> ├── urls.pyc
> ├── wsgi.py
> └── wsgi.pyc
>
> --
>
>
> Environment:
>
>
> Request Method: POST
> Request URL: http://127.0.0.1:8000/polls/1/vote/
>
> Django Version: 1.4.3
> Python Version: 2.7.3
> Installed Applications:
> ('django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'django.contrib.admin',
>  'polls')
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware')
>
> Traceback:
> File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" 
> in get_response
>   111. response = callback(request, 
> *callback_args, **callback_kwargs)
> File "/home/mehmet/internet_projeleri/proje1/polls/views.py" in vote
>   55. return HttpResponseRedirect(reverse('polls.views.results', 
> args=(p.id,)))
> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
> in reverse
>   476. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, 
> *args, **kwargs))
> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
> in _reverse_with_prefix
>   396. "arguments '%s' not found." % (lookup_view_s, args, 
> kwargs))
>
> Exception Type: NoReverseMatch at /polls/1/vote/
> Exception Value: Reverse for 'polls.views.results' with arguments '(1,)' 
> and keyword arguments '{}' not found.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




poll tutorial 4

2013-01-26 Thread Fatih Tiryakioglu
Hi all,

I have encountered following error in the django tutorial. It is a reverse 
function error and the problematic line:

return HttpResponseRedirect(reverse('polls.views.results', args=(p.id,)))

In the "vote" view, I choose one of the choices, and click the vote button. 
Instead of "results" view, I face this error. ("results" view works, and 
the scores of the choices are also correct.)

My tree:

.
├── databaseim.db
├── manage.py
├── polls
│   ├── admin.py
│   ├── admin.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── models.py
│   ├── models.pyc
│   ├── tests.py
│   ├── urls.py
│   ├── urls.pyc
│   ├── views.py
│   └── views.pyc
└── proje1
├── __init__.py
├── __init__.pyc
├── settings.py
├── settings.pyc
├── templatelerim
│   ├── admin
│   │   └── base_site.html
│   └── polls
│   ├── detail.html
│   ├── index.html
│   └── results.html
├── urls.py
├── urls.pyc
├── wsgi.py
└── wsgi.pyc

--


Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/polls/1/vote/

Django Version: 1.4.3
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'polls')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')

Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" 
in get_response
  111. response = callback(request, *callback_args, 
**callback_kwargs)
File "/home/mehmet/internet_projeleri/proje1/polls/views.py" in vote
  55. return HttpResponseRedirect(reverse('polls.views.results', 
args=(p.id,)))
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
in reverse
  476. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, 
*args, **kwargs))
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
in _reverse_with_prefix
  396. "arguments '%s' not found." % (lookup_view_s, args, 
kwargs))

Exception Type: NoReverseMatch at /polls/1/vote/
Exception Value: Reverse for 'polls.views.results' with arguments '(1,)' 
and keyword arguments '{}' not found.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.