Re: geocoding - getting latlng from JavaScript, send to server, store into MongoDB

2012-07-03 Thread Markus Gattol
Answering to my own question: this is what I ended up using 
http://dajaxproject.com/maps/ to send coordinates (latlng) back to the 
server (from the users browser) and then store it in MongoDB. I can then 
easily query MongoDB for near points, send the data back to the users 
browser and draw markers on the map. Good stuff!

-- 
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/-/wz2zVQcUbKgJ.
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.



custom500 page does not show up ?

2012-07-03 Thread Nikhil Verma
HI All

I have made a custom and a very simple 500.html page. However when i make
debug=False and some error come in website
still it show basic server error message.

"A server error has occurred.Please contact the administrator"

I want whenever there is some error it should show my custom 500 page.

I tried by making a custom function and then setting the handler500="path"
but still with no luck.

Anyone can help in this as to how can i resolve this problem?

Thanks
-- 
Regards
Nikhil Verma
+91-958-273-3156

-- 
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: Dumpdata and serialization issues

2012-07-03 Thread natasha.ba...@utoronto.ca
Hm, I think the functionality to do this -- at least if I understand 
correctly what I read 
here: 
http://stackoverflow.com/questions/1113096/django-dump-data-for-a-single-model

I'd be fine dumping the data for the entire app -- but the reason I did it 
this way is because when I do this, the category_id field is empty for all 
parts in the Part table. If I look at the database contents, it should not 
be blank -- so not sure why that's happening. So that's why I wanted to 
delve deeper...

So maybe my actual question should be why is the category_id many-to-many 
field showing up blank consistently when I do a dumpdata??





On Tuesday, July 3, 2012 5:55:32 PM UTC-4, ke1g wrote:
>
> In fact, I think dumpdata takes an app name, not a table or model name. 
>
> On Tue, Jul 3, 2012 at 5:54 PM, Bill Freeman  wrote: 
> > I think that you have to dumdata one or both of the models at the ends 
> > of the many to many, 
> > and the join table will come along for free. 
> > 
> > On Tue, Jul 3, 2012 at 3:21 PM, natasha.ba...@utoronto.ca 
> >  wrote: 
> >> Hi All, 
> >> 
> >> I'm trying to dump the contents of a table which is the mapping for a 
> >> many-to-many field. 
> >> 
> >> The table is called Part and it has a ManytoManyField called 
> >> category_id. 
> >> 
> >> When I run python manage.py dumpdata store.part_category_id > 
> >> file.json 
> >> 
> >> I get the error Error: Unable to serialize database: Category matching 
> >> query does not exist. 
> >> 
> >> I have validated that all values in the table are valid. 
> >> 
> >> The table is defined as follows --> id: integer PRIMARY KEY 
> >> unipart_id: integer category_id: integer 
> >> 
> >> Also, when I run dumpdata on the table (python manage.py dumpdata 
> >> store.part > file.json), the data is dumped without an error message 
> >> but the category_id field is consistently empty in the output. 
> >> 
> >> Any thoughts on what I'm doing wrong? 
> >> 
> >> Thanks, 
> >> Natasha 
> >> 
> >> -- 
> >> 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. 
> >> 
>

-- 
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/-/cDNwL3wAvZYJ.
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: Use regular expression to retrieve all image tags from a given content

2012-07-03 Thread Tim Chase
On 07/03/12 13:55, Melvyn Sopacua wrote:
> On 3-7-2012 20:38, Tim Chase wrote:
>>   <  img ... >
> 
> Which should fail.

It depends on what the OP is using it for.  If it's just for
extraction of images on the page to list them out, and such a tag
comes through, then the OP may be willing to let such
peculiarly-formed tags slide.  However, if the eventual purpose is
to prevent users from adding image tags to a text-area, then it's
perfectly valid (or at least widely accepted by multiple browsers).

>> Also, depending on the use-case (such as stripping them out of
>> validated code), a use-case such as
>>
>>   
>>
>> could get part stripped out and leave the evil  tag in the text.
> 
> r'<[Ii][Mm][Gg][^>]+[Ss][Rr][Cc]=[^>]+>' will leave very few corner
> cases.

And yet I keep coming up with those corner cases, as would any
attacker that wanted to inject an image into the page (again, if the
goal is preventing image injection).  We could still have tags like

  < img class="spoon" src="evil.gif">

and since the HTML spec is pretty lazy/sloppy regarding ignoring
unknown tags, one can even have garbage attributes introduced
anywhere you want:

  

> The point is that if you want nothing but the tags (stripped or
> matched), regular expressions can do the job just fine.

The level of concern varies radically depending on whether one just
wants to extract/gather the sane(ish) image tags from a source, or
if the purpose is to sanitize input.  A rough estimate for
extraction could be done something like the following untested regexp:

 r = re.compile(r"""
<# tag opening
\s*  # optional whitespace
img  # the tag
\b   # must end here
(?:  # one of these things:
 \s+  # whitespace
 (?:[a-z][a-z0-9]+:)? # an optional namespace
 src  # a "src" attribute
 \s*  # optional whitespace
 =# the equals sign
 \s*  # optional whitespace
 (# capture the value
  "[^"]*" # a double-quoted string
  |   # or
  '[^']*' # a single-quoted string
  |   # or
  [^-a-z0-9._:]*" # per HTML spec
  )   # end of the captured src
|# or something that's not src
 \s+  # whitespace
 (?:[a-z][a-z0-9]+:)? # an optional namespace
 [a-z0-9]+# the tag name
 (?:  # an optional value
  \s* # optional whitespace
  =   # an assignment
  \s* # optional whitespace
  (?:  # the value
   "[^"]*" # a double-quoted string
   |   # or
   '[^']*' # a single-quoted string
   |   # or
   [^-a-z0-9._:]*" # per HTML spec
   )   # end of the captured src
  )   # end of ignored attribute
 )*  # zero or more attributes
\s*  # optional whitespace
(?:/\s*) # an optional self-closing
># closing >
""", re.I | re.VERBOSE)

So, that said, I'm not sure it's much more complex to use a real
parsing library :-)

> It's a trade-off you should make a decision on, not just blatantly
> dismiss regular expressions when a document contains tags or call them
> complex when they contain more then two characters.

I'm not blithely dismissing them, just making sure that

1) the use case is understood (I haven't heard the OP chime in
beyond the simple code snippet in the first post)

2) the complexity of adequately catching a wide variety of
edge-cases one can encounter when using regexps, and

3) parsing HTML/XML is often better left to battle-tested libraries,
as I'm sure there are missing bits in the above regex...things like
the actual allowable character-sets for attribute names, and there
might yet be some sociopathic code that could slip by, but this
catches most of the cases that occur from my understanding of the
HTML spec.

> The call can even be swayed in favor for either by the "I want to
> learn (regex|XML parsing)" argument.

THAT, I can't give you any grief about--I frequently use that
argument myself :-D

-tim





-- 
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: Decoupling Urls

2012-07-03 Thread Nikolas Stevenson-Molnar
Sorry, I missed the second part of your first question. I would consider
'polls.urls' to be a full path from your project root. Depending on your
configuration, it may also be something like 'myproject.polls.urls'.

_Nik

On 7/3/2012 5:14 PM, Smaran Harihar wrote:
> Hey Nik,
>
> Thanks for the reply. When you say, provide full path for the lazy
> quoted version, do you mean 'polls.url' ?
> Is that not relative path?
>
> Also having the path in quotes 'polls.url', is it not a string?
>
> Thanks,
> Smaran
>
> On Tue, Jul 3, 2012 at 5:02 PM, Nikolas Stevenson-Molnar
> > wrote:
>
> If I understand correctly, you're asking about the difference
> between include('polls.urls') and include(admin.site.urls)? Django
> will often let you reference modules, functions, and classes
> 'lazily', meaning you don't need to import them first. You could
> use the unquoted version for polls as well, it would look
> something like
>
> import polls
> ...
> url(r'^polls/', include(polls.urls))
>
> /or/
>
> from polls import urls as poll_urls
> ...
> url(r'^polls/', include(poll_urls))
>
> Note that if you're using the 'lazy', quoted version you always
> need to provide the full path.
>
> _Nik
>
>
> On 7/3/2012 4:24 PM, Smaran Harihar wrote:
>> Hi Djangoers,
>>
>> I just completed the tutorial 3 and got a little confused on the
>> last section
>> 
>> 
>> of the tutorial,
>>
>> urlpatterns = patterns('',
>> url(r'^polls/', include('polls.urls')),
>> url(r'^admin/', include(admin.site.urls)),
>> )
>> In this for the polls app, we are assigning the urls.py path in
>> the quotes 'polls.urls'
>> but for admin we are not?
>>
>> So what is the difference and being it quotes how does it still
>> pick up the path? Does django not consider it to be simply string.
>>
>> -- 
>> Thanks & Regards
>> Smaran Harihar
>>
>> -- 
>> 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.
>
>
> -- 
> 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.
>
>
>
>
> -- 
> Thanks & Regards
> Smaran Harihar
>
> -- 
> 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.


-- 
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: Decoupling Urls

2012-07-03 Thread Nikolas Stevenson-Molnar
Hi Smaran,

Yes, by full path, I mean, for example, 'polls.urls'. And yes, it is a
string. Django interprets it as a module path when it builds up the
URLs. It's the same thing that happens in the polls.urls module when
mapping the URL patterns to functions. The functions are all quoted as
well (in the tutorial). In this case, you /don't/ need to give the full
path, since the 'polls.views' part is specified as the first argument of
patterns. For example, looking at the last code snippet on the page you
linked to, you could write the URL patterns in a few different ways:

1) as-is
2) with no 'prefix' given:
urlpatterns = patterns('',
url(r'^$', 'polls.views.index'),
...
)

3) with a partial prefix:
urlpatterns = patterns('polls',
url(r'^$', 'views.index'),
...
)

4) by passing in the function itself, rather than a string
from polls.views import index
...
urlpatterns = patterns('',
url(r'^$', index),
...
)

This notion of using strings instead of actual references is used
elsewhere too. For example, if you need to create a ForeignKey field in
one model that references a model defined later in the same file:
https://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey (see
first ForeignKey code example). It's also used in the settings file (all
the apps and middleware classes are provided as strings; typically
nothing is imported in the settings module).

Does that make sense at all? In short, in many places where Django
requires a function, class, or module, you can provide a direct
reference to it, or provide a string instead. You'll still get an error
if the module path in that string is not correct.

_Nik

On 7/3/2012 5:14 PM, Smaran Harihar wrote:
> Hey Nik,
>
> Thanks for the reply. When you say, provide full path for the lazy
> quoted version, do you mean 'polls.url' ?
> Is that not relative path?
>
> Also having the path in quotes 'polls.url', is it not a string?
>
> Thanks,
> Smaran
>
> On Tue, Jul 3, 2012 at 5:02 PM, Nikolas Stevenson-Molnar
> > wrote:
>
> If I understand correctly, you're asking about the difference
> between include('polls.urls') and include(admin.site.urls)? Django
> will often let you reference modules, functions, and classes
> 'lazily', meaning you don't need to import them first. You could
> use the unquoted version for polls as well, it would look
> something like
>
> import polls
> ...
> url(r'^polls/', include(polls.urls))
>
> /or/
>
> from polls import urls as poll_urls
> ...
> url(r'^polls/', include(poll_urls))
>
> Note that if you're using the 'lazy', quoted version you always
> need to provide the full path.
>
> _Nik
>
>
> On 7/3/2012 4:24 PM, Smaran Harihar wrote:
>> Hi Djangoers,
>>
>> I just completed the tutorial 3 and got a little confused on the
>> last section
>> 
>> 
>> of the tutorial,
>>
>> urlpatterns = patterns('',
>> url(r'^polls/', include('polls.urls')),
>> url(r'^admin/', include(admin.site.urls)),
>> )
>> In this for the polls app, we are assigning the urls.py path in
>> the quotes 'polls.urls'
>> but for admin we are not?
>>
>> So what is the difference and being it quotes how does it still
>> pick up the path? Does django not consider it to be simply string.
>>
>> -- 
>> Thanks & Regards
>> Smaran Harihar
>>
>> -- 
>> 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.
>
>
> -- 
> 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.
>
>
>
>
> -- 
> Thanks & Regards
> Smaran Harihar
>
> -- 
> 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.


-- 
You received this message because 

Re: Decoupling Urls

2012-07-03 Thread Smaran Harihar
Hey Nik,

Thanks for the reply. When you say, provide full path for the lazy quoted
version, do you mean 'polls.url' ?
Is that not relative path?

Also having the path in quotes 'polls.url', is it not a string?

Thanks,
Smaran

On Tue, Jul 3, 2012 at 5:02 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

>  If I understand correctly, you're asking about the difference between
> include('polls.urls') and include(admin.site.urls)? Django will often let
> you reference modules, functions, and classes 'lazily', meaning you don't
> need to import them first. You could use the unquoted version for polls as
> well, it would look something like
>
> import polls
> ...
> url(r'^polls/', include(polls.urls))
>
> *or*
>
> from polls import urls as poll_urls
> ...
> url(r'^polls/', include(poll_urls))
>
> Note that if you're using the 'lazy', quoted version you always need to
> provide the full path.
>
> _Nik
>
>
> On 7/3/2012 4:24 PM, Smaran Harihar wrote:
>
> Hi Djangoers,
>
>  I just completed the tutorial 3 and got a little confused on the last
> sectionof
>  the tutorial,
>
>   urlpatterns = patterns('',
> url(r'^polls/', include('polls.urls')),
> url(r'^admin/', include(admin.site.urls)),)
>
> In this for the polls app, we are assigning the urls.py path in the quotes
> 'polls.urls'
> but for admin we are not?
>
>  So what is the difference and being it quotes how does it still pick up
> the path? Does django not consider it to be simply string.
>
>  --
> Thanks & Regards
> Smaran Harihar
>
>  --
> 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.
>
>
>
>  --
> 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.
>



