Re: Calculations in Queries

2012-08-15 Thread Sandeep kaur
On Thu, Aug 16, 2012 at 2:31 AM, Callum Bonnyman  wrote:
> I am creating a popular page for my app and for the most part this is just
> to gain an understanding.

> Any ideas? I know its something to do with query expressions and looking at
> this page confuses the hell out of me. Any guidelines, or is this even
> achievable?
>
Why don't you use sessions for the same. That is, in a session find
number of clicks on the pages by a user, then save it in database.
Then just get the page that has maximum clicks, that will be the most
popular page.
Just a wild idea.

-- 
Sandeep Kaur
E-Mail: mkaurkha...@gmail.com
Blog: sandymadaan.wordpress.com

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Stuck on "ViewDoesNotExist" last step of tutorial part 4

2012-08-15 Thread Sky
I've moved the urls.py out of mysite as instructed by the tutorial into 
polls.

My polls/url.py

from django.conf.urls import patterns, include, url
from django.views.generic import DetailView, ListView
from polls.models import Poll

#Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
url(r'^$',
ListView.as_view(
queryset = Poll.objects.order_by('-pub_date')[:5],
context_object_name = 'latest_poll_list',
template_name = 'polls/index.html')),
url(r'^(?P\d+)/$',
DetailView.as_view(
model = Poll,
template_name = 'polls/detail.html')),
url(r'^(?P\d+)/results/$',
DetailView.as_view(
model = Poll,
template_name = 'polls/results.html'),
name='poll_results'),
url(r'^(?P\d+)/vote/$', 'polls.views.vote'),
)

urlpatterns = patterns('',
url(r'^polls/', include('polls.urls')),   
url(r'^admin/', include(admin.site.urls)),
)

# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

My polls/views.py

# Create your views here.
from django.shortcuts import render_to_response, get_object_or_404
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from django.template import RequestContext
from polls.models import Choice, Poll

def vote(request, poll_id):
p = get_object_or_404 (Poll, pk = poll_id)
try: 
selected_choice = p.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
return render_to_response('polls/detail.html', {
'poll': p,
'error_message': "You didn't select a choice.",
}, context_instance = RequestContext(request))
else:
selected_choice.votes += 1
selected_choice.save()
return HttpResponseRedirect(reverse('poll_results', args = (p.id,)))


On Thursday, August 16, 2012 11:53:12 AM UTC+8, Kurtis wrote:
>
> I just noticed another thing here. But, it could just be related to 
> copying and pasting your source here. See below
>
> On Tue, Aug 14, 2012 at 11:16 PM, Sky 
> > wrote:
>
>> I've having a similar problem here using Django 1.4 and I can't quite 
>> figure what's wrong. The error reads: Could not import polls.views.index. 
>> View does not exist in module polls.views.
>>
>> urls.py
>>
>> from django.conf.urls import patterns, include, url
>> from django.views.generic import DetailView, ListView
>> from polls.models import Poll
>>
>> Uncomment the next two lines to enable the admin:
>>
>
> So, first, add a # to the beginning of that line, to make it this:
> # Uncomment the next two lines to enable the admin:
>  
>
>> from django.contrib import admin
>> admin.autodiscover()
>>
>>
> Here, you're going to make a list of patterns. Nothing wrong with that.
>  
>
>> urlpatterns = patterns('',
>> url(r'^$',
>> ListView.as_view(
>> queryset = Poll.objects.order_by('-pub_date')[:5],
>> context_object_name = 'latest_poll_list',
>> template_name = 'polls/index.html')),
>> url(r'^(?P\d+)/$',
>> DetailView.as_view(
>> model = Poll,
>> template_name = 'polls/detail.html')),
>> url(r'^(?P\d+)/results/$',
>> DetailView.as_view(
>> model = Poll,
>> template_name = 'polls/results.html'),
>> name='poll_results'),
>> url(r'^(?P\d+)/vote/$', 'polls.views.vote'),
>> )
>>
>>
> Now, below, you've overridden the same URL patterns. (The previous list 
> should, hypothetically, be ignored at this point) This is actually reading 
> the urls.py file from your 'polls' module. I'm not sure if this is really 
> all in the same file or not. If it is, can you show us what's in your 
> polls/urls.py file?
>  
>
>> urlpatterns = patterns('',
>> url(r'^polls/', include('polls.urls')),
>> url(r'^admin/', include(admin.site.urls)),
>> )
>>
>> # Uncomment the admin/doc line below to enable admin documentation:
>> # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
>>
>> views.py
>> # Create your views here.
>> from django.shortcuts import render_to_response, get_object_or_404
>> from django.http import HttpResponseRedirect, HttpResponse
>> from django.core.urlresolvers import reverse
>> from django.template import RequestContext
>> from polls.models import Choice, Poll
>>
>> def vote(request, poll_id):
>> p = get_object_or_404 (Poll, pk = poll_id)
>> try:
>> selected_choice = 
>> p.choice_set.get(pk=request.POST['choice'])
>> except (KeyError, Choice.DoesNotExist):
>> return render_to_response('polls/detail.html', {
>> 'poll': p,
>> 'error_message': "You didn't select a choice.",
>> }, context_instance = RequestContext(request))
>> else:
>> selected_choice.votes += 1
>> s

Re: Auto login with external cookie from different system

2012-08-15 Thread Kurtis Mullins
On Wed, Aug 15, 2012 at 10:08 AM, Melvyn Sopacua wrote:

> ...
> Split does not work like you think it does:
> http://localhost/doc/python/library/stdtypes.html#str.split
> ...


Just wanted to clear one small thing up I saw :)
Not all of us host the Python docs, locally, haha.
I think the link you wanted to share was this:
http://docs.python.org/library/stdtypes.html#str.split

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Calculations in Queries