-- 
Thanks & Regards
Smaran Harihar

-- 
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: Decoupling Urls

2012-07-03 Thread Nikolas Stevenson-Molnar
If I understand correctly, you're asking about the difference between
include('polls.urls') and include(admin.site.urls)? Django will often
let you reference modules, functions, and classes 'lazily', meaning you
don't need to import them first. You could use the unquoted version for
polls as well, it would look something like

import polls
...
url(r'^polls/', include(polls.urls))

/or/

from polls import urls as poll_urls
...
url(r'^polls/', include(poll_urls))

Note that if you're using the 'lazy', quoted version you always need to
provide the full path.

_Nik

On 7/3/2012 4:24 PM, Smaran Harihar wrote:
> Hi Djangoers,
>
> I just completed the tutorial 3 and got a little confused on the last
> section
> 
> of the tutorial,
>
> urlpatterns = patterns('',
> url(r'^polls/', include('polls.urls')),
> url(r'^admin/', include(admin.site.urls)),
> )
> In this for the polls app, we are assigning the urls.py path in the
> quotes 'polls.urls'
> but for admin we are not?
>
> So what is the difference and being it quotes how does it still pick
> up the path? Does django not consider it to be simply string.
>
> -- 
> Thanks & Regards
> Smaran Harihar
>
> -- 
> 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.


-- 
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.



Super slow authentication

2012-07-03 Thread Ali Mesdaq
Hey everyone,

I got a situation where I have SUPER slow authentication like approx 5min
to authenticate with both LDAP and default authentication mechanisms. So
my issue is two parts first is why and how is my authentication so slow?
Second is now I am having some remote users timeout on their
authentication which was not happening before but is happening now. I have
not seen anything in the logs or error messages to help me track down the
cause of this issue. The system is centos 5 and is running apache + wsgi.
The django version is 1.3.

Thanks,
Ali Mesdaq
Security Researcher
Email:  ali.mes...@fireeye.com

Next Generation Threat Protection
http://www.FireEye.com 


__
This email and any attachments thereto may contain private, confidential, 
and/or privileged material for the sole use of the intended recipient.  Any 
review, copying, or distribution of this email (or any attachments thereto) by 
others is strictly prohibited.  If you are not the intended recipient, please 
contact the sender immediately and permanently delete the original and any 
copies of this email and any attachments thereto.
__

-- 
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.



Decoupling Urls

2012-07-03 Thread Smaran Harihar
Hi Djangoers,

I just completed the tutorial 3 and got a little confused on the last
sectionof
the tutorial,

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

In this for the polls app, we are assigning the urls.py path in the quotes
'polls.urls'
but for admin we are not?

So what is the difference and being it quotes how does it still pick up the
path? Does django not consider it to be simply string.

-- 
Thanks & Regards
Smaran Harihar

-- 
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: Controlling access

2012-07-03 Thread Larry Martell
On Tue, Jul 3, 2012 at 12:31 PM, Larry Martell  wrote:
> On Tue, Jul 3, 2012 at 11:55 AM, Robert Steckroth
>  wrote:
>> Django is a very open-ended framework. The admin system is built around
>> developer/user customization.
>
>
> Yes, I realize that. But I was asking if there was something that just
> worked (i.e. like foreign key references do). I don't think so, but my
> client seems to.

Apparently there is. Stepping through their app I found that it calls
has_perm in contrib/auth/models.py, which calls has_perm in
contrib/auth/backends.py, and this controls what specific
functionality each user has access to.


>> On Tue, Jul 3, 2012 at 1:51 PM, Larry Martell 
>> wrote:
>>>
>>> On Tue, Jul 3, 2012 at 11:49 AM, Robert Steckroth
>>>  wrote:
>>> > Yes, I have seen some very impressive admin media controls for websites
>>> > with
>>> > larger projects
>>> > having wordpress like functionality. However, there are not easy
>>> > or cheap to
>>> > make.
>>> > I recommend checking open-souce projects for a good start.
>>>
>>> But there's nothing inherently built into Django admin that supports
>>> this, correct?
>>>
>>> >
>>> >
>>> > On Tue, Jul 3, 2012 at 1:39 PM, Larry Martell 
>>> > wrote:
>>> >>
>>> >> I have a client that asked me to add some new functionality to their
>>> >> app, and then they said 'This new functionality should be controlled
>>> >> in Django admin so that only the admin user can see it.' Is there a
>>> >> way to control this in Django admin? I know in the python code i can
>>> >> check to see if they're the admin user or not and allow or disallow
>>> >> access, but what they're saying makes it seem I can just do it admin.
>>> >>
>>> >> --
>>> >> 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.
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > Bust0ut, Surgemcgee: Systems Engineer ---
>>> > PBDefence.com
>>> > BudTVNetwork.com
>>> > RadioWeedShow.com
>>> > "Bringing entertainment to Unix"
>>> >
>>> > --
>>> > 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.
>>>
>>> --
>>> 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.
>>>
>>
>>
>>
>> --
>> Bust0ut, Surgemcgee: Systems Engineer ---
>> PBDefence.com
>> BudTVNetwork.com
>> RadioWeedShow.com
>> "Bringing entertainment to Unix"
>>
>> --
>> 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.

-- 
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: how to save response 's render file to server or email using httpresponse

2012-07-03 Thread Min Hong Tan
\(^o^)/

On Tue, Jul 3, 2012 at 4:53 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

>  You are welcome. Glad you got it working :)
>
> _Nik
>
>
> On 7/3/2012 3:33 PM, Min Hong Tan wrote:
>
> Thx nik,
>
>  I'm confused , your words has aroused me  from the word.
> "You won't use HttpResponse at all, just EmailMessage (using
> message.attach). "
>
>  problem solved by using below:
>
>
>
>  from io import BytesIO
>
>
>
>  buffer = BytesIO()
> book.save(buffer)
> excel = buffer.getvalue()
> buffer.close()
>
>  and just
>
>
> mail.attach(filename="testing.xls",content=excel,mimetype="application/ms-excel")
>
>  mail.send()
>
>  and mission accomplished!!
>
>
>
>
> On Tue, Jul 3, 2012 at 2:59 PM, Nikolas Stevenson-Molnar <
> nik.mol...@consbio.org> wrote:
>
>>  You'll need to use EmailMessage:
>> https://docs.djangoproject.com/en/dev/topics/email/?from=olddocs/#django.core.mail.EmailMessage
>>
>> You won't use HttpResponse at all, just EmailMessage (using
>> message.attach).
>>
>> _Nik
>>
>>
>> On 7/3/2012 1:34 PM, Min Hong Tan wrote:
>>
>> sorry all, maybe i'm not type why i need the httpresponse to be attach.
>>
>>  response = HttpResponse(mimetype='application/pdf')
>> response['Content-Disposition'] = 'attaachment; filename=report.pdf'
>>
>>  i'm generating the pdf file in response. and normally i will return
>> response and it should be perfect with the pdf file download.
>>
>>  but, how if i want to attach it and send out the mail?
>>
>> On Tue, Jul 3, 2012 at 12:32 PM, Nikolas Stevenson-Molnar <
>> nik.mol...@consbio.org> wrote:
>>
>>> Oh, and HttpResponse is intended to send data back to a web browser. I
>>> can't think of any reason you would use an HttpResponse when sending an
>>> email.
>>>
>>> _Nik
>>>
>>> On 7/3/2012 11:20 AM, Min Hong Tan wrote:
>>>  > hi,
>>> >
>>> > I have a problem to send mail using Emailmessage,
>>> > i wan to attach the file that render using httpresponse and send, but
>>> > always show me "int" does not have method "lower".
>>> > therefore, I think to save the file in the server and then attach
>>> > using emailmessage.  but how do i get the httpresonse to save
>>> > in server /tmp/file  ?
>>> >
>>> > Regards,
>>> > MH
>>>   > --
>>> > 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.
>>>
>>>
>>> --
>>> 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.
>>>
>>>
>>  --
>> 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.
>>
>>
>>
>>--
>> 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.
>>
>
>  --
> 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.
>
>
>
>  --
> 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.
>

-- 
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: how to save response 's render file to server or email using httpresponse

2012-07-03 Thread Nikolas Stevenson-Molnar
You are welcome. Glad you got it working :)

_Nik

On 7/3/2012 3:33 PM, Min Hong Tan wrote:
> Thx nik,
>
> I'm confused , your words has aroused me  from the word.
> "You won't use HttpResponse at all, just EmailMessage (using
> message.attach). "
>
> problem solved by using below:
>
>
>
> from io import BytesIO
>
>
>
> buffer = BytesIO()
> book.save(buffer) 
> excel = buffer.getvalue()
> buffer.close()
>
> and just 
>
> mail.attach(filename="testing.xls",content=excel,mimetype="application/ms-excel")
>
> mail.send()
>
> and mission accomplished!!
>
>
>
>
> On Tue, Jul 3, 2012 at 2:59 PM, Nikolas Stevenson-Molnar
> > wrote:
>
> You'll need to use EmailMessage:
> 
> https://docs.djangoproject.com/en/dev/topics/email/?from=olddocs/#django.core.mail.EmailMessage
>
> You won't use HttpResponse at all, just EmailMessage (using
> message.attach).
>
> _Nik
>
>
> On 7/3/2012 1:34 PM, Min Hong Tan wrote:
>> sorry all, maybe i'm not type why i need the httpresponse to be
>> attach.
>>
>> response = HttpResponse(mimetype='application/pdf')
>> response['Content-Disposition'] = 'attaachment; filename=report.pdf'
>>
>> i'm generating the pdf file in response. and normally i will
>> return response and it should be perfect with the pdf file download.
>>
>> but, how if i want to attach it and send out the mail?
>>
>> On Tue, Jul 3, 2012 at 12:32 PM, Nikolas Stevenson-Molnar
>> > wrote:
>>
>> Oh, and HttpResponse is intended to send data back to a web
>> browser. I
>> can't think of any reason you would use an HttpResponse when
>> sending an
>> email.
>>
>> _Nik
>>
>> On 7/3/2012 11:20 AM, Min Hong Tan wrote:
>> > hi,
>> >
>> > I have a problem to send mail using Emailmessage,
>> > i wan to attach the file that render using httpresponse and
>> send, but
>> > always show me "int" does not have method "lower".
>> > therefore, I think to save the file in the server and then
>> attach
>> > using emailmessage.  but how do i get the httpresonse to save
>> > in server /tmp/file  ?
>> >
>> > Regards,
>> > MH
>> > --
>> > 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.
>>
>>
>> --
>> 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.
>>
>>
>> -- 
>> 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.
>
>
> -- 
> 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.
>
>
> -- 
> 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.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to 

Re: Conditionals in Templates

2012-07-03 Thread Javier Guerra Giraldez
On Tue, Jul 3, 2012 at 3:39 PM, Bill Freeman  wrote:
> The obvious ways are:
>
> 1. Provide a model method that returns a string representing the type
> of the instance, compare against that
> 2. Decorate the instance with an attribute giving the name of the type
> as a string...

3. write a template tag


-- 
Javier

-- 
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: how to save response 's render file to server or email using httpresponse

2012-07-03 Thread Min Hong Tan
Thx nik,

I'm confused , your words has aroused me  from the word.
"You won't use HttpResponse at all, just EmailMessage (using
message.attach). "

problem solved by using below:



from io import BytesIO



buffer = BytesIO()
book.save(buffer)
excel = buffer.getvalue()
buffer.close()

and just

mail.attach(filename="testing.xls",content=excel,mimetype="application/ms-excel")

mail.send()

and mission accomplished!!




On Tue, Jul 3, 2012 at 2:59 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

>  You'll need to use EmailMessage:
> https://docs.djangoproject.com/en/dev/topics/email/?from=olddocs/#django.core.mail.EmailMessage
>
> You won't use HttpResponse at all, just EmailMessage (using
> message.attach).
>
> _Nik
>
>
> On 7/3/2012 1:34 PM, Min Hong Tan wrote:
>
> sorry all, maybe i'm not type why i need the httpresponse to be attach.
>
>  response = HttpResponse(mimetype='application/pdf')
> response['Content-Disposition'] = 'attaachment; filename=report.pdf'
>
>  i'm generating the pdf file in response. and normally i will return
> response and it should be perfect with the pdf file download.
>
>  but, how if i want to attach it and send out the mail?
>
> On Tue, Jul 3, 2012 at 12:32 PM, Nikolas Stevenson-Molnar <
> nik.mol...@consbio.org> wrote:
>
>> Oh, and HttpResponse is intended to send data back to a web browser. I
>> can't think of any reason you would use an HttpResponse when sending an
>> email.
>>
>> _Nik
>>
>> On 7/3/2012 11:20 AM, Min Hong Tan wrote:
>>  > hi,
>> >
>> > I have a problem to send mail using Emailmessage,
>> > i wan to attach the file that render using httpresponse and send, but
>> > always show me "int" does not have method "lower".
>> > therefore, I think to save the file in the server and then attach
>> > using emailmessage.  but how do i get the httpresonse to save
>> > in server /tmp/file  ?
>> >
>> > Regards,
>> > MH
>>   > --
>> > 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.
>>
>>
>> --
>> 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.
>>
>>
>  --
> 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.
>
>
>
>  --
> 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.
>