2012-08-15 Thread Kurtis Mullins
On Wed, Aug 15, 2012 at 8:51 PM, Callum Bonnyman wrote:

> I've tried a few things but i cannot get the correct date formats to
> calculate the difference, so far i have this:
>
> popular_posts = Post.objects.extra(select={
> 'popularity': '(' + datetime.datetime.now() + ' - created) * views'
> })
>
It shows an error, i've tried googling it but not had much luck so far


Where error are you getting?

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Stuck on "ViewDoesNotExist" last step of tutorial part 4

2012-08-15 Thread Kurtis Mullins
I just noticed another thing here. But, it could just be related to copying
and pasting your source here. See below

On Tue, Aug 14, 2012 at 11:16 PM, Sky  wrote:

> I've having a similar problem here using Django 1.4 and I can't quite
> figure what's wrong. The error reads: Could not import polls.views.index.
> View does not exist in module polls.views.
>
> urls.py
>
> from django.conf.urls import patterns, include, url
> from django.views.generic import DetailView, ListView
> from polls.models import Poll
>
> Uncomment the next two lines to enable the admin:
>

So, first, add a # to the beginning of that line, to make it this:
# Uncomment the next two lines to enable the admin:


> from django.contrib import admin
> admin.autodiscover()
>
>
Here, you're going to make a list of patterns. Nothing wrong with that.


> urlpatterns = patterns('',
> url(r'^$',
> ListView.as_view(
> queryset = Poll.objects.order_by('-pub_date')[:5],
> context_object_name = 'latest_poll_list',
> template_name = 'polls/index.html')),
> url(r'^(?P\d+)/$',
> DetailView.as_view(
> model = Poll,
> template_name = 'polls/detail.html')),
> url(r'^(?P\d+)/results/$',
> DetailView.as_view(
> model = Poll,
> template_name = 'polls/results.html'),
> name='poll_results'),
> url(r'^(?P\d+)/vote/$', 'polls.views.vote'),
> )
>
>
Now, below, you've overridden the same URL patterns. (The previous list
should, hypothetically, be ignored at this point) This is actually reading
the urls.py file from your 'polls' module. I'm not sure if this is really
all in the same file or not. If it is, can you show us what's in your
polls/urls.py file?


> urlpatterns = patterns('',
> url(r'^polls/', include('polls.urls')),
> url(r'^admin/', include(admin.site.urls)),
> )
>
> # Uncomment the admin/doc line below to enable admin documentation:
> # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
> views.py
> # Create your views here.
> from django.shortcuts import render_to_response, get_object_or_404
> from django.http import HttpResponseRedirect, HttpResponse
> from django.core.urlresolvers import reverse
> from django.template import RequestContext
> from polls.models import Choice, Poll
>
> def vote(request, poll_id):
> p = get_object_or_404 (Poll, pk = poll_id)
> try:
> selected_choice =
> p.choice_set.get(pk=request.POST['choice'])
> except (KeyError, Choice.DoesNotExist):
> return render_to_response('polls/detail.html', {
> 'poll': p,
> 'error_message': "You didn't select a choice.",
> }, context_instance = RequestContext(request))
> else:
> selected_choice.votes += 1
> selected_choice.save()
> return HttpResponseRedirect(reverse('poll_results', args =
> (p.id,)))
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/bWqxut6y_YgJ.
> 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.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 回复: Stuck on "ViewDoesNotExist" last step of tutorial part 4

2012-08-15 Thread Sky
Oh, and it works when the url is http://localhost:8000/polls/1/vote/

On Thursday, August 16, 2012 11:19:09 AM UTC+8, Sky wrote:
>
> I'm pretty sure the source is the same as I copied it out from the editor. 
> I'm using sqlite3, not sure if that affects anything. I'm not sure what's 
> wrong as I got the code straight from the tutorial.
>
> The traceback:
>
>
>- 
>
> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/handlers/base.py
> in get_response
>1. 
>   
>   request.path_info)
>   
>   ...
>▶ Local vars 
>- 
>
> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py
> in resolve
>1. 
>   
>   sub_match = pattern.resolve(new_path)
>   
>   ...
>▶ Local vars 
>- 
>
> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py
> in resolve
>1. 
>   
>   return ResolverMatch(self.callback, args, kwargs, self.name)
>   
>   ...
>▶ Local vars 
>- 
>
> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py
> in callback
>1. 
>   
>   self._callback = get_callable(self._callback_str)
>   
>   ...
>▶ Local vars 
>- 
>
> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/functional.py
> in wrapper
>1. 
>   
>   result = func(*args)
>   
>   ...
>▶ Local vars 
>- 
>
> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py
> in get_callable
>1. 
>   
>   (lookup_view, mod_name))
>   
>   ...
>▶ Local vars 
>
>
> On Thursday, August 16, 2012 11:03:27 AM UTC+8, Kurtis wrote:
>>
>> This line should be commented out: "Uncomment the next two lines to 
>> enable the admin:"
>>
>> Also, I don't see why it's trying to import 'polls.views.index'. That 
>> would be a function named 'index' in your views.py file in the polls 
>> directory (also known as a module). Not only does that 'index' 
>> method/function not exist, I don't see anywhere in your urls.py that 
>> indicates you are trying to load or otherwise reference that method.
>>
>> So as Melvyn implied, are you sure this source code you presented is 
>> exactly the same as you're trying to run? I think he assumed you were using 
>> a WSGI Handler -- but runserver should pick up any changes that you make up 
>> to the structure automatically.
>>
>> Can you share the traceback that your web browser shows when you try to 
>> access your Django application? Just make sure to hide any 
>> private/sensetive data:
>> http://localhost:8000 after executing 'python manage.py runserver'
>>
>> On Wed, Aug 15, 2012 at 10:45 PM, Sky  wrote:
>>
>>> How do I do that? 
>>>
>>> I've tried the commands python manage.py syncdb followed by python 
>>> manage.py runserver several times but they don't work.
>>>
>>>
>>> On Wednesday, August 15, 2012 9:45:21 PM UTC+8, Melvyn Sopacua wrote:

 On 15-8-2012 10:01, Pengfei Xue wrote: 
 > there's no function in views.py, you should define that 'index' 
 > handler 

 No, he's not using it according to source. 
 Which means the source is not in sync with what is being run, typically 
 fixed by restarting the WSGI provider. 

 -- 
 Melvyn Sopacua 