-- 
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: Dumpdata and serialization issues

2012-07-03 Thread Bill Freeman
In fact, I think dumpdata takes an app name, not a table or model name.

On Tue, Jul 3, 2012 at 5:54 PM, Bill Freeman  wrote:
> I think that you have to dumdata one or both of the models at the ends
> of the many to many,
> and the join table will come along for free.
>
> On Tue, Jul 3, 2012 at 3:21 PM, natasha.ba...@utoronto.ca
>  wrote:
>> Hi All,
>>
>> I'm trying to dump the contents of a table which is the mapping for a
>> many-to-many field.
>>
>> The table is called Part and it has a ManytoManyField called
>> category_id.
>>
>> When I run python manage.py dumpdata store.part_category_id >
>> file.json
>>
>> I get the error Error: Unable to serialize database: Category matching
>> query does not exist.
>>
>> I have validated that all values in the table are valid.
>>
>> The table is defined as follows --> id: integer PRIMARY KEY
>> unipart_id: integer category_id: integer
>>
>> Also, when I run dumpdata on the table (python manage.py dumpdata
>> store.part > file.json), the data is dumped without an error message
>> but the category_id field is consistently empty in the output.
>>
>> Any thoughts on what I'm doing wrong?
>>
>> Thanks,
>> Natasha
>>
>> --
>> 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.
>>

-- 
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: Dumpdata and serialization issues

2012-07-03 Thread Bill Freeman
I think that you have to dumdata one or both of the models at the ends
of the many to many,
and the join table will come along for free.

On Tue, Jul 3, 2012 at 3:21 PM, natasha.ba...@utoronto.ca
 wrote:
> Hi All,
>
> I'm trying to dump the contents of a table which is the mapping for a
> many-to-many field.
>
> The table is called Part and it has a ManytoManyField called
> category_id.
>
> When I run python manage.py dumpdata store.part_category_id >
> file.json
>
> I get the error Error: Unable to serialize database: Category matching
> query does not exist.
>
> I have validated that all values in the table are valid.
>
> The table is defined as follows --> id: integer PRIMARY KEY
> unipart_id: integer category_id: integer
>
> Also, when I run dumpdata on the table (python manage.py dumpdata
> store.part > file.json), the data is dumped without an error message
> but the category_id field is consistently empty in the output.
>
> Any thoughts on what I'm doing wrong?
>
> Thanks,
> Natasha
>
> --
> 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.
>

-- 
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: values() and order_by()

2012-07-03 Thread Bill Freeman
First, I think that you're going about last_visit in the wrong way.
timezone.now() is evaluated once, when the module is imported,
rather than when the user visits.  DateTimeField's auto_now=True
option is tailor made for this kind of situation.

Next, since you have the user id, I'm going to assume that you have
an actual user object.  In the code below I'll presume that it's
request.user .

visits_qs = Visit.objects.filter(user=request.user)
total_visits_count = visits_qs.count()
latest_visit = visits_qs.order_by('-last_visit')[0]

Yes, this is two database queries, but unless you are seeing a performance
issue that you've traced to the fact that this is more than one query, this
code is a heck of a lot more maintainable than trying to make it happen
in one.

Bill

On Tue, Jul 3, 2012 at 6:51 AM, J. Javier Maestro  wrote:
> Hi there!
>
> I have the following model:
>
>   class Visit(models.Model):
>   user = models.ForeignKey(User)
>   visitor = models.ForeignKey(User, related_name="visitor")
>   last_visit = models.DateTimeField(default=timezone.now())
>   count_visits = models.IntegerField(default=0)
>
> I would like to make the following SQL query using the Django ORM:
>
>   SELECT last_visit, SUM(count_visits) AS total_count_visits
>   FROM core_visit
>   WHERE user_id=42
>   GROUP BY user_id
>   ORDER BY last_visit DESC
>
> So far, I haven't been able to do it. When I use values('user') and
> order_by('-last_visit') the last_visit column is automatically added
> to the GROUP BY clause. I've read in the Django doc that this is how
> it's supposed to be but I can't seem to understand it. Why do I have
> to group the results by whatever I choose as order? What am I missing?
>
> Also, I know I can do a RawQuerySet but unfortunately, I would like to
> be able to use a full QuerySet (this query goes into Tastypie and so
> far, I haven't been successful in using it with anything but full
> QuerySets, not even ValueQuerySets...)
>
> All help and ideas would be greatly appreciated.
>
> Thanks a lot in advanced,
>
> --
> J. Javier Maestro 
>
> --
> 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.
>

-- 
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: how to save response 's render file to server or email using httpresponse

2012-07-03 Thread Nikolas Stevenson-Molnar
You'll need to use EmailMessage:
https://docs.djangoproject.com/en/dev/topics/email/?from=olddocs/#django.core.mail.EmailMessage

You won't use HttpResponse at all, just EmailMessage (using message.attach).

_Nik

On 7/3/2012 1:34 PM, Min Hong Tan wrote:
> sorry all, maybe i'm not type why i need the httpresponse to be attach.
>
> response = HttpResponse(mimetype='application/pdf')
> response['Content-Disposition'] = 'attaachment; filename=report.pdf'
>
> i'm generating the pdf file in response. and normally i will return
> response and it should be perfect with the pdf file download.
>
> but, how if i want to attach it and send out the mail?
>
> On Tue, Jul 3, 2012 at 12:32 PM, Nikolas Stevenson-Molnar
> > wrote:
>
> Oh, and HttpResponse is intended to send data back to a web browser. I
> can't think of any reason you would use an HttpResponse when
> sending an
> email.
>
> _Nik
>
> On 7/3/2012 11:20 AM, Min Hong Tan wrote:
> > hi,
> >
> > I have a problem to send mail using Emailmessage,
> > i wan to attach the file that render using httpresponse and
> send, but
> > always show me "int" does not have method "lower".
> > therefore, I think to save the file in the server and then attach
> > using emailmessage.  but how do i get the httpresonse to save
> > in server /tmp/file  ?
> >
> > Regards,
> > MH
> > --
> > 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.
>
>
> --
> 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.
>
>
> -- 
> 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.


-- 
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: Raise 404

2012-07-03 Thread Bill Freeman
We can't answer, since we don't know what page you're seeing.  We can't
access your localhost:8000 to check.

On Tue, Jul 3, 2012 at 3:38 PM, Smaran Harihar  wrote:
> Hey Djangoers,
>
> I am on my tutorial 3 and I was on this topic.
>
> And now if I try to access http://localhost:8000/polls/1/ it gives me the
> same error page, which it gives for other errors.
>
> I know the error is because I have not yet created the detail.html page but
> is this the output for 'raise Http404' ?
>
> --
> Thanks & Regards
> Smaran Harihar
>
> --
> 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.

-- 
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: Conditionals in Templates

2012-07-03 Thread Bill Freeman
The obvious ways are:

1. Provide a model method that returns a string representing the type
of the instance, compare against that
2. Decorate the instance with an attribute giving the name of the type
as a string...

Can't change the instance (I really think you can still decorate it in
the view, python is flexible that way, but), instead of rows of
instances, return rows of wrapper objects that have the type name as
above, and the original instance as another attribute.

On Tue, Jul 3, 2012 at 3:50 PM, Russ Abbott  wrote:
> I'm generating a table. I want the cells to be different depending on the
> type of the content. How do I test for the type of the content? I'd like to
> do something like this.
>
> 
> {% for row in rows %}
> 
> {% for cell in row %}
> 
> {% if isinstance( {{ cell }}, list) %}
> 
> {% for element in cell %}
> {{  element  }}
> {% endfor %}
> 
> {% else %}
> {{ cell }}
> {% endif %}
> 
> {% endfor %}
> 
> {% endfor %}
> 
>
> But "{% if isinstance( {{ cell }}, list) %}" is not allowed. Apparently I
> can't call a function in an {% if ...  %} tag.  Is there another way to do
> this?
>
> Thanks.
>
> --
> 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/-/jRlkDDGDgk0J.
> 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: Conditionals in Templates

2012-07-03 Thread Russ Abbott
Here's a workaround I came up with.

I defined a class:

class TableValue:
def __init__(self, value):
self.value = value
self.is_list = isinstance(value, list)

Then in the Template I wrote


{% for row in rows %}

{% for cell in row %}

{% if cell.is_list %}

{% for element in cell.value %}
{{ element }}
{% endfor %}

{% else %}
{{ cell.value }}
{% endif %}

{% endfor %}

{% endfor %}


Is that considered decent Django?

On Tuesday, July 3, 2012 12:50:15 PM UTC-7, Russ Abbott wrote:
>
> I'm generating a table. I want the cells to be different depending on the 
> type of the content. How do I test for the type of the content? I'd like to 
> do something like this.
>
> 
> {% for row in rows %}
> 
> {% for cell in row %}
> 
> {% if isinstance( {{ cell }}, list) %}
> 
> {% for element in cell %}
> {{  element  }}
> {% endfor %}
> 
> {% else %}
> {{ cell }}
> {% endif %}
> 
> {% endfor %}
> 
> {% endfor %}
> 
>
> But "{% if isinstance( {{ cell }}, list) %}" is not allowed. Apparently I 
> can't call a function in an {% if ...  %} tag.  Is there another way to do 
> this?
>
> Thanks.
>

-- 
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/-/HxfDQVmchj0J.
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: how to save response 's render file to server or email using httpresponse

2012-07-03 Thread Min Hong Tan
sorry all, maybe i'm not type why i need the httpresponse to be attach.

response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attaachment; filename=report.pdf'

i'm generating the pdf file in response. and normally i will return
response and it should be perfect with the pdf file download.

but, how if i want to attach it and send out the mail?

On Tue, Jul 3, 2012 at 12:32 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

> Oh, and HttpResponse is intended to send data back to a web browser. I
> can't think of any reason you would use an HttpResponse when sending an
> email.
>
> _Nik
>
> On 7/3/2012 11:20 AM, Min Hong Tan wrote:
> > hi,
> >
> > I have a problem to send mail using Emailmessage,
> > i wan to attach the file that render using httpresponse and send, but
> > always show me "int" does not have method "lower".
> > therefore, I think to save the file in the server and then attach
> > using emailmessage.  but how do i get the httpresonse to save
> > in server /tmp/file  ?
> >
> > Regards,
> > MH
> > --
> > 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.
>
>
> --
> 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.
>
>

-- 
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.



dateutil relativedelta compare - strange results

2012-07-03 Thread Cal Leeming [Simplicity Media Ltd]
Hi all,

Just spent about an hour figuring out what the hell was going on with
dateutil comparisons, and thought I'd share with the group.

Essentially, when trying to compare relativedelta to each other, we were
getting very strange results.

In the end, it was due to the fact 'calendar' needed to be imported -
without this, it seems to do strange things.

Hope this is useful to something else in the future - as we use dateutil
heavily in all our webapps, and this is the first time I'd ever come across
this.

Cal



Proof of concept:

>>> from dateutil.relativedelta import *
>>> relativedelta(years=+2) > relativedelta(days=+7)
True
>>> import datetime
>>> relativedelta(years=+2) > relativedelta(days=+7)
False
>>> import calendar
>>> relativedelta(years=+2) > relativedelta(days=+7)
True
>>>

-- 
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.



Conditionals in Templates

2012-07-03 Thread Russ Abbott
I'm generating a table. I want the cells to be different depending on the 
type of the content. How do I test for the type of the content? I'd like to 
do something like this.


{% for row in rows %}

{% for cell in row %}

{% if isinstance( {{ cell }}, list) %}

{% for element in cell %}
{{  element  }}
{% endfor %}

{% else %}
{{ cell }}
{% endif %}

{% endfor %}

{% endfor %}


But "{% if isinstance( {{ cell }}, list) %}" is not allowed. Apparently I 
can't call a function in an {% if ...  %} tag.  Is there another way to do 
this?

Thanks.

-- 
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/-/jRlkDDGDgk0J.
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: Still need help with the 405....please

2012-07-03 Thread Nikolas Stevenson-Molnar
Looking at the soaplib source, it looks like it required requests to be
made using POST. If you're loading this in a web browser to test, then
you're making a GET request. Try making a POST request (using something
like Fiddler) instead.

https://github.com/soaplib/soaplib/blob/master/src/soaplib/core/server/wsgi.py
(line 84/85)

_Nik

On 7/3/2012 12:20 PM, Jeff Silverman wrote:
> http://djangosnippets.org/snippets/2638/
>
> On Jul 3, 2:56 pm, Nikolas Stevenson-Molnar 
> wrote:
>> Would you please provide a reference to the snippet or to your complete
>> code? It's hard to understand what's going on from this small bit.
>>
>> _Nik
>>
>> On 7/3/2012 11:33 AM, Jeff Silverman wrote:
>>
>>
>>
>>> Thanks for the reply.  Removing that did not change the result.  Just
>>> an FYI, but I copied the code verbatim from the snippet.  that's why I
>>> cannot understand what's going on.  I continually get the 405 method
>>> not allowed error regardless.
>>> On Jul 3, 1:28 pm, Nikolas Stevenson-Molnar 
>>> wrote:
 I'm not sure that this is the problem, but typically constructors should
 not have a return value. Try removing the "return" from your
 DjangoSoapApp constructor.
 _Nik
 On 7/3/2012 6:32 AM, Jeff Silverman wrote:
> Below is the code from the views.py
> The 405 is retunred from the 'return super(DjangoSoapApp,
> self).__init__(Application(services, tns))' statement.  I am using
> python 2.6, soaplib20 and django 1.3.  I am struggling to understand
> what exactly is wrong here.
> class HelloWorldService(DefinitionBase):
> @soap(String,Integer,_returns=Array(String))
> def say_smello(self,name,times):
> results = []
> for i in range(0,times):
> results.append('Hello, %s'%name)
> return results
> class DjangoSoapApp(WSGIApplication):
> csrf_exempt = True
> def __init__(self, services, tns):
> """Create Django view for given SOAP soaplib services and
> tns"""
> return super(DjangoSoapApp,
> self).__init__(Application(services, tns))
> def __call__(self, request):
> django_response = HttpResponse()
> def start_response(status, headers):
> django_response.status_code = int(status.split(' ', 1)[0])
> for header, value in headers:
> django_response[header] = value
> response = super(DjangoSoapApp, self).__call__(request.META,
> start_response)
> django_response.content = '\n'.join(response)
> return django_response
> # the view to use in urls.py
> hello_world_service = DjangoSoapApp([HelloWorldService], '__name__')- 
> Hide quoted text -
 - Show quoted text -- Hide quoted text -
>> - Show quoted text -


-- 
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.



Dumpdata and serialization issues

2012-07-03 Thread natasha.ba...@utoronto.ca
Hi All,

I'm trying to dump the contents of a table which is the mapping for a
many-to-many field.

The table is called Part and it has a ManytoManyField called
category_id.

When I run python manage.py dumpdata store.part_category_id >
file.json

I get the error Error: Unable to serialize database: Category matching
query does not exist.

I have validated that all values in the table are valid.

The table is defined as follows --> id: integer PRIMARY KEY
unipart_id: integer category_id: integer

Also, when I run dumpdata on the table (python manage.py dumpdata
store.part > file.json), the data is dumped without an error message
but the category_id field is consistently empty in the output.

Any thoughts on what I'm doing wrong?

Thanks,
Natasha

-- 
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.



Raise 404

2012-07-03 Thread Smaran Harihar
Hey Djangoers,

I am on my tutorial 3 and I was on this
topic
.

And now if I try to access http://localhost:8000/polls/1/ it gives me the
same error page, which it gives for other errors.

I know the error is because I have not yet created the detail.html page but
is this the output for 'raise Http404' ?

-- 
Thanks & Regards
Smaran Harihar

-- 
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: Still need help with the 405....please

2012-07-03 Thread Jeff Silverman
http://djangosnippets.org/snippets/2638/

On Jul 3, 2:56 pm, Nikolas Stevenson-Molnar 
wrote:
> Would you please provide a reference to the snippet or to your complete
> code? It's hard to understand what's going on from this small bit.
>
> _Nik
>
> On 7/3/2012 11:33 AM, Jeff Silverman wrote:
>
>
>
> > Thanks for the reply.  Removing that did not change the result.  Just
> > an FYI, but I copied the code verbatim from the snippet.  that's why I
> > cannot understand what's going on.  I continually get the 405 method
> > not allowed error regardless.
>
> > On Jul 3, 1:28 pm, Nikolas Stevenson-Molnar 
> > wrote:
> >> I'm not sure that this is the problem, but typically constructors should
> >> not have a return value. Try removing the "return" from your
> >> DjangoSoapApp constructor.
>
> >> _Nik
>
> >> On 7/3/2012 6:32 AM, Jeff Silverman wrote:
>
> >>> Below is the code from the views.py
> >>> The 405 is retunred from the 'return super(DjangoSoapApp,
> >>> self).__init__(Application(services, tns))' statement.  I am using
> >>> python 2.6, soaplib20 and django 1.3.  I am struggling to understand
> >>> what exactly is wrong here.
> >>> class HelloWorldService(DefinitionBase):
> >>>     @soap(String,Integer,_returns=Array(String))
> >>>     def say_smello(self,name,times):
> >>>         results = []
> >>>         for i in range(0,times):
> >>>             results.append('Hello, %s'%name)
> >>>         return results
> >>> class DjangoSoapApp(WSGIApplication):
> >>>     csrf_exempt = True
> >>>     def __init__(self, services, tns):
> >>>         """Create Django view for given SOAP soaplib services and
> >>> tns"""
> >>>         return super(DjangoSoapApp,
> >>> self).__init__(Application(services, tns))
> >>>     def __call__(self, request):
> >>>         django_response = HttpResponse()
> >>>         def start_response(status, headers):
> >>>             django_response.status_code = int(status.split(' ', 1)[0])
> >>>             for header, value in headers:
> >>>                 django_response[header] = value
> >>>         response = super(DjangoSoapApp, self).__call__(request.META,
> >>> start_response)
> >>>         django_response.content = '\n'.join(response)
> >>>         return django_response
> >>> # the view to use in urls.py
> >>> hello_world_service = DjangoSoapApp([HelloWorldService], '__name__')- 
> >>> Hide quoted text -
> >> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

-- 
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: Still need help with the 405....please

2012-07-03 Thread Nikolas Stevenson-Molnar
Would you please provide a reference to the snippet or to your complete
code? It's hard to understand what's going on from this small bit.

_Nik

On 7/3/2012 11:33 AM, Jeff Silverman wrote:
> Thanks for the reply.  Removing that did not change the result.  Just
> an FYI, but I copied the code verbatim from the snippet.  that's why I
> cannot understand what's going on.  I continually get the 405 method
> not allowed error regardless.
>
> On Jul 3, 1:28 pm, Nikolas Stevenson-Molnar 
> wrote:
>> I'm not sure that this is the problem, but typically constructors should
>> not have a return value. Try removing the "return" from your
>> DjangoSoapApp constructor.
>>
>> _Nik
>>
>> On 7/3/2012 6:32 AM, Jeff Silverman wrote:
>>
>>
>>
>>> Below is the code from the views.py
>>> The 405 is retunred from the 'return super(DjangoSoapApp,
>>> self).__init__(Application(services, tns))' statement.  I am using
>>> python 2.6, soaplib20 and django 1.3.  I am struggling to understand
>>> what exactly is wrong here.
>>> class HelloWorldService(DefinitionBase):
>>> @soap(String,Integer,_returns=Array(String))
>>> def say_smello(self,name,times):
>>> results = []
>>> for i in range(0,times):
>>> results.append('Hello, %s'%name)
>>> return results
>>> class DjangoSoapApp(WSGIApplication):
>>> csrf_exempt = True
>>> def __init__(self, services, tns):
>>> """Create Django view for given SOAP soaplib services and
>>> tns"""
>>> return super(DjangoSoapApp,
>>> self).__init__(Application(services, tns))
>>> def __call__(self, request):
>>> django_response = HttpResponse()
>>> def start_response(status, headers):
>>> django_response.status_code = int(status.split(' ', 1)[0])
>>> for header, value in headers:
>>> django_response[header] = value
>>> response = super(DjangoSoapApp, self).__call__(request.META,
>>> start_response)
>>> django_response.content = '\n'.join(response)
>>> return django_response
>>> # the view to use in urls.py
>>> hello_world_service = DjangoSoapApp([HelloWorldService], '__name__')- Hide 
>>> quoted text -
>> - Show quoted text -


-- 
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: Use regular expression to retrieve all image tags from a given content

2012-07-03 Thread Melvyn Sopacua
On 3-7-2012 20:38, Tim Chase wrote:
> On 07/03/12 12:57, Melvyn Sopacua wrote:
>> On 30-6-2012 15:23, Sunny Nanda wrote:
>> What you're looking for is:
>> prog = re.compile(r'')
>> matches = re.search(prog)
>> for match in matches :
>>  print match
>>
>>> On a sidenote, you should not be using regular expressions if you are doing 
>>> anything complex that what you are doing right now.
>>
>> This isn't complex. The email validator in django is complex. Using an
>> XML parser for this is quite overkill. If you need several elements
>> based on their nesting and/or sister elements, then an XML parser makes
>> more sense, or better xpath queries. This is simple stuff for regular
>> expressions and what they're made for.
> 
> The reason for using a true parser is to avoid obscure edge cases.
> Your example fails on both
> 
>   

Which is easily corrected with either <[Ii][Mm][Gg] or case-insensitive.
> 
> and
> 
>   <  img ... >

Which should fail.

> Also, depending on the use-case (such as stripping them out of
> validated code), a use-case such as
> 
>   
> 
> could get part stripped out and leave the evil  tag in the text.

r'<[Ii][Mm][Gg][^>]+[Ss][Rr][Cc]=[^>]+>' will leave very few corner
cases. The point is that if you want nothing but the tags (stripped or
matched), regular expressions can do the job just fine. It's actually
more complex to do this with parsers, as you have to deal with syntax
errors, keep state and rejoin the tags with the attributes for SAX based
parsers and the only advantageous parser is a DOM tree, which has a
large memory footprint on complex/large documents.
It's a trade-off you should make a decision on, not just blatantly
dismiss regular expressions when a document contains tags or call them
complex when they contain more then two characters. The call can even be
swayed in favor for either by the "I want to learn (regex|XML parsing)"
argument.
-- 
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: Tutorial three '-pub_date'

2012-07-03 Thread Smaran Harihar
Thanks Vincent and Elliot.

On Tue, Jul 3, 2012 at 11:41 AM, cubells  wrote:

> It means "in descending order"
>
> , Vicent Cubells.
>
>
> - Reply message -
> De: "Smaran Harihar" 
> Para: 
> Asunto: Tutorial three '-pub_date'
> Fecha: mar., jul. 3, 2012 20:33
>
>
> Hey Djangoers,
>
> I am on the tutorial 
> 3,
> and found this code where we are modifying the view index()
>
> def index(request):
> latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
> output = ', '.join([p.question for p in latest_poll_list])
> return HttpResponse(output)
>
> What I did not understand, was why did we state,
>
> order_by('-pub_date'), what does that *'-'* mean before 'pub_date' ?
>
> --
> Thanks & Regards
> Smaran Harihar
>
>  --
> 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.
>
> --
> 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.
>



-- 
Thanks & Regards
Smaran Harihar

-- 
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: Tutorial three '-pub_date'

2012-07-03 Thread cubells
It means "in descending order"

, Vicent Cubells.

- Reply message -
De: "Smaran Harihar" 
Para: 
Asunto: Tutorial three -pub_date
Fecha: mar., jul. 3, 2012 20:33
Hey Djangoers,
I am on the tutorial 3, and found this code where we are modifying the view 
index()






def index(request):
latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
output = ', '.join([p.question for p in latest_poll_list])
return HttpResponse(output)
What I did not understand, was why did we state,
order_by('-pub_date'), what does that '-' mean before 'pub_date' ? 


-- 
Thanks & RegardsSmaran Harihar





-- 
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.

-- 
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: Use regular expression to retrieve all image tags from a given content

2012-07-03 Thread Tim Chase
On 07/03/12 12:57, Melvyn Sopacua wrote:
> On 30-6-2012 15:23, Sunny Nanda wrote:
> What you're looking for is:
> prog = re.compile(r'')
> matches = re.search(prog)
> for match in matches :
>   print match
> 
>> On a sidenote, you should not be using regular expressions if you are doing 
>> anything complex that what you are doing right now.
> 
> This isn't complex. The email validator in django is complex. Using an
> XML parser for this is quite overkill. If you need several elements
> based on their nesting and/or sister elements, then an XML parser makes
> more sense, or better xpath queries. This is simple stuff for regular
> expressions and what they're made for.

The reason for using a true parser is to avoid obscure edge cases.
Your example fails on both

  

and

  <  img ... >

Also, depending on the use-case (such as stripping them out of
validated code), a use-case such as

  

could get part stripped out and leave the evil  tag in the text.

-tkc



-- 
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: Tutorial three '-pub_date'

2012-07-03 Thread Elliot Bradbury
'-' reverses the ordering of that field. So it will order the most recently
published Polls first.

On Tue, Jul 3, 2012 at 2:33 PM, Smaran Harihar wrote:

> Hey Djangoers,
>
> I am on the tutorial 
> 3,
> and found this code where we are modifying the view index()
>
> def index(request):
> latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
> output = ', '.join([p.question for p in latest_poll_list])
> return HttpResponse(output)
>
> What I did not understand, was why did we state,
>
> order_by('-pub_date'), what does that *'-'* mean before 'pub_date' ?
>
> --
> Thanks & Regards
> Smaran Harihar
>
>  --
> 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.
>

-- 
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.



Tutorial three '-pub_date'

2012-07-03 Thread Smaran Harihar
Hey Djangoers,

I am on the tutorial
3,
and found this code where we are modifying the view index()

def index(request):
latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
output = ', '.join([p.question for p in latest_poll_list])
return HttpResponse(output)

What I did not understand, was why did we state,

order_by('-pub_date'), what does that *'-'* mean before 'pub_date' ?

-- 
Thanks & Regards
Smaran Harihar

-- 
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: Still need help with the 405....please

2012-07-03 Thread Jeff Silverman
Thanks for the reply.  Removing that did not change the result.  Just
an FYI, but I copied the code verbatim from the snippet.  that's why I
cannot understand what's going on.  I continually get the 405 method
not allowed error regardless.

On Jul 3, 1:28 pm, Nikolas Stevenson-Molnar 
wrote:
> I'm not sure that this is the problem, but typically constructors should
> not have a return value. Try removing the "return" from your
> DjangoSoapApp constructor.
>
> _Nik
>
> On 7/3/2012 6:32 AM, Jeff Silverman wrote:
>
>
>
> > Below is the code from the views.py
>
> > The 405 is retunred from the 'return super(DjangoSoapApp,
> > self).__init__(Application(services, tns))' statement.  I am using
> > python 2.6, soaplib20 and django 1.3.  I am struggling to understand
> > what exactly is wrong here.
>
> > class HelloWorldService(DefinitionBase):
> >     @soap(String,Integer,_returns=Array(String))
> >     def say_smello(self,name,times):
> >         results = []
> >         for i in range(0,times):
> >             results.append('Hello, %s'%name)
> >         return results
>
> > class DjangoSoapApp(WSGIApplication):
> >     csrf_exempt = True
>
> >     def __init__(self, services, tns):
> >         """Create Django view for given SOAP soaplib services and
> > tns"""
>
> >         return super(DjangoSoapApp,
> > self).__init__(Application(services, tns))
>
> >     def __call__(self, request):
> >         django_response = HttpResponse()
>
> >         def start_response(status, headers):
> >             django_response.status_code = int(status.split(' ', 1)[0])
> >             for header, value in headers:
> >                 django_response[header] = value
>
> >         response = super(DjangoSoapApp, self).__call__(request.META,
> > start_response)
> >         django_response.content = '\n'.join(response)
>
> >         return django_response
>
> > # the view to use in urls.py
> > hello_world_service = DjangoSoapApp([HelloWorldService], '__name__')- Hide 
> > quoted text -
>
> - Show quoted text -

-- 
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: how to save response 's render file to server or email using httpresponse

2012-07-03 Thread Nikolas Stevenson-Molnar
Oh, and HttpResponse is intended to send data back to a web browser. I
can't think of any reason you would use an HttpResponse when sending an
email.

_Nik

On 7/3/2012 11:20 AM, Min Hong Tan wrote:
> hi,
>
> I have a problem to send mail using Emailmessage,
> i wan to attach the file that render using httpresponse and send, but
> always show me "int" does not have method "lower".
> therefore, I think to save the file in the server and then attach
> using emailmessage.  but how do i get the httpresonse to save
> in server /tmp/file  ? 
>
> Regards,
> MH
> -- 
> 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.


-- 
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: Controlling access

2012-07-03 Thread Larry Martell
On Tue, Jul 3, 2012 at 11:55 AM, Robert Steckroth
 wrote:
> Django is a very open-ended framework. The admin system is built around
> developer/user customization.


Yes, I realize that. But I was asking if there was something that just
worked (i.e. like foreign key references do). I don't think so, but my
client seems to.


>
>
>
> On Tue, Jul 3, 2012 at 1:51 PM, Larry Martell 
> wrote:
>>
>> On Tue, Jul 3, 2012 at 11:49 AM, Robert Steckroth
>>  wrote:
>> > Yes, I have seen some very impressive admin media controls for websites
>> > with
>> > larger projects
>> > having wordpress like functionality. However, there are not easy
>> > or cheap to
>> > make.
>> > I recommend checking open-souce projects for a good start.
>>
>> But there's nothing inherently built into Django admin that supports
>> this, correct?
>>
>> >
>> >
>> > On Tue, Jul 3, 2012 at 1:39 PM, Larry Martell 
>> > wrote:
>> >>
>> >> I have a client that asked me to add some new functionality to their
>> >> app, and then they said 'This new functionality should be controlled
>> >> in Django admin so that only the admin user can see it.' Is there a
>> >> way to control this in Django admin? I know in the python code i can
>> >> check to see if they're the admin user or not and allow or disallow
>> >> access, but what they're saying makes it seem I can just do it admin.
>> >>
>> >> --
>> >> 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.
>> >>
>> >
>> >
>> >
>> > --
>> > Bust0ut, Surgemcgee: Systems Engineer ---
>> > PBDefence.com
>> > BudTVNetwork.com
>> > RadioWeedShow.com
>> > "Bringing entertainment to Unix"
>> >
>> > --
>> > 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.
>>
>> --
>> 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.
>>
>
>
>
> --
> Bust0ut, Surgemcgee: Systems Engineer ---
> PBDefence.com
> BudTVNetwork.com
> RadioWeedShow.com
> "Bringing entertainment to Unix"
>
> --
> 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.

-- 
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: how to save response 's render file to server or email using httpresponse

2012-07-03 Thread Nikolas Stevenson-Molnar
The content is already rendered when you pass it to your HttpResponse
object. Therefore, I would just write it out prior to creating/returning
the response object. E.g., if you're using a template:

t = get_template("foo.html")
c = Context({...})
content = t.render(c)
f = open('somefile.txt', 'w')
f.write(content)
f.close()
return HttpResponse(content)

However, from the error you mention, it sounds like your either a)
treating an integer like a string somewhere, or b) you are passing an
integer to a function which is expecting a string. Somewhere, something
like this is happening:

a = 5
a.lower() #<-- error

_Nik

On 7/3/2012 11:20 AM, Min Hong Tan wrote:
> hi,
>
> I have a problem to send mail using Emailmessage,
> i wan to attach the file that render using httpresponse and send, but
> always show me "int" does not have method "lower".
> therefore, I think to save the file in the server and then attach
> using emailmessage.  but how do i get the httpresonse to save
> in server /tmp/file  ? 
>
> Regards,
> MH
> -- 
> 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.


-- 
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.



how to save response 's render file to server or email using httpresponse

2012-07-03 Thread Min Hong Tan
hi,

I have a problem to send mail using Emailmessage,
i wan to attach the file that render using httpresponse and send, but
always show me "int" does not have method "lower".
therefore, I think to save the file in the server and then attach using
emailmessage.  but how do i get the httpresonse to save
in server /tmp/file  ?

Regards,
MH

-- 
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: Looking for common practice suggestion.

2012-07-03 Thread Brian Schott
An intermediate approach would be to generate an initial_data.json/yaml file 
and place it in your project's fixtures directory.  This at least should be 
database independent.
https://docs.djangoproject.com/en/dev/howto/initial-data/

Brian Schott
bfsch...@gmail.com



On Jul 3, 2012, at 1:33 PM, Robert Steckroth wrote:

> Hey Gang, I am writing a framework to install django projects to the cloud. 
> Currently I have the user specifying
> the site domain and site name in a config file for the django.sites framework 
> and providing the site_id in settings.py.
> Personally, I change the django.sites entries by issuing mysql commands to 
> the database.
> Can any of you provide the most common/best way that the django.sites object 
> is created?
> Is it usually provided in the settings.py file? Or is a database change your 
> current method?
> The docs don't seem to get into how this object get created. Also, is this 
> object created with the syncdb command?
> Much thanks to any help.
> 
> -- 
> Bust0ut, Surgemcgee: Systems Engineer ---
> PBDefence.com
> BudTVNetwork.com
> RadioWeedShow.com
> "Bringing entertainment to Unix"
> 
> 
> -- 
> 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.

-- 
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: Looking for common practice suggestion.

2012-07-03 Thread Robert Steckroth
Well, I guess the user will have to specify the domain and name in the
config file.
I was hoping the information could be provided in the settings file. Only
other way is the
admin system which isn't necessary for an otherwise completely automated
process.

On Tue, Jul 3, 2012 at 1:33 PM, Robert Steckroth
wrote:

> Hey Gang, I am writing a framework to install django projects to the
> cloud. Currently I have the user specifying
> the site domain and site name in a config file for the django.sites
> framework and providing the site_id in settings.py.
> Personally, I change the django.sites entries by issuing mysql commands to
> the database.
> Can any of you provide the most common/best way that the
> django.sites object is created?
> Is it usually provided in the settings.py file? Or is a database change
> your current method?
> The docs don't seem to get into how this object get created. Also, is this
> object created with the syncdb command?
> Much thanks to any help.
>
> --
> Bust0ut, Surgemcgee: Systems Engineer ---
> PBDefence.com
> BudTVNetwork.com
> RadioWeedShow.com
> "Bringing entertainment to Unix"
>
>


-- 
Bust0ut, Surgemcgee: Systems Engineer ---
PBDefence.com
BudTVNetwork.com
RadioWeedShow.com
"Bringing entertainment to Unix"

-- 
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: admin addGroup similar layout

2012-07-03 Thread Melvyn Sopacua
On 1-7-2012 16:32, ledzgio wrote:

> I would like to have a layout similar to the one in the Admin page --> 
> Groups --> Add Group, the Permissions field, where I can have all elements 
> of a table throw a foreignKey (I suppose) on the left and add them to the 
> right side. 



If you need it outside the admin, trace down the filter_horizontal
attribute to the widget. Not in a position to do that right now.
-- 
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: am new bird to django,need some suggestion...please please do reply friend..

2012-07-03 Thread manish girdhar
hmmm sorry guysreally appreciated your point..i will surely do
that..even i have started with that..

On Tue, Jul 3, 2012 at 12:00 AM, Daniel Roseman wrote:

> On Monday, 2 July 2012 18:38:12 UTC+1, rick wrote:
>>
>> h i will try my best.actually i have already read that
>> documentation but when i went to make application,then i got problem in
>> using filter functions..and this kind of functions are not mentioned in the
>> documentation.thats why i was facing problem.anyhow i will again
>> read this...but friend can you send me the link of a basic small
>> application..so that i just hang into that...
>>
>
> Seriously, people here are rapidly going to stop being your "friend" if
> you don't do the minimum to help yourself. I've already pointed you to the
> actual documentation, where those functions *are* not only mentioned but
> fully explained. If you choose not to read it, that's up to you, but you
> shouldn't then expect people to help you.
> --
> DR.
>
> --
> 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/-/Hp4fZubovAAJ.
>
> 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: Use regular expression to retrieve all image tags from a given content

2012-07-03 Thread Melvyn Sopacua
On 30-6-2012 15:23, Sunny Nanda wrote:
> You can try the following two suggestions:
> 
> 1. Try removing the "^" from the pattern and match only r" that the image tag might not be coming at the start of the string.

That, and re.match is bound to the start of the string. See:
http://docs.python.org/release/2.7.2/library/re.html#search-vs-match

What you're looking for is:
prog = re.compile(r'')
matches = re.search(prog)
for match in matches :
print match

> On a sidenote, you should not be using regular expressions if you are doing 
> anything complex that what you are doing right now.

This isn't complex. The email validator in django is complex. Using an
XML parser for this is quite overkill. If you need several elements
based on their nesting and/or sister elements, then an XML parser makes
more sense, or better xpath queries. This is simple stuff for regular
expressions and what they're made for.

-- 
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: Controlling access

2012-07-03 Thread Robert Steckroth
Django is a very open-ended framework. The admin system is built around
developer/user customization.



On Tue, Jul 3, 2012 at 1:51 PM, Larry Martell wrote:

> On Tue, Jul 3, 2012 at 11:49 AM, Robert Steckroth
>  wrote:
> > Yes, I have seen some very impressive admin media controls for websites
> with
> > larger projects
> > having wordpress like functionality. However, there are not easy
> or cheap to
> > make.
> > I recommend checking open-souce projects for a good start.
>
> But there's nothing inherently built into Django admin that supports
> this, correct?
>
> >
> >
> > On Tue, Jul 3, 2012 at 1:39 PM, Larry Martell 
> > wrote:
> >>
> >> I have a client that asked me to add some new functionality to their
> >> app, and then they said 'This new functionality should be controlled
> >> in Django admin so that only the admin user can see it.' Is there a
> >> way to control this in Django admin? I know in the python code i can
> >> check to see if they're the admin user or not and allow or disallow
> >> access, but what they're saying makes it seem I can just do it admin.
> >>
> >> --
> >> 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.
> >>
> >
> >
> >
> > --
> > Bust0ut, Surgemcgee: Systems Engineer ---
> > PBDefence.com
> > BudTVNetwork.com
> > RadioWeedShow.com
> > "Bringing entertainment to Unix"
> >
> > --
> > 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.
>
> --
> 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.
>
>


-- 
Bust0ut, Surgemcgee: Systems Engineer ---
PBDefence.com
BudTVNetwork.com
RadioWeedShow.com
"Bringing entertainment to Unix"

-- 
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: Django Developer, Washington, D.C.

2012-07-03 Thread Robert Steckroth
There are jobs available in Minnesota for any interested as well. More info
can be found here -->
http://www.comfychairconsulting.com/


On Tue, Jul 3, 2012 at 11:09 AM, Jon Black  wrote:

> And also on http://djangogigs.com/
> --
> Jon Black
> www.jonblack.org
>
>
> On Tue, Jul 3, 2012, at 11:03, Itamar Reis Peixoto wrote:
> > On Tue, Jul 3, 2012 at 10:43 AM, Andrew Moore  >
> > wrote:
> > > Hello group.
> > >
> > > National Geographic is seeking Django developers, for permanent
> full-time
> > > positions at their Washington, D.C. headquarters.
> > >
> > > If I can share more details, please let me know.
> propensitygr...@gmail.com
> > > or and...@themidtowngroup.com.
> > >
> > > Thanks!
> > >
> >
> >
> > I think you can post this job at python.org job board.
> >
> >
> >
> >
> > --
> > 
> >
> > Itamar Reis Peixoto
> > msn, google talk: ita...@ispbrasil.com.br
> > +55 11 4063 5033 (FIXO SP)
> > +55 34 9158 9329 (TIM)
> > +55 34 8806 3989 (OI)
> > +55 34 3221 8599 (FIXO MG)
> >
> > --
> > 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.
> >
>
> --
> 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.
>
>