>>>  -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msg/django-users/-/VTBxdWtZXTYJ.
>>>
>>> To post to this group, send email to django...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> django-users...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/iMjF3xXQia8J.
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 回复: Stuck on "ViewDoesNotExist" last step of tutorial part 4

2012-08-15 Thread Sky
I'm pretty sure the source is the same as I copied it out from the editor. 
I'm using sqlite3, not sure if that affects anything. I'm not sure what's 
wrong as I got the code straight from the tutorial.

The traceback:


   - 
   
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/handlers/base.py
in get_response
   1. 
  
  request.path_info)
  
  ...
   ▶ Local vars 
   - 
   
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py
in resolve
   1. 
  
  sub_match = pattern.resolve(new_path)
  
  ...
   ▶ Local vars 
   - 
   
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py
in resolve
   1. 
  
  return ResolverMatch(self.callback, args, kwargs, self.name)
  
  ...
   ▶ Local vars 
   - 
   
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py
in callback
   1. 
  
  self._callback = get_callable(self._callback_str)
  
  ...
   ▶ Local vars 
   - 
   
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/functional.py
in wrapper
   1. 
  
  result = func(*args)
  
  ...
   ▶ Local vars 
   - 
   
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py
in get_callable
   1. 
  
  (lookup_view, mod_name))
  
  ...
   ▶ Local vars 
   

On Thursday, August 16, 2012 11:03:27 AM UTC+8, Kurtis wrote:
>
> This line should be commented out: "Uncomment the next two lines to 
> enable the admin:"
>
> Also, I don't see why it's trying to import 'polls.views.index'. That 
> would be a function named 'index' in your views.py file in the polls 
> directory (also known as a module). Not only does that 'index' 
> method/function not exist, I don't see anywhere in your urls.py that 
> indicates you are trying to load or otherwise reference that method.
>
> So as Melvyn implied, are you sure this source code you presented is 
> exactly the same as you're trying to run? I think he assumed you were using 
> a WSGI Handler -- but runserver should pick up any changes that you make up 
> to the structure automatically.
>
> Can you share the traceback that your web browser shows when you try to 
> access your Django application? Just make sure to hide any 
> private/sensetive data:
> http://localhost:8000 after executing 'python manage.py runserver'
>
> On Wed, Aug 15, 2012 at 10:45 PM, Sky 
> > wrote:
>
>> How do I do that? 
>>
>> I've tried the commands python manage.py syncdb followed by python 
>> manage.py runserver several times but they don't work.
>>
>>
>> On Wednesday, August 15, 2012 9:45:21 PM UTC+8, Melvyn Sopacua wrote:
>>>
>>> On 15-8-2012 10:01, Pengfei Xue wrote: 
>>> > there's no function in views.py, you should define that 'index' 
>>> > handler 
>>>
>>> No, he's not using it according to source. 
>>> Which means the source is not in sync with what is being run, typically 
>>> fixed by restarting the WSGI provider. 
>>>
>>> -- 
>>> Melvyn Sopacua 
>>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/VTBxdWtZXTYJ.
>>
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/SO7EV_TvGKQJ.
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 回复: Stuck on "ViewDoesNotExist" last step of tutorial part 4

2012-08-15 Thread Kurtis Mullins
This line should be commented out: "Uncomment the next two lines to enable
the admin:"

Also, I don't see why it's trying to import 'polls.views.index'. That would
be a function named 'index' in your views.py file in the polls directory
(also known as a module). Not only does that 'index' method/function not
exist, I don't see anywhere in your urls.py that indicates you are trying
to load or otherwise reference that method.

So as Melvyn implied, are you sure this source code you presented is
exactly the same as you're trying to run? I think he assumed you were using
a WSGI Handler -- but runserver should pick up any changes that you make up
to the structure automatically.

Can you share the traceback that your web browser shows when you try to
access your Django application? Just make sure to hide any
private/sensetive data:
http://localhost:8000 after executing 'python manage.py runserver'

On Wed, Aug 15, 2012 at 10:45 PM, Sky  wrote:

> How do I do that?
>
> I've tried the commands python manage.py syncdb followed by python
> manage.py runserver several times but they don't work.
>
>
> On Wednesday, August 15, 2012 9:45:21 PM UTC+8, Melvyn Sopacua wrote:
>>
>> On 15-8-2012 10:01, Pengfei Xue wrote:
>> > there's no function in views.py, you should define that 'index'
>> > handler
>>
>> No, he's not using it according to source.
>> Which means the source is not in sync with what is being run, typically
>> fixed by restarting the WSGI provider.
>>
>> --
>> Melvyn Sopacua
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/VTBxdWtZXTYJ.
>
> 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.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 回复: Stuck on "ViewDoesNotExist" last step of tutorial part 4

2012-08-15 Thread Sky
How do I do that? 

I've tried the commands python manage.py syncdb followed by python 
manage.py runserver several times but they don't work.

On Wednesday, August 15, 2012 9:45:21 PM UTC+8, Melvyn Sopacua wrote:
>
> On 15-8-2012 10:01, Pengfei Xue wrote: 
> > there's no function in views.py, you should define that 'index' 
> > handler 
>
> No, he's not using it according to source. 
> Which means the source is not in sync with what is being run, typically 
> fixed by restarting the WSGI provider. 
>
> -- 
> Melvyn Sopacua 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/VTBxdWtZXTYJ.
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Where to place Context