-- 
Bust0ut, Surgemcgee: Systems Engineer ---
PBDefence.com
BudTVNetwork.com
RadioWeedShow.com
"Bringing entertainment to Unix"

-- 
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: Controlling access

2012-07-03 Thread Larry Martell
On Tue, Jul 3, 2012 at 11:49 AM, Robert Steckroth
 wrote:
> Yes, I have seen some very impressive admin media controls for websites with
> larger projects
> having wordpress like functionality. However, there are not easy or cheap to
> make.
> I recommend checking open-souce projects for a good start.

But there's nothing inherently built into Django admin that supports
this, correct?

>
>
> On Tue, Jul 3, 2012 at 1:39 PM, Larry Martell 
> wrote:
>>
>> I have a client that asked me to add some new functionality to their
>> app, and then they said 'This new functionality should be controlled
>> in Django admin so that only the admin user can see it.' Is there a
>> way to control this in Django admin? I know in the python code i can
>> check to see if they're the admin user or not and allow or disallow
>> access, but what they're saying makes it seem I can just do it admin.
>>
>> --
>> 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.
>>
>
>
>
> --
> Bust0ut, Surgemcgee: Systems Engineer ---
> PBDefence.com
> BudTVNetwork.com
> RadioWeedShow.com
> "Bringing entertainment to Unix"
>
> --
> 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.

-- 
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: Controlling access

2012-07-03 Thread Robert Steckroth
Yes, I have seen some very impressive admin media controls for websites
with larger projects
having wordpress like functionality. However, there are not easy or cheap
to make.
I recommend checking open-souce projects for a good start.


On Tue, Jul 3, 2012 at 1:39 PM, Larry Martell wrote:

> I have a client that asked me to add some new functionality to their
> app, and then they said 'This new functionality should be controlled
> in Django admin so that only the admin user can see it.' Is there a
> way to control this in Django admin? I know in the python code i can
> check to see if they're the admin user or not and allow or disallow
> access, but what they're saying makes it seem I can just do it admin.
>
> --
> 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.
>
>


-- 
Bust0ut, Surgemcgee: Systems Engineer ---
PBDefence.com
BudTVNetwork.com
RadioWeedShow.com
"Bringing entertainment to Unix"

-- 
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.



Controlling access

2012-07-03 Thread Larry Martell
I have a client that asked me to add some new functionality to their
app, and then they said 'This new functionality should be controlled
in Django admin so that only the admin user can see it.' Is there a
way to control this in Django admin? I know in the python code i can
check to see if they're the admin user or not and allow or disallow
access, but what they're saying makes it seem I can just do it admin.

-- 
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.



Looking for common practice suggestion.

2012-07-03 Thread Robert Steckroth
Hey Gang, I am writing a framework to install django projects to the cloud.
Currently I have the user specifying
the site domain and site name in a config file for the django.sites
framework and providing the site_id in settings.py.
Personally, I change the django.sites entries by issuing mysql commands to
the database.
Can any of you provide the most common/best way that the
django.sites object is created?
Is it usually provided in the settings.py file? Or is a database change
your current method?
The docs don't seem to get into how this object get created. Also, is this
object created with the syncdb command?
Much thanks to any help.

-- 
Bust0ut, Surgemcgee: Systems Engineer ---
PBDefence.com
BudTVNetwork.com
RadioWeedShow.com
"Bringing entertainment to Unix"

-- 
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: Still need help with the 405....please

2012-07-03 Thread Nikolas Stevenson-Molnar
I'm not sure that this is the problem, but typically constructors should
not have a return value. Try removing the "return" from your
DjangoSoapApp constructor.

_Nik

On 7/3/2012 6:32 AM, Jeff Silverman wrote:
> Below is the code from the views.py
>
> The 405 is retunred from the 'return super(DjangoSoapApp,
> self).__init__(Application(services, tns))' statement.  I am using
> python 2.6, soaplib20 and django 1.3.  I am struggling to understand
> what exactly is wrong here.
>
>
>
> class HelloWorldService(DefinitionBase):
> @soap(String,Integer,_returns=Array(String))
> def say_smello(self,name,times):
> results = []
> for i in range(0,times):
> results.append('Hello, %s'%name)
> return results
>
> class DjangoSoapApp(WSGIApplication):
> csrf_exempt = True
>
> def __init__(self, services, tns):
> """Create Django view for given SOAP soaplib services and
> tns"""
>
> return super(DjangoSoapApp,
> self).__init__(Application(services, tns))
>
> def __call__(self, request):
> django_response = HttpResponse()
>
> def start_response(status, headers):
> django_response.status_code = int(status.split(' ', 1)[0])
> for header, value in headers:
> django_response[header] = value
>
> response = super(DjangoSoapApp, self).__call__(request.META,
> start_response)
> django_response.content = '\n'.join(response)
>
> return django_response
>
> # the view to use in urls.py
> hello_world_service = DjangoSoapApp([HelloWorldService], '__name__')
>


-- 
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.



Inheriting template with a form into an existing template

2012-07-03 Thread DF
I have a simple note taking part of my application I'm trying to converge 
into one template. Currently, I have one template and view that renders and 
posts the form and another that displays the results. I'd like to 
amalgamate these into one where the form exists and the results are 
displayed on the same page.

This seems to be something that be achieved with template inheritance, but 
I'm not sure how to alter the views so that both of these results can 
appear in the same template. I've looked around for answers but can't seem 
to find what I need to achieve this. Any help that could also inform me on 
how to properly achieve this moving forward would be appreciated. This is 
one of those areas I've been anticipating learning but it's been more 
difficult that I assumed. The essential code is posted below:

Views for submitting and displaying notes:

@login_required
def submit_note(request):
if request.method == 'POST':
notes_form = NotesForm(request.POST, request.FILES)
if notes_form.is_valid():
new_note = notes_form.save(commit=False)
new_note.author = request.user
new_note.save()
return HttpResponseRedirect( "" )
else:
notes_form = NotesForm()
return render_to_response("write_note/notes.html", {'form': 
notes_form}, context_instance=RequestContext(request))

@login_required
def all_notes(request):
all_notes = Notes.objects.all().order_by('-date')
paginate = paginated_stories(request, all_notes)
return render_to_response("report/notes.html",
   {'notes': paginate},
context_instance=RequestContext(request))

Current basic templates to submit and display:

{% extends 'base.html' %}
{% block page_title %}Notebook{% endblock %}
{% block headline %}Notebook{% endblock %}
{% block content %}
Write and save notes, quotes and other story info



{% csrf_token %}
{{ form.as_p }}





{% endblock %}

{% extends 'base.html' %}
{% block page_title %}Notebook{% endblock %}
{% block headline %}Notebook{% endblock %}

{% block content %}


{% if notes %}
{% for note in user.notes.all reversed %}
{{ note.title }}
{{ note.date }}
{{ note.copy }}
{% endfor %}
 {% else %}
You have no notes stored.
 {% endif %}


{% endblock content %}

And the two urls:

url(r'^write_note/$', 'stentorian.report.views.submit_note', 
name='write_note'),
url(r'^notes/', 'stentorian.report.views.all_notes', name='all_notes')

-- 
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/-/IG6vV9MaSVoJ.
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.



get_or_create() race condition MySQL - second fix!

2012-07-03 Thread Cal Leeming [Simplicity Media Ltd]
Hi guys,

A while ago we released a monkey patch which resolved the get_or_create()
race condition when used in combination with READ COMMITED transaction
isolation.

However, this caused issues with legacy applications, so we have released a
new fix that works without READ COMMITED.

The code snippet can be found here, along with details:
https://code.djangoproject.com/ticket/18557

Thanks

Cal

-- 
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: Django Developer, Washington, D.C.

2012-07-03 Thread Jon Black
And also on http://djangogigs.com/
-- 
Jon Black
www.jonblack.org


On Tue, Jul 3, 2012, at 11:03, Itamar Reis Peixoto wrote:
> On Tue, Jul 3, 2012 at 10:43 AM, Andrew Moore 
> wrote:
> > Hello group.
> >
> > National Geographic is seeking Django developers, for permanent full-time
> > positions at their Washington, D.C. headquarters.
> >
> > If I can share more details, please let me know. propensitygr...@gmail.com
> > or and...@themidtowngroup.com.
> >
> > Thanks!
> >
> 
> 
> I think you can post this job at python.org job board.
> 
> 
> 
> 
> -- 
> 
> 
> Itamar Reis Peixoto
> msn, google talk: ita...@ispbrasil.com.br
> +55 11 4063 5033 (FIXO SP)
> +55 34 9158 9329 (TIM)
> +55 34 8806 3989 (OI)
> +55 34 3221 8599 (FIXO MG)
> 
> -- 
> 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.
> 

-- 
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: Django Developer, Washington, D.C.

2012-07-03 Thread Itamar Reis Peixoto
On Tue, Jul 3, 2012 at 10:43 AM, Andrew Moore  wrote:
> Hello group.
>
> National Geographic is seeking Django developers, for permanent full-time
> positions at their Washington, D.C. headquarters.
>
> If I can share more details, please let me know. propensitygr...@gmail.com
> or and...@themidtowngroup.com.
>
> Thanks!
>


I think you can post this job at python.org job board.




-- 


Itamar Reis Peixoto
msn, google talk: ita...@ispbrasil.com.br
+55 11 4063 5033 (FIXO SP)
+55 34 9158 9329 (TIM)
+55 34 8806 3989 (OI)
+55 34 3221 8599 (FIXO MG)

-- 
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: Advices on what web programming language used in template?

2012-07-03 Thread Frankline
Hi Yu,

Your question is not really clear. Perhaps take a look at this:
https://docs.djangoproject.com/en/dev/topics/templates/

Since you have mentioned JSP, I'm thinking you are looking at Python/Django
alternatives. If that is the case, then you have the following alternatives:

- Ruby on Rails
- PHP
- Java/JSP/Spring or Struts and even JSF

But then again, it would help if you were more clear on what you need. This
is 'mostly' a Django forum.

Regards,
Frankline

-- 
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: Advices on what web programming language used in template?

2012-07-03 Thread Yu Min

于 2012年07月03日 19:09, kenneth gonsalves 写道:

could you clarify your question please? Do you want to know what
programming language is to be used in templates? Or do you want to know
what programming language is to be used to program templates?


Sorry for not make myself clear.
What I am wondering is, what programming language could be used in 
program the template. I know jsp probably is a good choice, but what 
other choices are there?

Thanks for hitting me up.


--
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.



Django Developer, Washington, D.C.

2012-07-03 Thread Andrew Moore
Hello group.

National Geographic is seeking Django developers, for permanent full-time 
positions at their Washington, D.C. headquarters.

If I can share more details, please let me know. propensitygr...@gmail.com 
or and...@themidtowngroup.com.

Thanks!

-- 
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/-/iVF2JPnZJOgJ.
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.



Still need help with the 405....please

2012-07-03 Thread Jeff Silverman
Below is the code from the views.py

The 405 is retunred from the 'return super(DjangoSoapApp,
self).__init__(Application(services, tns))' statement.  I am using
python 2.6, soaplib20 and django 1.3.  I am struggling to understand
what exactly is wrong here.



class HelloWorldService(DefinitionBase):
@soap(String,Integer,_returns=Array(String))
def say_smello(self,name,times):
results = []
for i in range(0,times):
results.append('Hello, %s'%name)
return results

class DjangoSoapApp(WSGIApplication):
csrf_exempt = True

def __init__(self, services, tns):
"""Create Django view for given SOAP soaplib services and
tns"""

return super(DjangoSoapApp,
self).__init__(Application(services, tns))

def __call__(self, request):
django_response = HttpResponse()

def start_response(status, headers):
django_response.status_code = int(status.split(' ', 1)[0])
for header, value in headers:
django_response[header] = value

response = super(DjangoSoapApp, self).__call__(request.META,
start_response)
django_response.content = '\n'.join(response)

return django_response

# the view to use in urls.py
hello_world_service = DjangoSoapApp([HelloWorldService], '__name__')

-- 
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: 'CSRF verification failed." from django.contrib.comments. can you help solve it? django 1.3

2012-07-03 Thread Melvyn Sopacua
On 30-6-2012 8:39, brycenesbitt wrote:

> {% csrf_token %}
> 
> I render my form with:
> {% render_comment_form for entry %}

You should verify if the generated html looks sane. If you need help
with that, put it up on dpaste.

> ---
> I should note it did work when I first added it to the application.  It 
> broke after I added pybbm.  I've since removed pybbm (it is maintained and 
> broken), but comments
> started getting csrf errors.

Any chance pybbm started messing with the session storage backend and
you haven't set it back correctly? Do any sessions work at all?

-- 
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: Filter FieldError

2012-07-03 Thread Saroja Parameswaran
That worked! Thank you!!

On Tue, Jul 3, 2012 at 4:33 PM, Jon Black  wrote:

>   I think you need a double underscore:
>
>  fieldname__startswith
>
>  On Tue, Jul 3, 2012, at 02:47, Saroja Parameswaran wrote:
>
>  While using filters on Django objects, I get the below error message.
> Except equals, all the other options like _startswith, _exact, _iexact
> shows the same error. I am using Django 1.4.
>
>
> FieldError: Cannot resolve keyword 'fieldname_exact' into field. Choices
> are:
>
>
>   Can anyone tell me the solution?
>
>
> --
> 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/-/NJDqAyZcunAJ.
> 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.
>