2012-08-15 Thread Gregory Strydom
Thanks very much, i have been confused about this for awhile but can now 
see much clearer!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/WXD7UoocVSIJ.
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Where to place Context

2012-08-15 Thread Melvyn Sopacua
On 16-8-2012 2:33, Gregory Strydom wrote:
> Hi all , great to be here.

Welcome.

> I just have a very simple question if thats ok. I am quite new to Django 
> but am enjoying it very much, but seem to be struggling with templates.  Im 
> sure this is a simple question but could anyone please tell me where do you 
> place context that you define for your templates?

It's covered in the tutorial quite extensively:


For class-based views:



Also mentioned in the tutorial:



-- 
Melvyn Sopacua

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Calculations in Queries

2012-08-15 Thread Callum Bonnyman
I've tried a few things but i cannot get the correct date formats to 
calculate the difference, so far i have this: 

popular_posts = Post.objects.extra(select={
'popularity': '(' + datetime.datetime.now() + ' - created) * views'
})

It shows an error, i've tried googling it but not had much luck so far

On Thursday, 16 August 2012 00:59:39 UTC+1, Melvyn Sopacua wrote:
>
> On 15-8-2012 23:01, Callum Bonnyman wrote: 
> > 
> > 
> > I am creating a popular page for my app and for the most part this is 
> just 
> > to gain an understanding. 
> > 
> > The idea is to divide the number of views by the days old, now i don't 
> know 
> > if this will be successful or even working but like I said its go get an 
> > idea of how queries work... 
> > 
> > My fields are named: views and created. Below is an idea of what I'm 
> > thinking of. 
> > 
> > (now - created) / views 
> You probably want views / (now - created) which means the average number 
> of views over time. Your function above calculates the average time 
> between views. 
>
> > popular_posts = Post.objects.all().order_by('-id')[:50] 
>
> The problem isn't the calculation. The problem is that you want the 
> result of the calculation and the ability to sort with it. If you want 
> to keep this independent of the database backend I highly suggest you 
> calculate the value in python and store it in the database. 
>
> Otherwise, I don't see a way to avoid using the extra method: 
>  
>
> -- 
> Melvyn Sopacua 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/rrf6cN7n3oYJ.
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Where to place Context

2012-08-15 Thread Gregory Strydom
Hi all , great to be here.

I just have a very simple question if thats ok. I am quite new to Django 
but am enjoying it very much, but seem to be struggling with templates.  Im 
sure this is a simple question but could anyone please tell me where do you 
place context that you define for your templates? Ive done quite a few 
searches on a google but cant seem to to find the answer im looking for 
even though im sure its right in front of my eyes. For example with a 
"home_page" html template, wher exactly do i place the the context 
variables that will be displayed, eg: c = learner_firstname etc... 
Hopefully someone will be able to help out and i really appreciate it!

thanks alot.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/s6hRrx1YuIEJ.
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Calculations in Queries

2012-08-15 Thread Melvyn Sopacua
On 15-8-2012 23:01, Callum Bonnyman wrote:
> 
> 
> I am creating a popular page for my app and for the most part this is just 
> to gain an understanding.
> 
> The idea is to divide the number of views by the days old, now i don't know 
> if this will be successful or even working but like I said its go get an 
> idea of how queries work...
> 
> My fields are named: views and created. Below is an idea of what I'm 
> thinking of.
> 
> (now - created) / views
You probably want views / (now - created) which means the average number
of views over time. Your function above calculates the average time
between views.

> popular_posts = Post.objects.all().order_by('-id')[:50]

The problem isn't the calculation. The problem is that you want the
result of the calculation and the ability to sort with it. If you want
to keep this independent of the database backend I highly suggest you
calculate the value in python and store it in the database.

Otherwise, I don't see a way to avoid using the extra method:


-- 
Melvyn Sopacua

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: blocktrans inside a with tag

2012-08-15 Thread Melvyn Sopacua
On 15-8-2012 19:27, ernando wrote:

> I just checked provided code - and it works ok (1.4 Django). Are u using 
> the latest version or 1.3 one?

Actually, my reply was a bit in a hurry cause I was on my way out. The
dollar sign means nothing to python or django templates, so it is just
raw text. Just to make sure no one thinks from my reading my reply that
dollar signs formats stuff as monetary ;)

On the OP's problem: make sure your translation file kept the format
string. The block will end up as:
#, python-format
msgid "Blah Blah $%(val)"
msgstr "..."

-- 
Melvyn Sopacua

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Calculations in Queries

2012-08-15 Thread Callum Bonnyman


I am creating a popular page for my app and for the most part this is just 
to gain an understanding.

The idea is to divide the number of views by the days old, now i don't know 
if this will be successful or even working but like I said its go get an 
idea of how queries work...

My fields are named: views and created. Below is an idea of what I'm 
thinking of.

(now - created) / views


For my view I have:

def popular(request):

popular_posts = Post.objects.all().order_by('-id')[:50]

return render_to_response(

'posts/popular.html', 

{'popular_posts': popular_posts}, 

)

Obviously that just gets all the objects ordered by id. Is there a way to 
achieve something similar to what I'm looking for without going into loads 
of complex code?

Any ideas? I know its something to do with query expressions and looking at 
this 
page
 confuses 
the hell out of me. Any guidelines, or is this even achievable?


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/gWzK1UJfkfIJ.
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: join models on Timestamp field without foreign keys

2012-08-15 Thread Jeff Dickens


On Tuesday, August 14, 2012 1:43:18 PM UTC-4, Dennis Lee Bieber wrote:
>
> On Mon, 13 Aug 2012 21:58:59 -0700 (PDT), Jeff Dickens 
> > declaimed the following in 
> gmane.comp.python.django.user: 
>
> > Hi all.  I have a number of models, each of which is based on an 
> abstract 
> > class that includes a Timestamp field.  The model definitions look like 
> > this: 
> > 
> > class Md_model(models.Model): 
> > Timestamp = 
> > models.DateTimeField(auto_now_add=True,unique=True,db_index=True) 
> > def __unicode__(self): 
> > return self.Timestamp.strftime('%Y %m %d %H:%M') 
> > def as_dict(self): 
> > return(model_to_dict(self)) 
> > class Meta: 
> > abstract = True 
> > 
> > class md_10_1(Md_model): 
> > name='md_10_1' 
> > dataSource = 'http://192.168.0.10/auto/001' 
> > n1 = models.DecimalField(max_digits=10,decimal_places=3) 
> > n2 = models.DecimalField(max_digits=10,decimal_places=3) 
> > n3 = models.DecimalField(max_digits=10,decimal_places=3) 
> > 
> > class md_10_2(Md_model): 
> > name='md_10_2' 
> > dataSource = 'http://192.168.0.10/auto/002' 
> > n4 = models.DecimalField(max_digits=10,decimal_places=3) 
> > n5 = models.DecimalField(max_digits=10,decimal_places=3) 
> > 
> This example makes me think the design is faulty... Especially if 
> you mean you have more tables than just the two... 
>

It's not.  Read on... 

>
> Though I think better in SQL -- are "name" and "dataSource" items 
> that would be stored in the database? Right now, all they seem to do is 
> duplicate information as to which "model" the record represents. 
>

No, they are not items that are stored in the database.  They exist because 
the script that populates the table (every minute) is generalized to handle 
an unlimited number of data models. It uses introspection for everything - 
as DRY as it can possibly be.  Otherwise it would very quickly become 
unmanageable.

>
> Given just your example I'd probably have created just one table 
> containing all of n1..n5, with option to permit Null values, and coded 
> to do INSERT if the timestamp didn't exist, and UPDATE if the timestamp 
> was already in the table. 
>
> There are now 8 data models and I have to be able to add more over time 
without having to reprocess the (voluminous) data that has been logged into 
the existing models.
 

> If you do mean you have half a dozen or more all similar I'd try 
> to 
> isolate back to the form that would support the most... If all the data 
> fields are identical (all 10.3 decimal) say... (Again, I'm going to use 
> pseudo SQL) 
>
> create table Sources 
> ( 
> IDinteger auto increment primary key, 
> timestampdatetime, 
> sourcechar(80),#whatever length you need 
> modelchar(20)#ditto 
> ); 
>
> create table Fields 
> ( 
> ID integer auto increment primary key, 
> sourceID integer foreign key Source (ID), 
> fieldID integer, 
> fieldValuedecimal 
> ) 
>
> These wouldn't fit as regular Django form without a lot of 
> logic... 
> Instead of /n/ tables looking like 
>
> timestampn1n2n3 ... 
>
> you'd have 
>
> 1timestamphttp://... 
> 2timestamphttp://... 
>
> and 
>
> 111value 
> 212value 
> 313value 
> 421value 
> 522value 
> ... 
>
> This schema allows for any number of identical datatype values per 
> "record", but putting them /into/ record order requires looping over the 
> result set. 
>
>
>
> > 
> > What I want to do is join them all (actually some programatically 
> defined 
> > subset of them) into a single query set or some other data structure 
> that I 
> > can pass into the template.  This set would have only one Timestamp 
> field, 
> > and all of the other fields from all of the other models that are to be 
> > joined.  She thre result would have Timestamp, n1, n2, n3, n4, n5 in the 
> > example above, 
>
> INNER, LEFT OUTER, or RIGHT OUTER; if you needed both OUTER 
> conditions in one result set you'd have to run a UNION wrapped by a 
> SELECT DISTINCT 
>
> Raw SQL might look like 
>
> select distinct * from 
> (select md_10_1.timestamp as tstamp, n1, ..., n5 from md_10_1 
> left join md_10_2 on md_10_1.timestamp = md_10_2.timestamp 
> union 
>  select md_10_2.timestamp as tstamp, n1, ..., n5 from md_10_1 
> right join md_10_2 on md_10_1.timestamp = 
> md_10_2.timestamp) 
> where tstamp > starttime and tstamp < endtime 
> order by tstamp 
>
> {If the DBMS doesn't implement RIGHT JOIN make it a LEFT and swap the 
> table order around the clause} 
> -- 
> Wulfraed Dennis Lee Bieber AF6VN 
> wlf...@i

Re: UnicodeDecodeError with non ascii app_label

2012-08-15 Thread vitalije

Just in case someone else run in the same problem, I have found a solution. 
It is explained here: https://code.djangoproject.com/ticket/17566

HTH Vitalije

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/YyZuhMPJcNIJ.
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: blocktrans inside a with tag

2012-08-15 Thread dipo . elegbede
H 
Sent from my BlackBerry wireless device from MTN

-Original Message-
From: ernando 
Sender: django-users@googlegroups.com
Date: Wed, 15 Aug 2012 10:27:30 
To: 
Reply-To: django-users@googlegroups.com
Subject: Re: blocktrans inside a with tag

Sorry, didn't catch it :)

I just checked provided code - and it works ok (1.4 Django). Are u using 
the latest version or 1.3 one?

-Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/vqf-i_qCXI0J.
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: blocktrans inside a with tag

2012-08-15 Thread ernando
Sorry, didn't catch it :)

I just checked provided code - and it works ok (1.4 Django). Are u using 
the latest version or 1.3 one?

-Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/vqf-i_qCXI0J.
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



read only datatime field with a custom admin

2012-08-15 Thread brian downing

How do I create a read only datatime field with a custom admin?


Here is the psudo code from what I've done:

-

class myAdminForm(forms.ModelForm):

def __init__(self, *args, **kwargs):

   super(myAdminForm, self).__init__(*args, **kwargs)

...

self.fields['Created_date'].widget.attrs['readonly'] = 'readonly'

...

class myAdmin(admin.ModelAdmin):

...

change_form_template= 'my_change_form_admin.html'

form = myAdminForm

...

#readonly_fields = ['Created_date', 'Modified_date']

usrAdminSite.register(myMdl, myAdmin)

-


For 'my_change_form_admin.html' I've started with the admins 
'change_form.html' and tweaked it. Since I want to access the individual 
fields I've removed:


-

{% for fieldset in adminform %}
{% include "admin/includes/fieldset.html" %}
{% endfor %}

--

and replaced it with code like 'adminform.form.Created_date'.


This worked fine till I tried to give 'Created_date' a read only 
attribute. In myAdmin if I add  
then 'adminform.form.Created_date' no longer exists.



Next in 'myAdminForm' I added 
 but 
this seems to be ignored. I also tried 
 with the 
same effect.




How should I create a read only datatime field?  I'm using Django 1.3.


Brian

--
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



transaction.rollback() raises an exception when my transactions fail due losing connection to oracle. How to handle?

2012-08-15 Thread Matthew Lauber
All,
I've got an issue with a flakey connection between my oracle database 
and my webserver.   We run a background merge process, managed by django.  
Every so often, the database connection will go down with an ORACLE-03113 
error, "Received end-of-file on communication channel.  This is occurring 
during a transaction.commit_manually decorated function.  So over all my 
code looks like this.

@transaction.commit_manually
def function():
try:
transaction.set_dirty()
... raw SQL queries here  <-- The exception occurs here 
transaction.commit()
except Exception e:
transaction.rollback()

The issue is that after the ORACLE-03113 error, I've lost connection to the 
database, so transaction.rollback() raises an ORACLE-03114 error "not 
connected to ORACLE".  And I expect that if I just catch and silence the 
transaction.rollback() failure, I'll get a TransactionManagementError since 
the transaction was not (and cannot be) successfully rolled back.

Is there a proper way of handling this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/05q9lzzbQZUJ.
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: blocktrans inside a with tag

2012-08-15 Thread Melvyn Sopacua
On 15-8-2012 16:26, ernando wrote:
> I really didn't try to use  blocktrans and with tags together but why do 
> use val variable value with $ sign? Try just {{val}} one - it works ok for 
> me.
Because it's a monetary ammount?

-- 
Melvyn Sopacua

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: What is the easy way to install DJango?

2012-08-15 Thread Vibhu Rishi
Hi, 

If you are new to Django and are just getting around to learn it, I 
recommend using BitNami Django stack for windows.
http://bitnami.org/stack/djangostack 

So far, it has been the easiest to install on the windows machine.

Vibhu

On Wednesday, 15 August 2012 14:06:33 UTC+5:30, Thato wrote:
>
> Hi guys I want to install Django on my windows computer please help me the 
> easy way to install Django frame work.
>
> Regards
> AbcThato
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/70BcZ0yFvWMJ.
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: blocktrans inside a with tag

2012-08-15 Thread ernando
I really didn't try to use  blocktrans and with tags together but why do 
use val variable value with $ sign? Try just {{val}} one - it works ok for 
me.

- Dmitry

On Tuesday, August 14, 2012 2:41:16 AM UTC+3, Jason Buckner wrote:
>
> I would like to use a blocktrans tag inside a with tag so I can 
> dynamically pass values to multiple blocktrans blocks. For instance:
>
> {% with cost="250" %}
> {% blocktrans with val=cost %} Blah blah ${{val}} {% endblocktrans %}
> .
> .
> .
> {% blocktrans with val=cost %} Blah blah ${{val}} {% endblocktrans %}
> {% endwith %}
>
> This produces empty {{ val }} values.
>
> Is this possible?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/VYH7wEGrMyUJ.
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Auto login with external cookie from different system

2012-08-15 Thread Melvyn Sopacua
On 15-8-2012 13:04, Tomas Jacobsen wrote:
> Hello
> 
> I'm trying to write a custom backed for login in users from an
> external encrypted cookie.
> 
> I have done it in PHP, but I'm trying to convert it to python/django
> logic, but this is most advanced python code I have tried to write! I
> have found some basic examples to look at, but none of them do the
> things I need (decrypt cookie)
> 
> Could anyone look over my code and tell me if I'm on the right path,
> or is there to much PHP thinking in my code?
> 
> Here is my python code: http://dpaste.org/ZDKIj/

This is a bit puzzling:
 if not hasattr(request, 'user'): raise ImproperlyConfigured()

You're the one providing the user on the request, so why would this
check be here?

try without except is a waste of a try. Exceptions are always raised,
try isn't something you use to activate exception handling.

Split does not work like you think it does:
http://localhost/doc/python/library/stdtypes.html#str.split

What you're looking for:
from base64 import b64_decode
self.secret, self.hashstring, self.userID = b64_decode(
token).split('-', 2)

hashlib.sha1(settings.SHARED_SECRET == self.secret.lower())
This computes the hash of a boolean.

On the whole: take the advice of the python docs library reference:
"keep this under your pillow"

-- 
Melvyn Sopacua

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: New to dj: relational limitations

2012-08-15 Thread Tomas Neme
> On Tue, Aug 14, 2012 at 8:49 PM, Russell Keith-Magee 
>  wrote:

I'm just glad I didn't come back with a half-assed response


--
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 回复: Stuck on "ViewDoesNotExist" last step of tutorial part 4