-- 
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: to add counter in the project

2012-07-03 Thread Bharati Sharma
sorry  kenneth ...but I have stored information(resume) of professors in
the database.
in models.py , i have taken fields like name, dob,
qualification,designation etc. then these are saved in the database of
every professor.
but the point is designation of professors vary(like there are professors,
assistant professors and associate professors).I want that it should count
 the no of   professors, assistant professors and associate
professors automatically and increments their value after I fill and save
the next resume in the database. Is there any logic like this...plz help
me. I shall be very thankfull.

On Tue, Jul 3, 2012 at 4:22 AM, kenneth gonsalves wrote:

> On Tue, 2012-07-03 at 04:16 -0700, Bharati Sharma wrote:
> > thanks  kenneth ...but will it count those entries also which I will
> > enter
> > in the database after using filter() and count()?
>
> if you want to know the number of assistant profs do a query like this:
>
> no_of_asstprofs =
> Faculty.objects.filter(job_title='AssistantProf').count()
>
> do not store this in the database - call it when you need it. If you
> have a counter, you need to maintain it - increment when adding, reduce
> when deleting - which also means setting up signals to adjust the
> counter when a model is changed. A huge waste of time and energy.
>
>
> --
> regards
> Kenneth Gonsalves
>
> --
> 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.
>
>

-- 
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: to add counter in the project

2012-07-03 Thread kenneth gonsalves
On Tue, 2012-07-03 at 04:16 -0700, Bharati Sharma wrote:
> thanks  kenneth ...but will it count those entries also which I will
> enter
> in the database after using filter() and count()? 

if you want to know the number of assistant profs do a query like this:

no_of_asstprofs =
Faculty.objects.filter(job_title='AssistantProf').count()

do not store this in the database - call it when you need it. If you
have a counter, you need to maintain it - increment when adding, reduce
when deleting - which also means setting up signals to adjust the
counter when a model is changed. A huge waste of time and energy.


-- 
regards
Kenneth Gonsalves

-- 
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: to add counter in the project

2012-07-03 Thread Bharati Sharma
thanks  kenneth ...but will it count those entries also which I will enter
in the database after using filter() and count()?

On Tue, Jul 3, 2012 at 4:06 AM, kenneth gonsalves wrote:

> On Tue, 2012-07-03 at 01:08 -0700, Bharati Sharma wrote:
> > actually I am making project of faculty management system of my
> > college.I
> > have added some of the faculty member's resume in the database. i want
> > a
> > counter in my project that should increment its value whenever a new
> > faculty member's resume is added into the database. yes, it will
> > require
> > filter also as i want it should count no of assistant professors,no of
> > associate professors etc seperatelyhelp me please..
>
> you are storing redundant data in the database - not good. If you want
> the number of assistant professors, use filter() and count().
> --
> regards
> Kenneth Gonsalves
>
> --
> 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.
>
>

-- 
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: to add counter in the project

2012-07-03 Thread Bharati Sharma
thanks jon...

On Tue, Jul 3, 2012 at 4:06 AM, kenneth gonsalves wrote:

> On Tue, 2012-07-03 at 01:08 -0700, Bharati Sharma wrote:
> > actually I am making project of faculty management system of my
> > college.I
> > have added some of the faculty member's resume in the database. i want
> > a
> > counter in my project that should increment its value whenever a new
> > faculty member's resume is added into the database. yes, it will
> > require
> > filter also as i want it should count no of assistant professors,no of
> > associate professors etc seperatelyhelp me please..
>
> you are storing redundant data in the database - not good. If you want
> the number of assistant professors, use filter() and count().
> --
> regards
> Kenneth Gonsalves
>
> --
> 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.
>
>

-- 
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: Advices on what web programming language used in template?

2012-07-03 Thread kenneth gonsalves
On Tue, 2012-07-03 at 15:30 +0800, Yu Min wrote:
> I'm going through django structure. And while struggling to 
> understand the django usage, I start to wonder what web programing 
> language goes well with the template system. 

could you clarify your question please? Do you want to know what
programming language is to be used in templates? Or do you want to know
what programming language is to be used to program templates?
-- 
regards
Kenneth Gonsalves

-- 
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: to add counter in the project

2012-07-03 Thread kenneth gonsalves
On Tue, 2012-07-03 at 01:08 -0700, Bharati Sharma wrote:
> actually I am making project of faculty management system of my
> college.I
> have added some of the faculty member's resume in the database. i want
> a
> counter in my project that should increment its value whenever a new
> faculty member's resume is added into the database. yes, it will
> require
> filter also as i want it should count no of assistant professors,no of
> associate professors etc seperatelyhelp me please.. 

you are storing redundant data in the database - not good. If you want
the number of assistant professors, use filter() and count(). 
-- 
regards
Kenneth Gonsalves

-- 
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: Filter FieldError

2012-07-03 Thread kenneth gonsalves
On Tue, 2012-07-03 at 02:47 -0700, Saroja Parameswaran wrote:
>  Can anyone tell me the solution?

double underscore __
-- 
regards
Kenneth Gonsalves

-- 
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: Filter FieldError

2012-07-03 Thread Jon Black
I think you need a double underscore:

fieldname__startswith

On Tue, Jul 3, 2012, at 02:47, Saroja Parameswaran wrote:

While using filters on Django objects, I get the below error
message. Except equals, all the other options like _startswith,
_exact, _iexact shows the same error. I am using Django 1.4.



  FieldError: Cannot resolve keyword 'fieldname_exact' into
  field. Choices are:



 Can anyone tell me the solution?


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To view this discussion on the web visit
  [1]https://groups.google.com/d/msg/django-users/-/NJDqAyZcunAJ
  .
  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.

References

1. https://groups.google.com/d/msg/django-users/-/NJDqAyZcunAJ

-- 
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: to add counter in the project

2012-07-03 Thread Jon Black
It sounds like you have different user's (User) with different
roles (Group with permission set) that have a resume:

class Resume(models.Model):
  resume = models.FileField()
  date_uploaded = models.DateTimeField()

You can then query by aggregating across the group and
date_uploaded fields. That's one option.

--
Jon Black
www.jonblack.org


On Tue, Jul 3, 2012, at 01:08, Bharati Sharma wrote:

  thanks Jon...

actually I am making project of faculty management system of my
college.I have added some of the faculty member's resume in the
database. i want a counter in my project that should increment
its value whenever a new faculty member's resume is added into
the database. yes, it will require filter also as i want it
should count no of assistant professors,no of associate
professors etc seperatelyhelp me please..
On Tue, Jul 3, 2012 at 12:48 AM, Jon Black <[1]jon_bl...@mm.st>
wrote:

That's quite a vague requirement. You could override form_valid()
in your view and increment a counter in your model manually
before saving. It might pay to ask yourself why you need a
counter. Does it make more sense to record the actions in a
separate table and count the records? Will the count require
filtering later (e.g. number of counts each month, week, day).

--
Jon Black
[2]www.jonblack.org


On Mon, Jul 2, 2012, at 23:25, Bharati Sharma wrote:

I want to add counter in my project so that the value in the
table increases as the data is put in the database. Can anyone
help me plz.


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To post to this group, send email to
  [3]django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  [4]django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  [5]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
  [6]django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  [7]django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  [8]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.

References

1. mailto:jon_bl...@mm.st
2. http://www.jonblack.org/
3. mailto:django-users@googlegroups.com
4. mailto:django-users%2bunsubscr...@googlegroups.com
5. http://groups.google.com/group/django-users?hl=en
6. mailto:django-users@googlegroups.com
7. mailto:django-users%2bunsubscr...@googlegroups.com
8. 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.



values() and order_by()

2012-07-03 Thread J. Javier Maestro
Hi there!

I have the following model:

  class Visit(models.Model):
  user = models.ForeignKey(User)
  visitor = models.ForeignKey(User, related_name="visitor")
  last_visit = models.DateTimeField(default=timezone.now())
  count_visits = models.IntegerField(default=0)

I would like to make the following SQL query using the Django ORM:

  SELECT last_visit, SUM(count_visits) AS total_count_visits
  FROM core_visit
  WHERE user_id=42
  GROUP BY user_id
  ORDER BY last_visit DESC

So far, I haven't been able to do it. When I use values('user') and
order_by('-last_visit') the last_visit column is automatically added
to the GROUP BY clause. I've read in the Django doc that this is how
it's supposed to be but I can't seem to understand it. Why do I have
to group the results by whatever I choose as order? What am I missing?

Also, I know I can do a RawQuerySet but unfortunately, I would like to
be able to use a full QuerySet (this query goes into Tastypie and so
far, I haven't been successful in using it with anything but full
QuerySets, not even ValueQuerySets...)

All help and ideas would be greatly appreciated.

Thanks a lot in advanced,

-- 
J. Javier Maestro 

-- 
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.



Advices on what web programming language used in template?

2012-07-03 Thread Yu Min

hi, guys
   I'm going through django structure. And while struggling to 
understand the django usage, I start to wonder what web programing 
language goes well with the template system.

   Will you guys kindly enough to give me some advice on this please!

--
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.



Filter FieldError

2012-07-03 Thread Saroja Parameswaran
While using filters on Django objects, I get the below error message. 
Except equals, all the other options like _startswith, _exact, _iexact 
shows the same error. I am using Django 1.4. 
 

> FieldError: Cannot resolve keyword 'fieldname_exact' into field. Choices 
> are: 
>

 Can anyone tell me the solution?

-- 
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/-/NJDqAyZcunAJ.
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: to add counter in the project

2012-07-03 Thread Bharati Sharma
thanks Jon...
actually I am making project of faculty management system of my college.I
have added some of the faculty member's resume in the database. i want a
counter in my project that should increment its value whenever a new
faculty member's resume is added into the database. yes, it will require
filter also as i want it should count no of assistant professors,no of
associate professors etc seperatelyhelp me please..

On Tue, Jul 3, 2012 at 12:48 AM, Jon Black  wrote:

>  That's quite a vague requirement. You could override form_valid() in your
> view and increment a counter in your model manually before saving. It might
> pay to ask yourself why you need a counter. Does it make more sense to
> record the actions in a separate table and count the records? Will the
> count require filtering later (e.g. number of counts each month, week, day).
>
>  --
>  Jon Black
>  www.jonblack.org
>
>
>  On Mon, Jul 2, 2012, at 23:25, Bharati Sharma wrote:
>
> I want to add counter in my project so that the value in the table
> increases as the data is put in the database. Can anyone help me plz.
>
>
> --
> 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.
>
>
>
> --
> 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.
>

-- 
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.



Use django and xml to communicate whith ORI-OAI

2012-07-03 Thread nef
Hello,
I am working with django and I have a medium level. I want to use xml to 
interchange data with an application that already exists. This application 
is ORI-OAI. This is an application that advertises the information in the 
field of education, especially in France. Only I do not know yet used xml 
with django. I would like a link or a tutorial for me to start.

-- 
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/-/nXb63Ko77W0J.
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: Deployment: Apache2, wsgi (Debian squeeze)

2012-07-03 Thread Rohan
If you change '/django' to '/' in your WSGIScriptAlias directive, then 
everything will be forwarded to django, but apache will no longer check 
in DocumentRoot since all url paths begin with a '/' and will be matched 
by your wsgi alias


This means you would need another way of handling static content that 
doesn't need to be rendered by django. I personally use an nginx proxy 
in front of apache which serves static content directly and forwards 
dynamic requests to apache.


In answer to your question of how you handle the same problem through 
urls.py, you can use the django static files app as explained in 
https://docs.djangoproject.com/en/dev/howto/static-files/


For example, having the following in urls.py

url(r'^media/(?P.*)$', 'django.views.static.serve', 
{'document_root': settings.MEDIA_ROOT,}),


lets django serve requests beginning with '/media' directly if your 
media files are located at MEDIA_ROOT simlar to how apache serves 
content from DocumentRoot. However, as the django documentation 
explains, this is highly inefficient, and NOT recommended for production 
since webservers do a better job of handling static content. As Kenneth 
suggested, setting up a virtual host in apache is an excellent way to 
start off.


On 7/3/2012 3:30 AM, kenneth gonsalves wrote:

On Tue, 2012-07-03 at 15:03 +1200, Matt Smith wrote:

Now I feel I'm stuck
between that old way of doing things and the django/wsgi way which I
can't get my head around even after reading the docs.