2012-08-15 Thread Melvyn Sopacua
On 15-8-2012 10:01, Pengfei Xue wrote:
> there's no function in views.py, you should define that 'index'
> handler

No, he's not using it according to source.
Which means the source is not in sync with what is being run, typically
fixed by restarting the WSGI provider.

-- 
Melvyn Sopacua

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: What is the easy way to install DJango?

2012-08-15 Thread baldyeti

Thato Aphane wrote, On 2012-08-15 15:06:

I have downloaded Django now where do I unzip it/ In which path?


Wherever you want - that'll just be a temporary working directory
used during the install; afterwards the setup tools will copy
the django files under your site-packages
(the work directory can thus be deleted after installation)


--
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Prevent sorting in admin

2012-08-15 Thread Timster
Picture the following model and admin:

class Section(models.Model):
position = models.PositiveIntegerField(editable=False)
title = models.CharField(max_length=200)

class SectionAdmin(admin.ModelAdmin):
list_display = ['title']
ordering = [ 'position']

The position is a column that will be automatically populated. This column 
is not editable and will not show up in the admin list display.

However, I would like to prevent the admin page from being able to sort on 
any other column. The column headers need to not be clickable and 
sort-able. 

Is there any easy way to do this?

I have dug around the docs and looked through the source a good bit, but 
couldn't find any straight-forward way of accomplishing this without 
heavily customizing the admin app.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/hcDCJEs8IfcJ.
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: What is the easy way to install DJango?

2012-08-15 Thread Thato Aphane
I have downloaded Django now where do I unzip it/ In which path?



On Wed, Aug 15, 2012 at 3:00 PM, Jirka Vejrazka wrote:

> It's easy to install Django on a Windows machine to test it out and
> develop code. Most of this is covered here:
> https://docs.djangoproject.com/en/1.4/topics/install/
>
> In a nutshell, you need:
> - Python 2.x (2.7) - install it if you already have not done so
> - Django (start with a stable release e.g. 1.4, download link on the
> main Django page)
> - to install the downloaded Django package (covered in docs)
> - to find your "django-admin.py" (most likely in C:\Python27\Scripts)
> and use it to create your first project.
> - follow the official tutorial to learn the basics
>
> https://docs.djangoproject.com/en/1.4/intro/tutorial01/
>
>   It's pretty straightforward, most people have trouble locating the
> django-admin.py which is not on system PATH by default.
>
>  HTH
>
>Jirka
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
**
*

   - Kind Regards

*
*

   - Thato

*
*

   - Cell: 076 381 8106

**

***
**

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: What is the easy way to install DJango?

2012-08-15 Thread Jirka Vejrazka
It's easy to install Django on a Windows machine to test it out and
develop code. Most of this is covered here:
https://docs.djangoproject.com/en/1.4/topics/install/

In a nutshell, you need:
- Python 2.x (2.7) - install it if you already have not done so
- Django (start with a stable release e.g. 1.4, download link on the
main Django page)
- to install the downloaded Django package (covered in docs)
- to find your "django-admin.py" (most likely in C:\Python27\Scripts)
and use it to create your first project.
- follow the official tutorial to learn the basics

https://docs.djangoproject.com/en/1.4/intro/tutorial01/

  It's pretty straightforward, most people have trouble locating the
django-admin.py which is not on system PATH by default.

 HTH

   Jirka

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: What is the easy way to install DJango?

2012-08-15 Thread baldyeti

You'll need the python interpreter first 
then 'pip install django' should give you the latest release

(pip.exe lives under the Scripts subdirectory of your python install,
which I think recent installers should add to you PATH automatically)

Other than that I see nothing wrong with the offcial instructions at
https://docs.djangoproject.com/en/dev/intro/install/

have fun!

AbcThato wrote, On 2012-08-15 10:36:

Hi guys I want to install Django on my windows computer please help me
the easy way to install Django frame work.

Regards
AbcThato

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/PoU8-G3WVzoJ.
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.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.



--
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: What is the easy way to install DJango?

2012-08-15 Thread Thomas Guettler

Am 15.08.2012 10:36, schrieb AbcThato:

Hi guys I want to install Django on my windows computer please help me the easy 
way to install Django frame work.

Regards
AbcThato


Where do you want to deploy your app if you have written some code? Most 
Hosting environments use
Linux. That's why I would use Linux for development, too. You can use a virtual 
machine.

HTH,
  Thomas

--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

--
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: New to dj: relational limitations

2012-08-15 Thread Axel Rau

Am 15.08.2012 um 01:49 schrieb Russell Keith-Magee:

> This SQL "Standard" of which you speak… do you know of anyone that
> implements it? :-)
Yes. Look here:
http://www.postgresql.org/docs/9.1/static/features.html
At a minimum, I expect such a conformance list from a vendor.
> 
> Python code. Python doesn't have a concept of an enumerated type, so
> there hasn't been a whole lot of effort focussed on that feature.
I will try the enumField from Jonathan S. Katz:
https://github.com/jkatz/django_postgres_extensions
>> but the real stopper was that dj does not support NULL on TEXT columns.
> 
> Incorrect. At a model level, you can certainly store NULL in a
> TextField column (or any other char-like column for that matter).
Good to know.