I would suggest that you start with trying to understand the concept of
virtual host in Apache. Try to set up a virtual host serving static
content at the start and once you understand that, things will start
falling in place (I am from a similar background from you, and thats how
I did it.



--
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: to add counter in the project

2012-07-03 Thread Sandeep kaur
On Tue, Jul 3, 2012 at 11:55 AM, Bharati Sharma  wrote:
> I want to add counter in my project so that the value in the table increases
> as the data is put in the database. Can anyone help me plz.
>
If you want a counter in database, you can make it auto-increment.
Like I want job_no as a counter field in a table, then in models.py, add this :

job_no = models.AutoField(primary_key=True)

But if you want the counter in tables in the template file then add
{{forloop.counter}} as your table field.

Correct me if I am wrong anywhere.

-- 
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: Can't figure out how to obtain organized list of my friends

2012-07-03 Thread Jon Black
I agree with Kenneth. Your models seem odd. Why not use a
ManyToManyField? The django docs even provides quite a nice example
(see:
https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ManyToManyField.symmetrical):

  class Person(models.Model):
  friends = models.ManyToManyField("self")

You could adapt this to your UserProfile I suppose.

-- 
Jon Black
www.jonblack.org


On Tue, Jul 3, 2012, at 12:57, kenneth gonsalves wrote:
> On Mon, 2012-07-02 at 20:31 -0700, Keith D. Cardin wrote:
> > I'm trying to create a "my friends" page, which will list the user's 
> > friends listed in alphabetical order.
> > I have two classes involved with this data: Profile [and] Friendship
> > 
> > *class Friendship(models.Model):*
> > friend= models.ForeignKey(User,
> > related_name='friend1')
> > friendwith  = models.ForeignKey(User,
> > related_name='friend2')
> > 
> > *class Profile(models.Model):*
> > user = models.OneToOneField(User,
> > unique=True,
> > verbose_name=_('user'),
> > related_name='profile')
> > first_name   = models.TextField(max_length=50)
> > last_name   = models.TextField(max_length=50)
> > 
> > The exact raw SQL query [successfully tested] is as follows:: 
> > *select profiles_profile.first_name,profiles_profile.last_name FROM 
> > profiles_profile, friends_friendship WHERE profiles_profile.user_id = 
> > friends_friendship.friendwith_id AND friends_friendship.friend_id =
> > 30 
> > ORDER BY first_name ASC;*
> > *
> > *
> > My problem is I'm not sure how to do this in Python. 
> > '30' is the user's id/pk. 
> 
> to get a list of friends of a particular user this may work:
> 
> first get the user:
> me = Profile.objects.get(user = myuser)
> 
> then get the friend1
> friends = me.fiiend1_set.all()
> 
> the confusing thing about your models is that it seems to me that your
> Friendship model should be split into two models.
> -- 
> regards
> Kenneth Gonsalves
> 
> -- 
> 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.
> 

-- 
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: to add counter in the project

2012-07-03 Thread Jon Black
That's quite a vague requirement. You could override form_valid()
in your view and increment a counter in your model manually
before saving. It might pay to ask yourself why you need a
counter. Does it make more sense to record the actions in a
separate table and count the records? Will the count require
filtering later (e.g. number of counts each month, week, day).

--
Jon Black
www.jonblack.org


On Mon, Jul 2, 2012, at 23:25, Bharati Sharma wrote:

  I want to add counter in my project so that the value in the
  table increases as the data is put in the database. Can anyone
  help me plz.


  --
  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.

-- 
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: Same virtual-env for all django projects

2012-07-03 Thread Jon Black
Bear in mind that you may want different packages in your
environments depending on the project. For example, you may have
a project that uses a maps app (from pip) which isn't required by
others. The general purpose of virtualenv is to setup clean,
self-contained environments. What would you do if one project had
a dependency that required a new version of another package that
another project can't use. :) Moreover, if you start using
virtualenvwrapper hooks (e.g. switch to the project directory
when 'workon' is called), it won't make sense anymore if you
share an environment.

Maybe I'm being a bit extreme, but it was a thought. Only you can
judge your needs.

--
Jon Black
www.jonblack.org


On Mon, Jul 2, 2012, at 16:19, Smaran Harihar wrote:

  Thanks Musicman

On Mon, Jul 2, 2012 at 4:17 PM, Lachlan Musicman
<[1]data...@gmail.com> wrote:

On Tue, Jul 3, 2012 at 10:52 AM, Smaran Harihar
<[2]smaran.hari...@gmail.com> wrote:
> Hi Djangoers,
>
> I am using virtual-env for my django project and I wanted to
know that is it
> ok to use the same virtual-env for all the django projects on
my system?
>
> or do I need to create a virtual-env for every other django
project?


  Of course you can! It's not necessarily a good idea for
  production
  sites, but it is fine.
  Cheers
  L.
  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To post to this group, send email to
  [3]django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  [4]django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  [5]http://groups.google.com/group/django-users?hl=en.




  --
  Thanks & Regards

Smaran Harihar


  --
  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.

References

1. mailto:data...@gmail.com
2. mailto:smaran.hari...@gmail.com
3. mailto:django-users@googlegroups.com
4. mailto:django-users%2bunsubscr...@googlegroups.com
5. 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: Deployment: Apache2, wsgi (Debian squeeze)

2012-07-03 Thread kenneth gonsalves
On Tue, 2012-07-03 at 15:03 +1200, Matt Smith wrote:
> Now I feel I'm stuck 
> between that old way of doing things and the django/wsgi way which I 
> can't get my head around even after reading the docs. 

I would suggest that you start with trying to understand the concept of
virtual host in Apache. Try to set up a virtual host serving static
content at the start and once you understand that, things will start
falling in place (I am from a similar background from you, and thats how
I did it.
-- 
regards
Kenneth Gonsalves

-- 
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: Difficulties deploying Satchmo store

2012-07-03 Thread ionic drive
and is there any good reason why you go for django version 1.1?

or do you only not bother about framework versions?



On Mon, 2012-07-02 at 18:30 -0500, Jonathan Hayward wrote:

> Forgive me; I had already used search engine. The top (albeit 1.1)
> entry for "django wsgi tutorial", which did not reference later
> versions,
> was https://docs.djangoproject.com/en/1.1/howto/deployment/modwsgi/
> 
> 
> 
> My httpd.conf served up nothing but server errors (for this or any
> other site) when I had, uncommented,
> 
> 
> #
> #ServerName steampunk.stornge.com
> #ServerAdmin cjshayw...@pobox.com
> 
> 
> #
> #
> #Order deny,allow
> #allow from all
> #
> #
> 
> 
> #
> #WSGIPythonPath /home/jonathan/store/
> #WSGIScriptAlias / /home/jonathan/store/wsgi.py
> 
> 
> My wsgi.py file, with the last two lines changed, is:
> 
> 
> import os
> import sys
> 
> 
> os.environ.setdefault("DJANGO_SETTINGS_MODULE",
> "store.settings")
> 
> 
> # This application object is used by the development server
> # as well as any WSGI server configured to use this file.
> sys.path.append('/home/jonathan/store')
> import django.core.handlers.wsgi
> application = django.core.handlers.WSGIHandler()
> 
> 
> And a few days of Googling later, I find deployment more difficult
> than any other part of building a Django site. Could you lmgtfy a
> query whose top results will work?
> 
> 
> 
> On Mon, Jul 2, 2012 at 11:39 AM, ionic drive 
> wrote:
> 
> Dear Jonathan, 
> 
> I answer on Django as there is nothing Satchmo specific in
> your message.
> This link should help you on start up:
> http://lmgtfy.com/?q=mod_wsgi+django
> A developer with your skills really should know to ask
> straight forward questions and to use search engines.
> 
> Please Jonathan, your Signature is double the size of your
> email... 
> This is really hard for us to read!
> 
> good luck
> ionic
> 
> 
> 
> On Mon, 2012-07-02 at 07:53 -0500, Jonathan Hayward wrote: 
> 
> > I am trying to deploy a "Hello, world!" Satchmo store and have had 
> difficulties under Apache with mod_wsgi, Gunicorn (fails immediately on 
> attempted start), and mod_fcgi (I can start the daemon on 127.0.0.1 port 
> 1234, but my attempt to get live web interaction didn't pan out. 
> > 
> > Part of my problem is that I haven't found mod_fcgi examples. Could 
> I have an example of a .fcgi file that says to connect to this port on this 
> IP, with indicators of any additional information needed (like the project 
> path or the deploy subdirectory.)
> > 
> >  Jonathan Hayward, Author, Django JavaScript Integration: AJAX and 
> jQuery
> >  Toastmaster and Published Author (Excellent Written and Oral 
> Communicator)
> >  Ajax, CGI, CMS, CSS, Django, HTML, IA, JSON, JavaScript, LAMP, 
> Linux, Perl, PHP, Python, SQL, UI, Unix, Usability, UX, XHTML, XML
> >  With a good interest in the human side of computing and making 
> software and websites a joy to use
> > 

-- 
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: Can't figure out how to obtain organized list of my friends

2012-07-03 Thread kenneth gonsalves
On Mon, 2012-07-02 at 20:31 -0700, Keith D. Cardin wrote:
> I'm trying to create a "my friends" page, which will list the user's 
> friends listed in alphabetical order.
> I have two classes involved with this data: Profile [and] Friendship
> 
> *class Friendship(models.Model):*
> friend= models.ForeignKey(User,
> related_name='friend1')
> friendwith  = models.ForeignKey(User,
> related_name='friend2')
> 
> *class Profile(models.Model):*
> user = models.OneToOneField(User,
> unique=True,
> verbose_name=_('user'),
> related_name='profile')
> first_name   = models.TextField(max_length=50)
> last_name   = models.TextField(max_length=50)
> 
> The exact raw SQL query [successfully tested] is as follows:: 
> *select profiles_profile.first_name,profiles_profile.last_name FROM 
> profiles_profile, friends_friendship WHERE profiles_profile.user_id = 
> friends_friendship.friendwith_id AND friends_friendship.friend_id =
> 30 
> ORDER BY first_name ASC;*
> *
> *
> My problem is I'm not sure how to do this in Python. 
> '30' is the user's id/pk. 

to get a list of friends of a particular user this may work:

first get the user:
me = Profile.objects.get(user = myuser)

then get the friend1
friends = me.fiiend1_set.all()

the confusing thing about your models is that it seems to me that your
Friendship model should be split into two models.
-- 
regards
Kenneth Gonsalves

-- 
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: Difficulties deploying Satchmo store

2012-07-03 Thread ionic drive
Dear Jonathan,

I know a lot of things about you... you are an Orthodox Christian
Author, your skills are Ajax, CGI, CMS, CSS, Django, HTML, IA, JSON,
JavaScript, LAMP, Linux, Perl, PHP, Python, SQL, UI, Unix, Usability,
UX, XHTML, XML,...
I know you only check the first results in search engines, I know you do
not investigate in alternative search terms...
This things I know, because you investigate a lot to tell us.

But I have no clue what you are going to achieve.
You do not ask specific questions.
I have no clue what servers you try to run. Apache, NGINX, Caudium,
Goron, Zope...

I did not tell you that this link will solve all your problems, it only
should help you to start going.

Jonathan my friend, this is not an easy task, you will need to
investigate more time in search engines and reading than in your
signature.
Sorry, but this are the hard facts.

Again good luck
io


On Mon, 2012-07-02 at 18:30 -0500, Jonathan Hayward wrote:

> Ajax, CGI, CMS, CSS, Django, HTML, IA, JSON, JavaScript, LAMP, Linux,
> Perl, PHP, Python, SQL, UI, Unix, Usability, UX, XHTML, XML

-- 
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.



Deployment: Apache2, wsgi (Debian squeeze)

2012-07-03 Thread Matt Smith

Hi,

I made a multi choice quiz using django and was able to deploy it at:

http://mattsmith.org.nz/django/test

Thanks to the community for making these tools available.

I am a self-taught programmer, this is the first time I have tried any 
web development so please be patient. I always find these groups 
intimidating but I really feel I have made a decent RTFM effort before 
making this post.


Here are some things I know nothing about:

Apache configuration.
How http actually works.

Up until now I've been serving non-dynamic content the usual way. I 
apt-got installed apache2, worked out /var/www was the root, followed 
the index.html convention and that worked fine. Now I feel I'm stuck 
between that old way of doing things and the django/wsgi way which I 
can't get my head around even after reading the docs. The development 
server experience hasn't helped me much when it comes to deployment.


I wanted to connect the quiz to http://mattsmith.org.nz/test instead of 
http://mattsmith.org.nz/django/test but I couldn't see how to do that.


I also want to convert the whole site to django so I can use child 
templates, but I cant work this out either.


I guess my main question is this:

Under the old scheme if someone types just my domain into their browser 
they get $DOCUMENT_ROOT/index.html, simple. What is the equivalent for 
the django/wsgi setup.? What do you put in urls.py?


After reading the docs (they all say different things) I ended up with 
the following setup:


/var/www/{oldStuff}
/var/django/dogscience/apache/django.wsgi

To help you help me you can see the following files from my system at 
http://mattsmith.org.nz/pleasehelp


/etc/apache2/httpd.conf
/var/django/dogscience/settings.py
/var/django/dogscience/urls.py
/var/django/dogscience/apache/django.wsgi

Thank you,

--
Matt Smith
http://mattsmith.org.nz

--
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.



to add counter in the project

2012-07-03 Thread Bharati Sharma
I want to add counter in my project so that the value in the table
increases as the data is put in the database. Can anyone help me plz.

-- 
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: Fw: PLEASE HELP

2012-07-03 Thread Emily
Hi every one,

I am so sorry but I am not the one that did that.
may be I should change my authentication details
to prevent this from happening again.

Emily

On Mon, Jul 2, 2012 at 8:57 PM, Larry Martell wrote:

> On Mon, Jul 2, 2012 at 11:45 AM, Cal Leeming [Simplicity Media Ltd]
>  wrote:
> > Emily,
> >
> > Please refrain from sending chain/spam emails to the list, this isn't
> > acceptable.
> >
> > Also - on a site note, you really shouldn't be giving out your entire
> > mailbox by cc'ing everyone, this isn't very good practice at all.
>
> I have a feeling that was caused by a virus or having her email hacked.
>
> --
> 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.
>
>

-- 
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.