> This could be addressed at the form level, but it will involve a
> little bit of tinkering (specifically, overriding the to_python method
> on django.forms.CharField). However, once you've written a CharField
> that treats blanks the way you want, you just need to remember to use
> your own form library rather than Django's defaults.
Ah, that the pointer, I looked for.
> 
> So - the fact that you have a database with a bunch of pre-existing
> expectations is going to cause you some difficulties, but they
> shouldn't be impossible to overcome. You are, however, going to be
> spending some quality time overriding defaults, and getting to know
> Django's internals pretty well. :-)
I will try and with the help of this list hopefully finally succeed. (-;

Thanks, Axel
---
PGP-Key:29E99DD6  ☀ +49 151 2300 9283  ☀ computing @ chaos claudius

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: NoReverseMatch Error

2012-08-15 Thread Karen Tracey
On Tue, Aug 14, 2012 at 10:46 AM, Serge G. Spaolonzi wrote:

> Try removing the quotes from 'polls.views.vote':
>
> 
>
>
>
Note that will work for 1.4 but it's doing things the old way, and that
will break in 1.5. Much better to add {% import url from future %} and have
code that will continue to work with the next release of Django. Removing
the quotes is not the best approach at this time.

Karen
-- 
http://tracey.org/kmt/

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Auto login with external cookie from different system

2012-08-15 Thread Tomas Jacobsen
Hello

I'm trying to write a custom backed for login in users from an external 
encrypted cookie.

I have done it in PHP, but I'm trying to convert it to python/django logic, but 
this is most advanced python code I have tried to write! I have found some 
basic examples to look at, but none of them do the things I need (decrypt 
cookie)

Could anyone look over my code and tell me if I'm on the right path, or is 
there to much PHP thinking in my code?

Here is my python code: http://dpaste.org/ZDKIj/

Here is my working PHP code I'm trying to convert: http://dpaste.org/7aibK/


Thank you!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/6BKHgbZzOgoJ.
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



What is the easy way to install DJango?

2012-08-15 Thread AbcThato
Hi guys I want to install Django on my windows computer please help me the 
easy way to install Django frame work.

Regards
AbcThato

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/PoU8-G3WVzoJ.
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 'bool' object has no attribute 'render'

2012-08-15 Thread Alexis Roda

Al 15/08/12 02:59, En/na yao ge ha escrit:

class NewsAdmin(admin.ModelAdmin):
 list_display = ('title','newstype','newsdate',)
 search_fields=('title',)
 list_filter =('newstype',)
 delete_selected_confirmation_template = True
 raw_id_fields = ('rateperson','ratetvplay',)
admin.site.register(News,NewsAdmin)


Why??



https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#custom-template-options

 ModelAdmin.delete_selected_confirmation_template
New in Django 1.2: Please see the release notes

Path to a custom template, ...


HTH

--
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



回复: Stuck on "ViewDoesNotExist" last step of tutorial part 4

2012-08-15 Thread Pengfei Xue
there's no function in views.py, you should define that 'index' handler

--  
Sincerely,
Pengfei Xue





已使用 Sparrow (http://www.sparrowmailapp.com/?sig)

已使用 Sparrow (http://www.sparrowmailapp.com/?sig)  

在 2012年8月15日星期三,上午11:16,Sky 写道:

> I've having a similar problem here using Django 1.4 and I can't quite figure 
> what's wrong. The error reads: Could not import polls.views.index. View does 
> not exist in module polls.views.
>  
> urls.py
>  
> from django.conf.urls import patterns, include, url
> from django.views.generic import DetailView, ListView
> from polls.models import Poll
>  
> Uncomment the next two lines to enable the admin:
> from django.contrib import admin
> admin.autodiscover()
>  
> urlpatterns = patterns('',
> url(r'^$',
> ListView.as_view(
> queryset = Poll.objects.order_by('-pub_date')[:5],
> context_object_name = 'latest_poll_list',
> template_name = 'polls/index.html')),
> url(r'^(?P\d+)/$',
> DetailView.as_view(
> model = Poll,
> template_name = 'polls/detail.html')),
> url(r'^(?P\d+)/results/$',
> DetailView.as_view(
> model = Poll,
> template_name = 'polls/results.html'),
> name='poll_results'),
> url(r'^(?P\d+)/vote/$', 'polls.views.vote'),
> )
>  
> urlpatterns = patterns('',
> url(r'^polls/', include('polls.urls')),  
> url(r'^admin/', include(admin.site.urls)),
> )
>  
> # Uncomment the admin/doc line below to enable admin documentation:
> # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
>  
> views.py
> # Create your views here.
> from django.shortcuts import render_to_response, get_object_or_404
> from django.http import HttpResponseRedirect, HttpResponse
> from django.core.urlresolvers import reverse
> from django.template import RequestContext
> from polls.models import Choice, Poll
>  
> def vote(request, poll_id):
> p = get_object_or_404 (Poll, pk = poll_id)
> try:  
> selected_choice = p.choice_set.get(pk=request.POST['choice'])
> except (KeyError, Choice.DoesNotExist):
> return render_to_response('polls/detail.html', {
> 'poll': p,
> 'error_message': "You didn't select a choice.",
> }, context_instance = RequestContext(request))
> else:
> selected_choice.votes += 1
> selected_choice.save()
> return HttpResponseRedirect(reverse('poll_results', args = (p.id,)))
>  
>  
> --  
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/bWqxut6y_YgJ.
> To post to this group, send email to django-users@googlegroups.com 
> (mailto:django-users@googlegroups.com).
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com 
> (mailto:django-users+unsubscr...@googlegroups.com).
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>  
>  


-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: more info to the user

2012-08-15 Thread Mario Gudelj
For the first question you should look at Forms topic in django docs. For
the second one take a look at models docs for the info on how to mark the
field as not required.

M
On Aug 15, 2012 3:36 PM, "heni yemun"  wrote:

> Hi,
> I have set up a UserProfile using the technique outlined in the standard.
> What i can do give values to the fields in the user profile model. So if
> i've a city field in the UserProfile, how can i put the value 'Asmara' to
> it and save it in the database?
>
> Second question is whenever i try to save a field it says '*fieldname*cannot 
> be NULL'. What is this? THANK YOU!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/kNwyJrDyyeUJ.
> 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.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.