Missing 'SITE_ID' breaks first Django app

2012-07-05 Thread DF
 

Hi. I just delayed my first Django app via Heroku and I'm having an issue 
that's proving very difficult to resolve. I have django-registration and 
profiles installed and apparently something runs afoul unless the 
'django.contrib.sites', and SITE_ID is removed from settings (this wasn't 
the case prior to deployment). Unfortunately, when content is submitted 
from a user to be displayed. I'm getting the following error:: 

TemplateSyntaxError at /Caught AttributeError while rendering: 'Settings' 
object has no attribute 'SITE_ID'. 

Adding these back just kills the whole app. Looking to see if anyone had 
any insight or advice on how to resolve this.

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

2012-07-05 Thread Larry Martell
On Thu, Jul 5, 2012 at 10:48 PM, Andy McKay  wrote:
>> I'm trying to use the Navigation Timing package to measure how long a
>> page takes to be rendered.
>
> So you don't want to include all the lookups? Just the "rendering" part?

Not sure what you mean by "lookups." I want to include everything
between when the server sends the data, to when the page is completely
generated (I'm using "rendered" to mean that). I'm trying to get a
metric on the delay the user experiences.

>> So that would be loadEventEnd-responseEnd,
>> however I am finding that loadEventEnd is always 0 for me, even though
>> I am accessing it from within a window.onload function, e.g:
>>
>> window.onload = function() {
>> var t = performance.timing;
>> var render_time = parseInt(t['loadEventEnd']) - 
>> parseInt(t['responseEnd']);
>> }
>>
>> What do I have to wait for before loadEventEnd gets set?
>
> Stupid question, but when does the onload event occur, before or after
> loadEventEnd?

>From looking at
https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html#processing-model
it seems that that loadEventEnd gets set when the onload event
completes. And from my testing it seems that window.onload fires
before that

> Running it in a console as I type this email, it gives me a non-zero value.

Yes, in a console I see that too. But programatically, I cannot seem
to capture loadEventEnd after it's set.

How did you do it in what you describe at
http://blog.mozilla.org/webdev/2012/01/06/timing-amo-user-experience/?

-- 
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: Render time

2012-07-05 Thread Andy McKay
> Thanks Andy. Super cool, and pretty much just what I was looking for.
> Seems to work fine in FF and Chrome, but in Safari I don't seem to
> have access to the performance.timing data. Should that be there or do
> I have do something to load or enable it?

Sadly, Safari does not support this :( You'd have to try and fake
this. Boomerang does this.

https://github.com/yahoo/boomerang

-- 
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: Render time

2012-07-05 Thread Andy McKay
> I'm trying to use the Navigation Timing package to measure how long a
> page takes to be rendered.

So you don't want to include all the lookups? Just the "rendering" part?

> So that would be loadEventEnd-responseEnd,
> however I am finding that loadEventEnd is always 0 for me, even though
> I am accessing it from within a window.onload function, e.g:
>
> window.onload = function() {
> var t = performance.timing;
> var render_time = parseInt(t['loadEventEnd']) - 
> parseInt(t['responseEnd']);
> }
>
> What do I have to wait for before loadEventEnd gets set?

Stupid question, but when does the onload event occur, before or after
loadEventEnd? Running it in a console as I type this email, it gives
me a non-zero value.

-- 
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-tagging | Filtering results

2012-07-05 Thread Barry Morrison


Total brain block. 

code: https://gist.github.com/2c70c0992ba14ded1593

The desired result is something like this

/favs/ will show all favorites (no tag cloud)

/favs/Source1

Will display tag cloud associated with only Source1

/favs/Source2

will display tag cloud associated with only Source2

I'm struggling to figure out how to filter on source to only display the 
tags associated with the source. 

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/-/M8W0Ub1u8SQJ.
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-05 Thread Nikolas Stevenson-Molnar
Yes, I would expect a 403 when the CSRF middleware is active, the
decorator is not used, and no CSRF token is provided. This is the
intended behavior. You can fix this in a few ways:

 1. Apply the decorator to the __call__ method (rather than to the class
itself). If I understand how this code works, that should correctly
disable CSRF for the view.
 2. Provide a CSRF value with the POST data, as you suggested. This all
depends on how the request is made. Django's CSRF system relies on a
CSRF value set in a cookie. You have to mimic a browsers cookie
functionality, then use the value of the CSRF cookie with evey
request you make. By default, the cookie name is 'csrftoken'. For
more info on the CSRF process:
https://docs.djangoproject.com/en/1.4/ref/contrib/csrf/
 3. Disable CSRF altogether. Simply remove the CsrfViewMiddleware from
your settings and you're good to go.

_Nik

On 7/5/2012 6:22 PM, Jeff Silverman wrote:
> Nik, if I remove the csrf decorator and leave the middleware in place,
> I get the 403.  Is there a way to add the token on the POST command,
> or is there another way of leaving the middleware in place, but turn
> off csrf without using the decorator?
>
> On Thursday, July 5, 2012 8:33:51 PM UTC-4, Jeff Silverman wrote:
>
> Nik, I will give that a try.  The reason for the decorator was
> that I was getting 403 forbidden, and the decorator made that one
> go away.  If I remove the csrf from the settings file, will that
> solve that problem?
>
>
> On Tuesday, July 3, 2012 9:32:20 AM UTC-4, 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 view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/WpDQ4UjGEQwJ.
> 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: Admin actions -- short_description as doc string?

2012-07-05 Thread Russell Keith-Magee
On Fri, Jul 6, 2012 at 9:06 AM, Melvyn Sopacua  wrote:
> On 6-7-2012 0:59, Russell Keith-Magee wrote:
>> On Thu, Jul 5, 2012 at 9:22 PM, Melvyn Sopacua  wrote:
>>> On 5-7-2012 2:02, Russell Keith-Magee wrote:
 The short_description is a label that can be used for display purposes --
 a 'human readable' version of the method name.
>>>
>>> Where is this used though? I've had the suspicion that the picture in
>>> the documentation needs updating, cause it doesn't show the
>>> short_description.
>>
>> An admin action shows up as the text in the pulldown where you select
>> the action you want to perform. It definitely works that way in
>> practice -- I'm looking at it working right now. Which picture do you
>> think is out of date?
>
> https://docs.djangoproject.com/en/1.4/_images/article_actions.png
>
> Code above states:
> make_published.short_description = "Mark selected stories as published"
>
> Image states: 'Make published'

Ok - That's definitely inconsistent. Would you be so kind as to open a
ticket for this?

Yours,
Russ Magee %-)

-- 
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-05 Thread Jeff Silverman
Nik, if I remove the csrf decorator and leave the middleware in place, I 
get the 403.  Is there a way to add the token on the POST command, or is 
there another way of leaving the middleware in place, but turn off csrf 
without using the decorator?

On Thursday, July 5, 2012 8:33:51 PM UTC-4, Jeff Silverman wrote:
>
> Nik, I will give that a try.  The reason for the decorator was that I was 
> getting 403 forbidden, and the decorator made that one go away.  If I 
> remove the csrf from the settings file, will that solve that problem?
>
>
> On Tuesday, July 3, 2012 9:32:20 AM UTC-4, 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/WpDQ4UjGEQwJ.
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 actions -- short_description as doc string?

2012-07-05 Thread Melvyn Sopacua
On 6-7-2012 0:59, Russell Keith-Magee wrote:
> On Thu, Jul 5, 2012 at 9:22 PM, Melvyn Sopacua  wrote:
>> On 5-7-2012 2:02, Russell Keith-Magee wrote:
>>> The short_description is a label that can be used for display purposes --
>>> a 'human readable' version of the method name.
>>
>> Where is this used though? I've had the suspicion that the picture in
>> the documentation needs updating, cause it doesn't show the
>> short_description.
> 
> An admin action shows up as the text in the pulldown where you select
> the action you want to perform. It definitely works that way in
> practice -- I'm looking at it working right now. Which picture do you
> think is out of date?

https://docs.djangoproject.com/en/1.4/_images/article_actions.png

Code above states:
make_published.short_description = "Mark selected stories as published"

Image states: 'Make published'
-- 
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: Acessing data on Model/Detail classes

2012-07-05 Thread Melvyn Sopacua
On 5-7-2012 21:46, Fabiano Martins wrote:

> I'm novice on Django, and I have a problem that I can't resolve through 
> documentation.
> 
> I like to make a validation on Model.clear() of the master class method based 
> on 
> data of your detail classes, but it returns always a empty set.
> 
> This example illustrates my problem:

>  def clean(self):
>  super(Master, self).clean()
>  total = 0
>  for product in self.product_set.all():
>  total += product.value

At clean() time nothing has been saved, so the relationship isn't there
yet and you can't ask for it. There are a few ways to solve it in
decreasing order:
- Use a custom template and write some javascript that calculates the
master value on submit.
- Write a custom view and calculate the totals there.
- Wrap everything in a transaction, do the validation in the post_save
signal and roll back the transaction if the total is too low (not even
sure this /can/ be done).

Maybe others have more ideas.
-- 
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: {% spaceless %} abuse (?)

2012-07-05 Thread David Lam
On Thu, Jul 5, 2012 at 5:00 PM, Russell Keith-Magee  wrote:

> On Fri, Jul 6, 2012 at 4:27 AM, David Lam  wrote:
> > hmm, kinda semi-noob, but heres my scenario
> >
> > I just started working on a fairly large Django project thats been around
> > for a couple years.
> >
> > In the templates,  I see a lot of use of {% spaceless %} tags whose
> apparent
> > function is solely to trim whitespace to reduce page size/page load time
> or
> > something.
> >
> > That's not really what it was made for right?
>
> Good question. I'm not really sure *what* it's supposed to be used
> for. Trimming whitespace to reduce page size is one possible use; the
> other is to 'humanize' the output of a block of template code that has
> a lot of control structures in it (i.e., a template with lots of {% if
> %} and {% for %} clauses will cause lots of blank lines and whitespace
> to be injected into a template, which is a bit messy and painful to
> read.
>
> However, for me, neither of these are particularly compelling uses.
>
> HTML code isn't supposed to be human readable, and all the modern
> tools (Firebug, Safari/Chrome inspect tools) parse the markup and show
> you DOM trees, not raw HTML code. And if you're worried about page
> size from a performance point of view, you're going to get much better
> results by turning on GZip compression in your response headers.
>
> So why is {% spaceless %} in the template language? Well, it was added
> in the early days of Django, when we were on a "accept everything in
> order to build community" drive. I suspect the thinking didn't go much
> further than "Yeah, I can see how that might be helpful; you've
> provided a patch, so lets add it".  With the benefit of hindsight, it
> probably isn't as useful as we originally hoped. Now it's there, and
> we'd have to go through a deprecation cycle (and probably a bunch of
> painful "But I *really* need it" arguments on django-dev), so it's
> easier to just live and let live.
>
> I haven't done any testing to be sure, but it certainly wouldn't
> surprise me if there's a non-trivial performance hit associated with
> using spaceless. If you're performance tuning a site, and you don't
> have any other reason for using spaceless (e.g., rendering a
> whitespace-significant output language), I wouldn't argue against
> removing uses of spaceless as a performance improvement.
>

ah cool,  thanks for the insight on the history of it

if it's really the case that {% spaceless %} shouldn't be used for
minifying white space on a page, I think it'd be useful to have a doc note
that discourages it or something -->
https://docs.djangoproject.com/en/dev/ref/templates/builtins/#spaceless

something like,  "If you wanna reduce page size, its better to use web
server gzip compression than to put {% spaceless %} tags everywhere.  The
spaceless tag was/is intended for... "

-- 
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-05 Thread Jeff Silverman
Nik, I will give that a try.  The reason for the decorator was that I was 
getting 403 forbidden, and the decorator made that one go away.  If I 
remove the csrf from the settings file, will that solve that problem?


On Tuesday, July 3, 2012 9:32:20 AM UTC-4, 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Li-smv_nBIgJ.
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: Converting to Postgres database; error with UserProfile model

2012-07-05 Thread Melvyn Sopacua
On 5-7-2012 19:06, DF wrote:

> django.db.utils.DatabaseError: relation "report_userprofile" does not exist
> LINE 1: INSERT INTO "report_userprofile" ("user_id", "first_name", "...
> 

[ ... ]

> This is the database model:
> 
> class UserProfile(models.Model):
> 
> user = models.OneToOneField(User, unique=True, related_name="profile")
> 
> first_name = models.CharField(max_length=25)
> 
> last_name = models.CharField(max_length=35)
> 
> email = models.EmailField()

Are you sure this model works? You use a one to one relationship but
duplicate the fields of the parent. Try running with an empty database
on your development machine and then run syncdb.

-- 
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: {% spaceless %} abuse (?)

2012-07-05 Thread Micky Hulse
On Thu, Jul 5, 2012 at 5:00 PM, Russell Keith-Magee
 wrote:
> Good question. I'm not really sure *what* it's supposed to be used
> for. Trimming whitespace to reduce page size is one possible use; the

If you develop for IE6, there's the IE6 whitespace bug. One fix, that
I know of, is to remove all whitespace around the HTML.

I never use the spaceless tag myself, but just thought I would mention
another way one could utilize the tag.

-- 
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: 1.4: Emails to BCC addresses not sent

2012-07-05 Thread Melvyn Sopacua
On 5-7-2012 19:44, Javi Romero wrote:
> Hi list, I'm new around though I've been developing Django sites since the 
> early 1.0 releases
> 
> I've been looking around for problems regarding email sending to BCC 
> addresses but can't find anything that explains what I'm seeing.

You've included a lot of information, except the mail log on the MTA
that django connects to and that's the crucial thing. You'll need to
verify if the bcc addresses are showing up to determine the guilty party.

Also, if you bcc something to a recipient already in the recipient list,
it is not guaranteed they receive two copies and even more likely that
they don't, so use addresses you know are good but not in the list already.
-- 
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: {% spaceless %} abuse (?)

2012-07-05 Thread Russell Keith-Magee
On Fri, Jul 6, 2012 at 4:27 AM, David Lam  wrote:
> hmm, kinda semi-noob, but heres my scenario
>
> I just started working on a fairly large Django project thats been around
> for a couple years.
>
> In the templates,  I see a lot of use of {% spaceless %} tags whose apparent
> function is solely to trim whitespace to reduce page size/page load time or
> something.
>
> That's not really what it was made for right?

Good question. I'm not really sure *what* it's supposed to be used
for. Trimming whitespace to reduce page size is one possible use; the
other is to 'humanize' the output of a block of template code that has
a lot of control structures in it (i.e., a template with lots of {% if
%} and {% for %} clauses will cause lots of blank lines and whitespace
to be injected into a template, which is a bit messy and painful to
read.

However, for me, neither of these are particularly compelling uses.

HTML code isn't supposed to be human readable, and all the modern
tools (Firebug, Safari/Chrome inspect tools) parse the markup and show
you DOM trees, not raw HTML code. And if you're worried about page
size from a performance point of view, you're going to get much better
results by turning on GZip compression in your response headers.

So why is {% spaceless %} in the template language? Well, it was added
in the early days of Django, when we were on a "accept everything in
order to build community" drive. I suspect the thinking didn't go much
further than "Yeah, I can see how that might be helpful; you've
provided a patch, so lets add it".  With the benefit of hindsight, it
probably isn't as useful as we originally hoped. Now it's there, and
we'd have to go through a deprecation cycle (and probably a bunch of
painful "But I *really* need it" arguments on django-dev), so it's
easier to just live and let live.

I haven't done any testing to be sure, but it certainly wouldn't
surprise me if there's a non-trivial performance hit associated with
using spaceless. If you're performance tuning a site, and you don't
have any other reason for using spaceless (e.g., rendering a
whitespace-significant output language), I wouldn't argue against
removing uses of spaceless as a performance improvement.

Yours,
Russ Magee %-)

-- 
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: Render time

2012-07-05 Thread Larry Martell
On Mon, Jun 25, 2012 at 9:04 PM, Andy McKay  wrote:
>> Now they want me to add to that how long
>> the browser takes to render the page after it gets the data.
>
> You can use the navigation timing API:
>
> https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html
>
> We use this in conjuction with graphite and django-statsd to produce
> graphs of hour long our sites takes to render.
>
> http://blog.mozilla.org/webdev/2012/01/06/timing-amo-user-experience/
>
> And some more links:
>
> https://github.com/andymckay/django-statsd
> http://django-statsd.readthedocs.org/en/latest/#front-end-timing-integration
> http://graphite.wikidot.com/

Andy-

I'm trying to use the Navigation Timing package to measure how long a
page takes to be rendered. So that would be loadEventEnd-responseEnd,
however I am finding that loadEventEnd is always 0 for me, even though
I am accessing it from within a window.onload function, e.g:

window.onload = function() {
var t = performance.timing;
var render_time = parseInt(t['loadEventEnd']) - parseInt(t['responseEnd']);
}

What do I have to wait for before loadEventEnd gets set?


Thanks!
-larry

-- 
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 actions -- short_description as doc string?

2012-07-05 Thread Russell Keith-Magee
On Thu, Jul 5, 2012 at 9:22 PM, Melvyn Sopacua  wrote:
> On 5-7-2012 2:02, Russell Keith-Magee wrote:
>> The short_description is a label that can be used for display purposes --
>> a 'human readable' version of the method name.
>
> Where is this used though? I've had the suspicion that the picture in
> the documentation needs updating, cause it doesn't show the
> short_description.

An admin action shows up as the text in the pulldown where you select
the action you want to perform. It definitely works that way in
practice -- I'm looking at it working right now. Which picture do you
think is out of date?

Yours,
Russ Magee %-)

-- 
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: Model for ListView needed?

2012-07-05 Thread Smaran Harihar
Thanks for the reply Luigi, but when should we use queryset and when should
we use model?


On Thu, Jul 5, 2012 at 3:25 PM, Luigi Castro wrote:

> They did not provide the model parameter because ca queryset was used,
> note the following line.
>
> queryset=Poll.objects.order_by**('-pub_date')[:5]
>
>
>
>
> On Thursday, July 5, 2012 1:13:38 PM UTC-6, Sam007 wrote:
>>
>> Hey Djangoers,
>>
>> In the fourth and last part of the Django tutorials,
>>
>> urlpatterns = patterns('',
>> url(r'^$',
>> ListView.as_view(
>> queryset=Poll.objects.order_by**('-pub_date')[:5],
>> context_object_name='latest_**poll_list',
>> template_name='polls/index.**html')),
>> url(r'^(?P\d+)/$',
>> DetailView.as_view(
>> model=Poll,
>> template_name='polls/detail.**html')),
>> url(r'^(?P\d+)/results/$',
>> DetailView.as_view(
>> model=Poll,
>> template_name='polls/results.**html'),
>> name='poll_results'),
>> url(r'^(?P\d+)/vote/$**', 'polls.views.vote'),)
>>
>>
>> There is a explanation that,
>>
>> "Each generic view needs to know what model it will be acting upon. This
>> is provided using the model parameter."
>>
>> But in the code above there was no 'model' parameter given for ListView?
>> So is model parameter only for DetailView? In the tutorial, was the generic
>> view suppose to be DetailView?
>>
>> --
>> Thanks & Regards
>> Smaran Harihar
>>
>>   --
> 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/-/VbSqnftQAVoJ.
> 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: Model for ListView needed?

2012-07-05 Thread Luigi Castro
They did not provide the model parameter because ca queryset was used, note 
the following line.

queryset=Poll.objects.order_by('-pub_date')[:5]




On Thursday, July 5, 2012 1:13:38 PM UTC-6, Sam007 wrote:
>
> Hey Djangoers,
>
> In the fourth and last part of the Django tutorials,
>
> urlpatterns = patterns('',
> url(r'^$',
> ListView.as_view(
> queryset=Poll.objects.order_by('-pub_date')[:5],
> context_object_name='latest_poll_list',
> template_name='polls/index.html')),
> url(r'^(?P\d+)/$',
> DetailView.as_view(
> model=Poll,
> template_name='polls/detail.html')),
> url(r'^(?P\d+)/results/$',
> DetailView.as_view(
> model=Poll,
> template_name='polls/results.html'),
> name='poll_results'),
> url(r'^(?P\d+)/vote/$', 'polls.views.vote'),)
>
>
> There is a explanation that,
>
> "Each generic view needs to know what model it will be acting upon. This 
> is provided using the model parameter."
>
> But in the code above there was no 'model' parameter given for ListView? 
> So is model parameter only for DetailView? In the tutorial, was the generic 
> view suppose to be DetailView?
>
> -- 
> Thanks & Regards
> Smaran Harihar
>
>  

-- 
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/-/VbSqnftQAVoJ.
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: check for edited views.py

2012-07-05 Thread Smaran Harihar
hmmm I guess you are right Nik. Will try it that way. Thanks

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

> Well, the only way to know for sure would be regression testing
> (http://en.wikipedia.org/wiki/Regression_testing). If the project makes
> use of the Django testing functionality
> (https://docs.djangoproject.com/en/1.4/topics/testing/), then you could
> just run the tests.
>
> Otherwise, you would need to look at what you changed and try to
> exercise any code that may have been affected. For example, if you added
> a view and only modified a single views.py file, then exercise some of
> the other views in that file and make sure they still work.
>
> The best thing to do would be to cut your teeth on a new project (where
> you wouldn't have to worry about making a mistake). Then, once you're
> more familiar with Django, come back to the existing project to make
> whatever changes are needed.
>
> _Nik
>
> On 7/5/2012 2:44 PM, Smaran Harihar wrote:
> > Hey Djangoers,
> >
> > I am messing around with a big django project and adding my view by
> > editing the views.py in the project code. This is the code that I have
> > added,
> >
> > def current_datetime(request):
> >now = datetime.datetime.now()
> >html = "It is now %s." % now
> >return HttpResponse(html)
> >
> > By this code you must have understood that I am a newbie. So what I
> > want to know, is there a way to check, If my editing the views.py has
> > created some error in the pre-existing project? How can I detect it?
> >
> > --
> > 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: check for edited views.py

2012-07-05 Thread Nikolas Stevenson-Molnar
Well, the only way to know for sure would be regression testing
(http://en.wikipedia.org/wiki/Regression_testing). If the project makes
use of the Django testing functionality
(https://docs.djangoproject.com/en/1.4/topics/testing/), then you could
just run the tests.

Otherwise, you would need to look at what you changed and try to
exercise any code that may have been affected. For example, if you added
a view and only modified a single views.py file, then exercise some of
the other views in that file and make sure they still work.

The best thing to do would be to cut your teeth on a new project (where
you wouldn't have to worry about making a mistake). Then, once you're
more familiar with Django, come back to the existing project to make
whatever changes are needed.

_Nik

On 7/5/2012 2:44 PM, Smaran Harihar wrote:
> Hey Djangoers,
>
> I am messing around with a big django project and adding my view by
> editing the views.py in the project code. This is the code that I have
> added,
>
> def current_datetime(request):
>now = datetime.datetime.now()
>html = "It is now %s." % now
>return HttpResponse(html)
>
> By this code you must have understood that I am a newbie. So what I
> want to know, is there a way to check, If my editing the views.py has
> created some error in the pre-existing project? How can I detect it?
>
> -- 
> 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.



check for edited views.py

2012-07-05 Thread Smaran Harihar
Hey Djangoers,

I am messing around with a big django project and adding my view by editing
the views.py in the project code. This is the code that I have added,

def current_datetime(request):
   now = datetime.datetime.now()
   html = "It is now %s." % now
   return HttpResponse(html)

By this code you must have understood that I am a newbie. So what I want to
know, is there a way to check, If my editing the views.py has created some
error in the pre-existing project? How can I detect it?

-- 
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-05 Thread Nikolas Stevenson-Molnar
Here's a good example of how Python decorators work behind the scenes:
http://en.wikipedia.org/wiki/Python_syntax_and_semantics#Decorators.
Essentially, the @csrf_exempt decorator is a function, meaning that when
you use it to decorate a class, you reassign the name of that class to a
function which returns a class instance. This creates problems when you
use super() or anything else that expects a class (and gets a function
instead).

This is the correct way to decorate a class-based view:
https://docs.djangoproject.com/en/dev/topics/class-based-views/#decorating-the-class.
Except I don't think that DjangoSoapApp is a view (?) so you'll need to
find where the actual view is and decorate that instead.

_Nik

On 7/5/2012 2:00 PM, Nikolas Stevenson-Molnar wrote:
> Try removing the @csrf_exempt decorator (for testing, you can disable
> CSRF for the site in your settings file by commenting out the
> CsrfViewMiddleware).
>
> _Nik
>
> On 7/5/2012 1:03 PM, Jeff Silverman wrote:
>> # soaplib v2.0.0beta2 (from memory)
>> # Django v1.3 (stable)
>> # NOTE: CSRF middleware has been turned off!
>> # For urls.py, see: https://gist.github.com/935812
>>
>> import soaplib
>> from soaplib.core.service import rpc, DefinitionBase
>> from soaplib.core.model.primitive import String, Integer
>> from soaplib.core.model.clazz import Array
>>
>> from django.views.decorators.csrf import csrf_exempt
>>
>>
>> class HelloWorldService(DefinitionBase):
>> @rpc(String,Integer,_returns=Array(String))
>> def say_hello(self, name, times):
>> results = []
>> for i in range(0, times):
>> results.append('Hellow, %s' %name)
>> return results
>>
>>
>> from soaplib.core.server.wsgi import Application
>> from django.http import HttpResponse
>>
>> import StringIO
>> class DumbStringIO(StringIO.StringIO):
>> def read(self, n):
>> return self.getvalue()
>>
>> @csrf_exempt
>> class DjangoSoapApp(Application):
>> def __call__(self, request):
>> django_response = HttpResponse()
>>
>> def start_response(status, headers):
>> status, reason = status.split(' ', 1)
>> django_response.status_code = int(status)
>> for header, value in headers:
>> django_response[header] = value
>>
>> environ = request.META.copy()
>> environ['CONTENT_LENGTH'] = len(request.raw_post_data)
>> environ['wsgi.input'] = DumbStringIO(request.raw_post_data)
>> environ['wsgi.multithread'] = False
>>
>> #print help(DjangoSoapApp)
>>
>> response = super(DjangoSoapApp, self).__call__(environ,
>> start_response)
>> django_response.content = '\n'.join(response)
>> return django_response
>>
>>
>> print type(DjangoSoapApp)
>> soap_application = soaplib.core.Application([HelloWorldService],
>> 'tns')
>> #import pdb; pdb.set_trace()
>> hello_world_service = DjangoSoapApp(soap_application)
>>
>>
>> On Jul 5, 2:54 pm, Nikolas Stevenson-Molnar 
>> wrote:
>>> Would you please provide the source for mysite.BDSCheckUser.views?
>>>
>>> _Nik
>>>
>>> On 7/5/2012 11:37 AM, Jeff Silverman wrote:
>>>
>>>
>>>
 Resulting output,
 Help on function DjangoSoapApp in module mysite.BDSCheckUser.views:
 DjangoSoapApp(*args, **kwargs)
 On Jul 5, 2:31 pm, Nikolas Stevenson-Molnar 
 wrote:
> Hmmm, I can't think of what may be happening. One more debug thing to
> try, print the help of DjangoSoapApp just before the problem line:
> print help(DjangoSoapApp)
> That way, if the DjangoSoapApp symbol is getting reassigned to a
> function somewhere along the way, that might clue you in.
> _Nik
> On 7/5/2012 11:17 AM, Jeff Silverman wrote:
>> I've been flip flopping my views.py between that snippet, and
>> https://gist.github.com/935809, which is a bit different, but easier
>> to follow.
>> On Jul 5, 2:03 pm, Nikolas Stevenson-Molnar 
>> wrote:
>>> Is your code still the same as you posted 
>>> earlier:http://djangosnippets.org/snippets/2638/?Andtheerror is 
>>> occuring on
>>> ln 28?
>>> _Nik
>>> On 7/5/2012 11:01 AM, Jeff Silverman wrote:
 The print output is:
 
 On Jul 5, 1:38 pm, Nikolas Stevenson-Molnar 
 wrote:
> Hmmm, not sure about this one. Try printing out the type of
> DjangoSoapApp before that line is called:
> print type(DjangoSoapApp)
> _Nik
> On 7/5/2012 5:20 AM, Jeff Silverman wrote:
>> Ok, I'm further along, I think.  Now I'm getting the following
>> response = super(DjangoSoapApp, self).__call__(environ,
>> start_response)
>> (Pdb) p start_response
>> 
>> (Pdb)  super(DjangoSoapApp, self).__call__(environ, start_response)
>> *** TypeError: super() argument 1 must be type, not function
>> On Jul 3, 3:47 pm, Nikolas Stevenson-Molnar 
>> wrote:
>>> Looking at the soaplib source, it looks like it required requests 
>>> to be

Re: Still need help with the 405....please

2012-07-05 Thread Nikolas Stevenson-Molnar
Try removing the @csrf_exempt decorator (for testing, you can disable
CSRF for the site in your settings file by commenting out the
CsrfViewMiddleware).

_Nik

On 7/5/2012 1:03 PM, Jeff Silverman wrote:
> # soaplib v2.0.0beta2 (from memory)
> # Django v1.3 (stable)
> # NOTE: CSRF middleware has been turned off!
> # For urls.py, see: https://gist.github.com/935812
>
> import soaplib
> from soaplib.core.service import rpc, DefinitionBase
> from soaplib.core.model.primitive import String, Integer
> from soaplib.core.model.clazz import Array
>
> from django.views.decorators.csrf import csrf_exempt
>
>
> class HelloWorldService(DefinitionBase):
> @rpc(String,Integer,_returns=Array(String))
> def say_hello(self, name, times):
> results = []
> for i in range(0, times):
> results.append('Hellow, %s' %name)
> return results
>
>
> from soaplib.core.server.wsgi import Application
> from django.http import HttpResponse
>
> import StringIO
> class DumbStringIO(StringIO.StringIO):
> def read(self, n):
> return self.getvalue()
>
> @csrf_exempt
> class DjangoSoapApp(Application):
> def __call__(self, request):
> django_response = HttpResponse()
>
> def start_response(status, headers):
> status, reason = status.split(' ', 1)
> django_response.status_code = int(status)
> for header, value in headers:
> django_response[header] = value
>
> environ = request.META.copy()
> environ['CONTENT_LENGTH'] = len(request.raw_post_data)
> environ['wsgi.input'] = DumbStringIO(request.raw_post_data)
> environ['wsgi.multithread'] = False
>
> #print help(DjangoSoapApp)
>
> response = super(DjangoSoapApp, self).__call__(environ,
> start_response)
> django_response.content = '\n'.join(response)
> return django_response
>
>
> print type(DjangoSoapApp)
> soap_application = soaplib.core.Application([HelloWorldService],
> 'tns')
> #import pdb; pdb.set_trace()
> hello_world_service = DjangoSoapApp(soap_application)
>
>
> On Jul 5, 2:54 pm, Nikolas Stevenson-Molnar 
> wrote:
>> Would you please provide the source for mysite.BDSCheckUser.views?
>>
>> _Nik
>>
>> On 7/5/2012 11:37 AM, Jeff Silverman wrote:
>>
>>
>>
>>> Resulting output,
>>> Help on function DjangoSoapApp in module mysite.BDSCheckUser.views:
>>> DjangoSoapApp(*args, **kwargs)
>>> On Jul 5, 2:31 pm, Nikolas Stevenson-Molnar 
>>> wrote:
 Hmmm, I can't think of what may be happening. One more debug thing to
 try, print the help of DjangoSoapApp just before the problem line:
 print help(DjangoSoapApp)
 That way, if the DjangoSoapApp symbol is getting reassigned to a
 function somewhere along the way, that might clue you in.
 _Nik
 On 7/5/2012 11:17 AM, Jeff Silverman wrote:
> I've been flip flopping my views.py between that snippet, and
> https://gist.github.com/935809, which is a bit different, but easier
> to follow.
> On Jul 5, 2:03 pm, Nikolas Stevenson-Molnar 
> wrote:
>> Is your code still the same as you posted 
>> earlier:http://djangosnippets.org/snippets/2638/?Andtheerror is occuring 
>> on
>> ln 28?
>> _Nik
>> On 7/5/2012 11:01 AM, Jeff Silverman wrote:
>>> The print output is:
>>> 
>>> On Jul 5, 1:38 pm, Nikolas Stevenson-Molnar 
>>> wrote:
 Hmmm, not sure about this one. Try printing out the type of
 DjangoSoapApp before that line is called:
 print type(DjangoSoapApp)
 _Nik
 On 7/5/2012 5:20 AM, Jeff Silverman wrote:
> Ok, I'm further along, I think.  Now I'm getting the following
> response = super(DjangoSoapApp, self).__call__(environ,
> start_response)
> (Pdb) p start_response
> 
> (Pdb)  super(DjangoSoapApp, self).__call__(environ, start_response)
> *** TypeError: super() argument 1 must be type, not function
> On Jul 3, 3:47 pm, Nikolas Stevenson-Molnar 
> wrote:
>> 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/serve...
>> (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

Re: install a new model in my project

2012-07-05 Thread Tomas Neme
> I used pip for install  sorl.thumbnail  but "multiuploader" it isn't in
> the pip's repo

well, HOW did you install it? you can still tell pip to use a git or
mercurial repository, or a tarbal file, for example

(virtualenv) $ pip install git+git://
github.com/Lacrymology/cmsplugin_s3slider.git#egg=cmsplugin-s3slider

will install a cms plugin I forked that uses the s3 javascript slider
for image galleries in your virtualenv

But anyways, how *did* you install it? your issue is that your python
interpreter is not finding the package

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

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

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

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



Re: install a new model in my project

2012-07-05 Thread dhararon


El miércoles, 4 de julio de 2012 14:10:47 UTC-5, Tomas Neme escribió:
>
> > (django_multiuploader), and i write in INSTALLED_APPS 
> 'sorl.thumbnail', 
> > 'multiuploader',  then i execute manager.py runserver  and return 
> "Error: No 
> > module named multiuploader"   I dont understand how make a link for this 
> > module. 
>
> *How* did you install it? are you using pip and a virtualenv? 
>
>
> -- 
> "The whole of Japan is pure invention. There is no such country, there are 
> no such people" --Oscar Wilde 
>
> |_|0|_| 
> |_|_|0| 
> |0|0|0| 
>
> (\__/) 
> (='.'=)This is Bunny. Copy and paste bunny 
> (")_(") to help him gain world domination. 
>

I used pip for install  sorl.thumbnail  but "multiuploader" it isn't in the 
pip's repo

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



{% spaceless %} abuse (?)

2012-07-05 Thread David Lam
hmm, kinda semi-noob, but heres my scenario

I just started working on a fairly large Django project thats been around
for a couple years.

In the templates,  I see a lot of use of {% spaceless %} tags
whose apparent function is solely to trim whitespace to reduce page
size/page load time or something.

That's not really what it was made for right?   When I look at the original
Django ticket thing here... https://code.djangoproject.com/ticket/1067, it
dosent look like it, but I'm not 100% sure I guess

Also, beyond making the template code more unreadable too, I think using it
too much could impact performance right?  When I read at the django source
for the spaceless tag, it eventually calls this function which does a regex
replace of all whitespace in between the spaceless tags

# /utils/html.py:87
def strip_spaces_between_tags(value):
"""Returns the given HTML with spaces between tags removed."""
return re.sub(r'>\s+<', '><', force_unicode(value))

-- 
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-05 Thread Jeff Silverman
# soaplib v2.0.0beta2 (from memory)
# Django v1.3 (stable)
# NOTE: CSRF middleware has been turned off!
# For urls.py, see: https://gist.github.com/935812

import soaplib
from soaplib.core.service import rpc, DefinitionBase
from soaplib.core.model.primitive import String, Integer
from soaplib.core.model.clazz import Array

from django.views.decorators.csrf import csrf_exempt


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


from soaplib.core.server.wsgi import Application
from django.http import HttpResponse

import StringIO
class DumbStringIO(StringIO.StringIO):
def read(self, n):
return self.getvalue()

@csrf_exempt
class DjangoSoapApp(Application):
def __call__(self, request):
django_response = HttpResponse()

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

environ = request.META.copy()
environ['CONTENT_LENGTH'] = len(request.raw_post_data)
environ['wsgi.input'] = DumbStringIO(request.raw_post_data)
environ['wsgi.multithread'] = False

#print help(DjangoSoapApp)

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


print type(DjangoSoapApp)
soap_application = soaplib.core.Application([HelloWorldService],
'tns')
#import pdb; pdb.set_trace()
hello_world_service = DjangoSoapApp(soap_application)


On Jul 5, 2:54 pm, Nikolas Stevenson-Molnar 
wrote:
> Would you please provide the source for mysite.BDSCheckUser.views?
>
> _Nik
>
> On 7/5/2012 11:37 AM, Jeff Silverman wrote:
>
>
>
> > Resulting output,
>
> > Help on function DjangoSoapApp in module mysite.BDSCheckUser.views:
>
> > DjangoSoapApp(*args, **kwargs)
>
> > On Jul 5, 2:31 pm, Nikolas Stevenson-Molnar 
> > wrote:
> >> Hmmm, I can't think of what may be happening. One more debug thing to
> >> try, print the help of DjangoSoapApp just before the problem line:
>
> >> print help(DjangoSoapApp)
>
> >> That way, if the DjangoSoapApp symbol is getting reassigned to a
> >> function somewhere along the way, that might clue you in.
>
> >> _Nik
>
> >> On 7/5/2012 11:17 AM, Jeff Silverman wrote:
>
> >>> I've been flip flopping my views.py between that snippet, and
> >>>https://gist.github.com/935809, which is a bit different, but easier
> >>> to follow.
> >>> On Jul 5, 2:03 pm, Nikolas Stevenson-Molnar 
> >>> wrote:
>  Is your code still the same as you posted 
>  earlier:http://djangosnippets.org/snippets/2638/?Andtheerror is occuring 
>  on
>  ln 28?
>  _Nik
>  On 7/5/2012 11:01 AM, Jeff Silverman wrote:
> > The print output is:
> > 
> > On Jul 5, 1:38 pm, Nikolas Stevenson-Molnar 
> > wrote:
> >> Hmmm, not sure about this one. Try printing out the type of
> >> DjangoSoapApp before that line is called:
> >> print type(DjangoSoapApp)
> >> _Nik
> >> On 7/5/2012 5:20 AM, Jeff Silverman wrote:
> >>> Ok, I'm further along, I think.  Now I'm getting the following
> >>> response = super(DjangoSoapApp, self).__call__(environ,
> >>> start_response)
> >>> (Pdb) p start_response
> >>> 
> >>> (Pdb)  super(DjangoSoapApp, self).__call__(environ, start_response)
> >>> *** TypeError: super() argument 1 must be type, not function
> >>> On Jul 3, 3:47 pm, Nikolas Stevenson-Molnar 
> >>> wrote:
>  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/serve...
>  (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 the405method
> >>> not allowed error regardless.
> >>> On Jul 3, 1:28 pm, Nikolas Stevenson-Molnar 
> >>> 
> >>> wrote:

Acessing data on Model/Detail classes

2012-07-05 Thread Fabiano Martins

  
  
Hi,

I'm novice on Django, and I have a problem that I can't resolve
through documentation.

I like to make a validation on Model.clear() of the master class
method based on data of your detail classes, but it returns always a
empty set.

This example illustrates my problem:

1) on admin.py:
from mdtest.models import Master, Product,
Service
from django.contrib import admin
from django import forms

class ProductInline(admin.TabularInline):
    model = Product
    extra = 0

class ServiceInline(admin.TabularInline):
    model = Service
    extra = 0

class MasterForm(forms.ModelForm):
    class Meta:
    model = Master

class MasterAdmin(admin.ModelAdmin):
    form = MasterForm    
    inlines = [ProductInline, ServiceInline, ]

admin.site.register(Master, MasterAdmin)

2) on models.py:
from django.db import models
from django.core.exceptions import ValidationError

class Master(models.Model):
    MIN_VALUE = 100.00 
    date = models.DateField()
    description = models.CharField(max_length=200)
    
    def clean(self):
    super(Master, self).clean()
    total = 0
    for product in self.product_set.all():
    total += product.value
    for service in self.service_set.all():
    total += service.value
    print "Sum is " + str(total)
    if total < self.MIN_VALUE :
    raise ValidationError("Value can't lower than " +
str(self.MIN_VALUE))

class Product(models.Model):
    master = models.ForeignKey(Master)
    description = models.CharField(max_length=200)
    value = models.DecimalField(max_digits=12, decimal_places=2)

class Service(models.Model):
    master = models.ForeignKey(Master)
    description = models.CharField(max_length=200)
    value = models.DecimalField(max_digits=12, decimal_places=2)

==

This example contains a Master class that contains two detail
classes: one "product" and one "service".  The constraint of Master
requires that the sum of "value" fields of both details classes are
greater than 100.00.

When I run this example, click on "add master", fill a master and
some details and click "Save". the "total" variable at clean()
method always result on 0.

How do I do to access data from detail classes from methods at the
master class?

Thanks in advance,
Fabiano Martins

-- 
Fabiano Martins
Unidade de Aplicativos e Internet
Divisão de Informática
MPRS
  




-- 
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: Converting to Postgres database; error with UserProfile model

2012-07-05 Thread DF
This happened when I ran sync.db. All the other tables were created.

I'm using South but I ran sync.db first to create the initial tables. When 
I ran South, the 'profiles' app still didn't appear.

There's also a signals.py file with the following:

def create_profile(sender, instance, signal, created, **kwargs):
"""When user is created also create a matching profile."""
 
from stentorian.report.models import UserProfile
 
if created:
UserProfile(user = instance).save()

On Thursday, July 5, 2012 1:06:26 PM UTC-4, DF wrote:
>
> I have a problem that I hope someone with insight can aid with. My first 
> Django project is near completion and I’m currently transitioning to a 
> Postgres database in anticipation of deploying via Heroku. The process was 
> going fairly smoothly until this occurred when I ran python manage.py 
> syncdb:
>
> django.db.utils.DatabaseError: relation "report_userprofile" does not exist
> LINE 1: INSERT INTO "report_userprofile" ("user_id", "first_name", "...
>
> Apparently, it did not create DB tables for the UserProfile model. I’m now 
> getting this exception when I attempt to run the server:
>
> xception Type: DoesNotExist at /accounts/login/
> Exception Value: Site matching query does not exist.
>
> Among the additional apps I'm using for the project is django-profiles, 
> which I had some issues setting up which are apparently common. The 
> "Missing Manual" site –
> http://birdhouse.org/blog/2009/06/27/django-profiles/ – helped resolve 
> those but may have led to the current problem.
>
> I am using the signals.post_save.connect(create_profile, sender=User) 
> recommended there. I was researching what might have gone wrong and came 
> across this post on Google Groups and answer which states that “If you’re 
> using a post_save signal on User you can’t do that because it results in a 
> race condition." I’m wondering if this may be causing the issue and, 
> obviously, what would be best to resolve it and get these tables into the 
> new database and functioning.
>
> This is the database model:
>
> class UserProfile(models.Model):
>
> user = models.OneToOneField(User, unique=True, related_name="profile")
>
> first_name = models.CharField(max_length=25)
>
> last_name = models.CharField(max_length=35)
>
> email = models.EmailField()
>
> birth_date = models.DateField(blank=True, null=True)
>
> city = models.CharField(max_length=25)
>
> state = models.CharField(max_length=20)
>
> zip_code = models.CharField(max_length=10)
>
> profile_pic = models.ImageField(upload_to='profilepictures', 
> blank=True)
>
>
> def __unicode__(self):
>
> return " %s" % (self.user)
>
>
> def get_absolute_url(self):
>
> return ('profiles_profile_detail', (), { 'username': 
> self.user.username })
>
> get_absolute_url = models.permalink(get_absolute_url)
>
> signals.post_save.connect(create_profile, sender=User)
>
>
> Any insight into how to remedy this issue would be greatly appreciated.
>
>
>

-- 
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/-/0eVvl2dDNI8J.
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: Converting to Postgres database; error with UserProfile model

2012-07-05 Thread m1chael
syncdb is doing nothing for you?

On Thu, Jul 5, 2012 at 1:06 PM, DF  wrote:
> I have a problem that I hope someone with insight can aid with. My first
> Django project is near completion and I’m currently transitioning to a
> Postgres database in anticipation of deploying via Heroku. The process was
> going fairly smoothly until this occurred when I ran python manage.py
> syncdb:
>
> django.db.utils.DatabaseError: relation "report_userprofile" does not exist
> LINE 1: INSERT INTO "report_userprofile" ("user_id", "first_name", "...
>
> Apparently, it did not create DB tables for the UserProfile model. I’m now
> getting this exception when I attempt to run the server:
>
> xception Type: DoesNotExist at /accounts/login/
> Exception Value: Site matching query does not exist.
>
> Among the additional apps I'm using for the project is django-profiles,
> which I had some issues setting up which are apparently common. The "Missing
> Manual" site –http://birdhouse.org/blog/2009/06/27/django-profiles/ – helped
> resolve those but may have led to the current problem.
>
> I am using the signals.post_save.connect(create_profile, sender=User)
> recommended there. I was researching what might have gone wrong and came
> across this post on Google Groups and answer which states that “If you’re
> using a post_save signal on User you can’t do that because it results in a
> race condition." I’m wondering if this may be causing the issue and,
> obviously, what would be best to resolve it and get these tables into the
> new database and functioning.
>
> This is the database model:
>
> class UserProfile(models.Model):
>
> user = models.OneToOneField(User, unique=True, related_name="profile")
>
> first_name = models.CharField(max_length=25)
>
> last_name = models.CharField(max_length=35)
>
> email = models.EmailField()
>
> birth_date = models.DateField(blank=True, null=True)
>
> city = models.CharField(max_length=25)
>
> state = models.CharField(max_length=20)
>
> zip_code = models.CharField(max_length=10)
>
> profile_pic = models.ImageField(upload_to='profilepictures', blank=True)
>
>
> def __unicode__(self):
>
> return " %s" % (self.user)
>
>
> def get_absolute_url(self):
>
> return ('profiles_profile_detail', (), { 'username':
> self.user.username })
>
> get_absolute_url = models.permalink(get_absolute_url)
>
> signals.post_save.connect(create_profile, sender=User)
>
>
> Any insight into how to remedy this issue would be greatly appreciated.
>
>
> --
> 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/-/tuKKBCicojMJ.
> 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-05 Thread Smaran Harihar
Hey Nik,

Thanks for the detailed explanation. It is clear now.

Thanks,
Smaran

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

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

Re: Still need help with the 405....please

2012-07-05 Thread Nikolas Stevenson-Molnar
Would you please provide the source for mysite.BDSCheckUser.views?

_Nik

On 7/5/2012 11:37 AM, Jeff Silverman wrote:
> Resulting output,
>
> Help on function DjangoSoapApp in module mysite.BDSCheckUser.views:
>
> DjangoSoapApp(*args, **kwargs)
>
>
> On Jul 5, 2:31 pm, Nikolas Stevenson-Molnar 
> wrote:
>> Hmmm, I can't think of what may be happening. One more debug thing to
>> try, print the help of DjangoSoapApp just before the problem line:
>>
>> print help(DjangoSoapApp)
>>
>> That way, if the DjangoSoapApp symbol is getting reassigned to a
>> function somewhere along the way, that might clue you in.
>>
>> _Nik
>>
>> On 7/5/2012 11:17 AM, Jeff Silverman wrote:
>>
>>
>>
>>> I've been flip flopping my views.py between that snippet, and
>>> https://gist.github.com/935809, which is a bit different, but easier
>>> to follow.
>>> On Jul 5, 2:03 pm, Nikolas Stevenson-Molnar 
>>> wrote:
 Is your code still the same as you posted 
 earlier:http://djangosnippets.org/snippets/2638/?Andthe error is occuring 
 on
 ln 28?
 _Nik
 On 7/5/2012 11:01 AM, Jeff Silverman wrote:
> The print output is:
> 
> On Jul 5, 1:38 pm, Nikolas Stevenson-Molnar 
> wrote:
>> Hmmm, not sure about this one. Try printing out the type of
>> DjangoSoapApp before that line is called:
>> print type(DjangoSoapApp)
>> _Nik
>> On 7/5/2012 5:20 AM, Jeff Silverman wrote:
>>> Ok, I'm further along, I think.  Now I'm getting the following
>>> response = super(DjangoSoapApp, self).__call__(environ,
>>> start_response)
>>> (Pdb) p start_response
>>> 
>>> (Pdb)  super(DjangoSoapApp, self).__call__(environ, start_response)
>>> *** TypeError: super() argument 1 must be type, not function
>>> On Jul 3, 3:47 pm, Nikolas Stevenson-Molnar 
>>> wrote:
 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/serve...
 (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 the405method
>>> 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
> The405is 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 u

Re: Still need help with the 405....please

2012-07-05 Thread Jeff Silverman
Resulting output,

Help on function DjangoSoapApp in module mysite.BDSCheckUser.views:

DjangoSoapApp(*args, **kwargs)


On Jul 5, 2:31 pm, Nikolas Stevenson-Molnar 
wrote:
> Hmmm, I can't think of what may be happening. One more debug thing to
> try, print the help of DjangoSoapApp just before the problem line:
>
> print help(DjangoSoapApp)
>
> That way, if the DjangoSoapApp symbol is getting reassigned to a
> function somewhere along the way, that might clue you in.
>
> _Nik
>
> On 7/5/2012 11:17 AM, Jeff Silverman wrote:
>
>
>
> > I've been flip flopping my views.py between that snippet, and
> >https://gist.github.com/935809, which is a bit different, but easier
> > to follow.
>
> > On Jul 5, 2:03 pm, Nikolas Stevenson-Molnar 
> > wrote:
> >> Is your code still the same as you posted 
> >> earlier:http://djangosnippets.org/snippets/2638/?Andthe error is occuring 
> >> on
> >> ln 28?
>
> >> _Nik
>
> >> On 7/5/2012 11:01 AM, Jeff Silverman wrote:
>
> >>> The print output is:
> >>> 
> >>> On Jul 5, 1:38 pm, Nikolas Stevenson-Molnar 
> >>> wrote:
>  Hmmm, not sure about this one. Try printing out the type of
>  DjangoSoapApp before that line is called:
>  print type(DjangoSoapApp)
>  _Nik
>  On 7/5/2012 5:20 AM, Jeff Silverman wrote:
> > Ok, I'm further along, I think.  Now I'm getting the following
> > response = super(DjangoSoapApp, self).__call__(environ,
> > start_response)
> > (Pdb) p start_response
> > 
> > (Pdb)  super(DjangoSoapApp, self).__call__(environ, start_response)
> > *** TypeError: super() argument 1 must be type, not function
> > On Jul 3, 3:47 pm, Nikolas Stevenson-Molnar 
> > wrote:
> >> 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/serve...
> >> (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 the405method
> > 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
> >>> The405is 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 -
> >>>

Re: Still need help with the 405....please

2012-07-05 Thread Nikolas Stevenson-Molnar
Hmmm, I can't think of what may be happening. One more debug thing to
try, print the help of DjangoSoapApp just before the problem line:

print help(DjangoSoapApp)

That way, if the DjangoSoapApp symbol is getting reassigned to a
function somewhere along the way, that might clue you in.

_Nik

On 7/5/2012 11:17 AM, Jeff Silverman wrote:
> I've been flip flopping my views.py between that snippet, and
> https://gist.github.com/935809, which is a bit different, but easier
> to follow.
>
> On Jul 5, 2:03 pm, Nikolas Stevenson-Molnar 
> wrote:
>> Is your code still the same as you posted 
>> earlier:http://djangosnippets.org/snippets/2638/?And the error is occuring on
>> ln 28?
>>
>> _Nik
>>
>> On 7/5/2012 11:01 AM, Jeff Silverman wrote:
>>
>>
>>
>>> The print output is:
>>> 
>>> On Jul 5, 1:38 pm, Nikolas Stevenson-Molnar 
>>> wrote:
 Hmmm, not sure about this one. Try printing out the type of
 DjangoSoapApp before that line is called:
 print type(DjangoSoapApp)
 _Nik
 On 7/5/2012 5:20 AM, Jeff Silverman wrote:
> Ok, I'm further along, I think.  Now I'm getting the following
> response = super(DjangoSoapApp, self).__call__(environ,
> start_response)
> (Pdb) p start_response
> 
> (Pdb)  super(DjangoSoapApp, self).__call__(environ, start_response)
> *** TypeError: super() argument 1 must be type, not function
> On Jul 3, 3:47 pm, Nikolas Stevenson-Molnar 
> wrote:
>> 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/serve...
>> (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 the405method
> 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
>>> The405is 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 -- Hide quoted text -
>> - Show quoted text -- 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 
djang

Re: Still need help with the 405....please

2012-07-05 Thread Jeff Silverman
I've been flip flopping my views.py between that snippet, and
https://gist.github.com/935809, which is a bit different, but easier
to follow.

On Jul 5, 2:03 pm, Nikolas Stevenson-Molnar 
wrote:
> Is your code still the same as you posted 
> earlier:http://djangosnippets.org/snippets/2638/?And the error is occuring on
> ln 28?
>
> _Nik
>
> On 7/5/2012 11:01 AM, Jeff Silverman wrote:
>
>
>
> > The print output is:
>
> > 
>
> > On Jul 5, 1:38 pm, Nikolas Stevenson-Molnar 
> > wrote:
> >> Hmmm, not sure about this one. Try printing out the type of
> >> DjangoSoapApp before that line is called:
>
> >> print type(DjangoSoapApp)
>
> >> _Nik
>
> >> On 7/5/2012 5:20 AM, Jeff Silverman wrote:
>
> >>> Ok, I'm further along, I think.  Now I'm getting the following
> >>> response = super(DjangoSoapApp, self).__call__(environ,
> >>> start_response)
> >>> (Pdb) p start_response
> >>> 
> >>> (Pdb)  super(DjangoSoapApp, self).__call__(environ, start_response)
> >>> *** TypeError: super() argument 1 must be type, not function
> >>> On Jul 3, 3:47 pm, Nikolas Stevenson-Molnar 
> >>> wrote:
>  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/serve...
>  (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 the405method
> >>> 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
> > The405is 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 -- Hide quoted text -
>  - Show quoted text -- 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-05 Thread Nikolas Stevenson-Molnar
Is your code still the same as you posted earlier:
http://djangosnippets.org/snippets/2638/? And the error is occuring on
ln 28?

_Nik

On 7/5/2012 11:01 AM, Jeff Silverman wrote:
> The print output is:
>
> 
>
>
> On Jul 5, 1:38 pm, Nikolas Stevenson-Molnar 
> wrote:
>> Hmmm, not sure about this one. Try printing out the type of
>> DjangoSoapApp before that line is called:
>>
>> print type(DjangoSoapApp)
>>
>> _Nik
>>
>> On 7/5/2012 5:20 AM, Jeff Silverman wrote:
>>
>>
>>
>>> Ok, I'm further along, I think.  Now I'm getting the following
>>> response = super(DjangoSoapApp, self).__call__(environ,
>>> start_response)
>>> (Pdb) p start_response
>>> 
>>> (Pdb)  super(DjangoSoapApp, self).__call__(environ, start_response)
>>> *** TypeError: super() argument 1 must be type, not function
>>> On Jul 3, 3:47 pm, Nikolas Stevenson-Molnar 
>>> wrote:
 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/serve...
 (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 the405method
>>> 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
> The405is 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 -- 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-05 Thread Jeff Silverman
The print output is:




On Jul 5, 1:38 pm, Nikolas Stevenson-Molnar 
wrote:
> Hmmm, not sure about this one. Try printing out the type of
> DjangoSoapApp before that line is called:
>
> print type(DjangoSoapApp)
>
> _Nik
>
> On 7/5/2012 5:20 AM, Jeff Silverman wrote:
>
>
>
> > Ok, I'm further along, I think.  Now I'm getting the following
>
> > response = super(DjangoSoapApp, self).__call__(environ,
> > start_response)
> > (Pdb) p start_response
> > 
>
> > (Pdb)  super(DjangoSoapApp, self).__call__(environ, start_response)
> > *** TypeError: super() argument 1 must be type, not function
>
> > On Jul 3, 3:47 pm, Nikolas Stevenson-Molnar 
> > wrote:
> >> 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/serve...
> >> (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 the405method
> > 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
> >>> The405is 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 -- 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.



1.4: Emails to BCC addresses not sent

2012-07-05 Thread Javi Romero
Hi list, I'm new around though I've been developing Django sites since the 
early 1.0 releases

I've been looking around for problems regarding email sending to BCC 
addresses but can't find anything that explains what I'm seeing.

I have a ModelForm that renders a pretty simple contact form, and on POST 
the instance of the model gets saved. In that method, I've implemented a 
simple email sending step and then it continues normally. Code is on bottom.
I've tried this with both EmailMultiAlternatives and EmailMessage, and with 
the IMAP and Console email backends, and on my local machine and on remote 
servers (webfaction).
The emails always go to the address in the "To" field, but the "BCC" ones, 
no matter if it's only one and the same than "To" or if they are a few 
different emails never receive anything.
On both the IMAP and the Console backends I get output similar to this:

-- MESSAGE FOLLOWS --
Content-Type: multipart/alternative;
 boundary="===1548201696055964499=="
MIME-Version: 1.0
Subject: Nuevo mensaje de test12 recibido en example.com
From: direcc...@example.com
To: tes...@test.es
Date: Thu, 05 Jul 2012 10:06:59 -
Message-ID: <20120705100659.9464.36431@i5-750>
X-Peer: 127.0.0.1
--===1548201696055964499==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Hola test12, acabamos de recibir tu mensaje y nos pondremos en contacto 
contigo lo antes posible.
ab7 Cosmética
--===1548201696055964499==
Content-Type: text/html; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit


 



Hola test12, acabamos de recibir tu mensaje y nos pondremos en contacto 
contigo lo antes posible.
http://example.com/media/configuracion/ab7_logo.png"; alt="ab7 
Cosmética" />ab7 Cosmética

--===1548201696055964499==--
 END MESSAGE 


Notice that, if you look at the headers, there is no sight of "BCC" fields 
or addresses. I've looked at the variables that contains the BCC addresses 
and they look right, something like [u'f...@mail.com', u'b...@mail.com'].
Also, if I check msg.recipients() I get a full list of every addresses, 
both To and BCC, what anyone would expect.
I've changed the bcc parameter to cc on the construction of the message 
instance and it appears on the headers of the message and gets delivered to 
the emails.

So, any idea of what may be happening? I'm pretty lost right now and don't 
know what else try to fix this :-/

Original code follows:

# -*- coding: utf-8 -*-
'''
Javier Romero
Desarrollado por Barrabarra
web: http://barrabarra.es
Fecha: 2012
'''
from django.conf import settings
from django.contrib.sites.models import Site
from django.contrib.sites.managers import CurrentSiteManager
from django.core.mail import EmailMessage, EmailMultiAlternatives
from django.db import models
from django.db.models.signals import post_save
from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _
from catalog.models import Product
from configuracion.models import Configuracion
from sorl.thumbnail import ImageField

class ContactConfig(models.Model):
"""
Contact main configuration, contains title and description for both 
form and sent pages
"""
contacto_titulo = models.CharField(verbose_name=_(u'Título de la 
página de contacto'), max_length=120)
contacto_texto  = models.TextField(verbose_name=_(u'Contenido'), 
blank=True,)
contacto_analytics  = models.TextField(verbose_name=_(u'Analytics de la 
página de contacto'), blank=True,)
contacto_imagen = ImageField(_(u'Imagen de la página de contacto'), 
blank=True, upload_to='contacto')

exito_titulo= models.CharField(verbose_name=_(u'Título de la 
página de formulario enviado'), max_length=120)
exito_texto = models.TextField(verbose_name=_(u'Contenido'), 
blank=True,)
exito_analytics = models.TextField(verbose_name=_(u'Analytics de la 
página de formulario enviado'), blank=True,)
exito_imagen= ImageField(_(u'Imagen de la página de formulario 
enviado'), blank=True, upload_to='contacto')

analytics_contacto  = models.TextField(verbose_name=_(u'Analytics del 
botón de formulario de contacto completo'), blank=True,)
analytics_contactame = models.TextField(verbose_name=_(u'Analytics del 
botón de formulario de contacto rápido'), blank=True,)

creado_el   = models.DateTimeField(_(u'Creado el'), 
editable=False, auto_now_add=True)
actualizado_el  = models.DateTimeField(_(u'Actualizado el'), 
editable=False, auto_now=True)

class Meta:
verbose_name = _(u'Configuración de contacto')
verbose_name_plural = _(u'Configuración de contacto')

class NotificationEmail(models.Model):
"""
Email addresses to be notified when contact forms are sent,
editable on admin instead of putting them on the settings file
"""
 

Help using the clean() overwrite to control if user selects more than one boolean field in the admin

2012-07-05 Thread Luigi NA
I am running into a problem, I asked for assistance in IRC but I still did 
not understand.

I have 2 objects one called Item, the other Upload, upload is linked to 
Item via Fkey and is being displayed inline. Upload also has a field called 
Featured. I am trying to override the clean() method for this so that user 
has to and can only select 1 upload item as featured. I tried reading the 
docs, but I am still confused can someone help me with this please? Here is 
my models.py and my admin.py

Model.py---

import datetime 

from django.db import models
from django.contrib.auth.models import User 


class Category(models.Model):
label = models.CharField(max_length=128)
description = models.TextField()

user = models.ForeignKey(User)

class Meta:
verbose_name_plural="categories"

def __unicode__(self):
return self.label

class Item(models.Model):

title= models.CharField(max_length=64,
   help_text="Lets name this item shall we? Maximum 
128 chars")
excerpt= models.CharField(max_length=384,
   help_text="Small excerpt of your content") 
content= models.TextField()

pub_date = models.DateTimeField(auto_now_add=True)
visible_date= models.DateTimeField(default=datetime.datetime.now)

slug = models.SlugField(unique=True)
category = models.ForeignKey(Category)


def __unicode__(self):
return self.title 

class Upload(models.Model):

image = models.ImageField(blank=True, upload_to='images')
title = models.CharField(max_length=100, blank=True)
featured = models.BooleanField(default=False,blank=True)
caption = models.CharField(max_length=256, blank=True)

item = models.ForeignKey(Item)

class Meta:
ordering =['title']


def __unicode__(self):
return self.title


admin.py--

from django.contrib import admin
from blogger.models import Category,Item, upload


class PhotoInline(admin.StackedInline):
model = upload

def clean_Upload(self):
if upload.featured == True:
raise forms.ValidationError("error")
return self.cleaned_data

class ItemAdmin(admin.ModelAdmin):
inlines =[PhotoInline]

admin.site.register(Category, )
admin.site.register(Item, ItemAdmin)

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



Overriding the clean() method to an inlines model

2012-07-05 Thread Luigi NA
Greetings, can someone point out how can I accomplish this:

I have 2 models Item and Upload, upload has an Fkey to Item and is being 
displayed Inlines. I am trying to override the clean() method so that only 
1 upload object per item can be selected as featured. I asked the forums 
and was told the answer but still was not able to understand what I need to 
do. for simplicity sake lets just say I want to override the clean() method 
so that if any field or the upload is checked on it does not validate. Here 
is what my models.py and admin.py look like. Thanks in advance

Models.py
class Item(models.Model):

title= models.CharField(max_length=64,
   help_text="Lets name this item shall we? Maximum 
128 chars")
excerpt= models.CharField(max_length=384,
   help_text="Small excerpt of your content") 
content= models.TextField()

pub_date = models.DateTimeField(auto_now_add=True)
visible_date= models.DateTimeField(default=datetime.datetime.now)

slug = models.SlugField(unique=True)
category = models.ForeignKey(Category)


def __unicode__(self):
return self.title 

class Upload(models.Model):

image = models.ImageField(blank=True, upload_to='images')
title = models.CharField(max_length=100, blank=True)
featured = models.BooleanField(default=False,blank=True)
caption = models.CharField(max_length=256, blank=True)

item = models.ForeignKey(Item)

class Meta:
ordering =['title']

admin.py---

from django.contrib import admin
from blogger.models import Category,Item, upload


class PhotoInline(admin.StackedInline):
model = upload

def clean_Upload(self):
if upload.featured == True:
raise forms.ValidationError("error")
return self.cleaned_data

class ItemAdmin(admin.ModelAdmin):
inlines =[PhotoInline]

admin.site.register(Category, )
admin.site.register(Item, ItemAdmin)

-- 
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/-/4x32zvik7DQJ.
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: ForeignKey problem

2012-07-05 Thread Tomas Neme
> But! I do have another problem. Lets ditch our football example. Let's say
> that I have something like that:
>
> class CherryTree(models.Model):
> name = models.IntegerField()
> cherries = models.ManyToManyField('CherryFruit')
>
> class CherryFruit(models.Model):
> name = models.CharField(max_length=50)
>
> More or less. The point is, I want to ass many CherryFruit to one
> CherryTree. How do I pass the additional information? I suspect this can
> have something to do with the 'through' argument, but I'm probably
> completely wrong. Or do I have to create additional Model, like:
>
> class CherriesOnTree(models.Model):
> name = models.ForeignKey('CherryFruit')
> tree = models.ForeignKey('CherryTree')
> amount = models.IntegerField()
>
> and add each fruit separately? Hope It's clear what I mean :).

well, no, no and no, but interesting anyways.

A tree and it's fruit is the same as a team and it's players.

You'd do

class CherryTree(models.Model):
name = models.IntegerField()

class CherryFruit(models.Model):
tree = models.ForeignKey(CherryTree)
name = models.CharField(max_length=50)

because each cherry belongs to a single tree. You can think of it as a
parent-child relationship, the children are the ones that have the
ForeignKey.

The "through" parameter in a many to many just defines the name of the
table to be used for that "CherriesOnTree" model you put there, which you
wouldn't need to define. Also, the "amount" field would be of no point,
would it?

then you would do this:

# create a new tree
my_tree = Tree("Tree on the corner")
# or maybe get a tree from the database
my_tree = Tree.objects.get(name="Tree on the corner")

# create a new cherry for this tree
cherry = Cherry(tree=my_tree, name="Some Cherry Name")
cherry.save()
## or if you don't need to do anything afterwards, you can simply
Cherry(tree=my_tree, name="Some Cherry Name").save()

a many-to-many would be used, for example, in a classes and students
scenario

Each student goes to many classes, each class has many students, so:

class Class(models.Model):
   name = models.CharField(max_length=50)

class Student(models.Model):
   name = models.CharField(max_length=50)
   classes = models.ManyToManyField(Class)

# create class
math = Class(name="Math")
math.save()

# create student
student = Student(name="Charles")
student.save() # need to save before setting up many to manies
# Charles goes to Math class
student.classes.add(math)

Here an extra table will be created to hold the many-to-many relationships.
I think it's called _class_m2m_student, or something like that.

The through class is used if you want to add some extra data, like for
example, where does a student seat in a particular class, or what other
students he's in groups with in there, see

https://docs.djangoproject.com/en/dev/topics/db/models/#intermediary-manytomany

for more details

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

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

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

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



Re: Still need help with the 405....please

2012-07-05 Thread Nikolas Stevenson-Molnar
Hmmm, not sure about this one. Try printing out the type of
DjangoSoapApp before that line is called:

print type(DjangoSoapApp)

_Nik

On 7/5/2012 5:20 AM, Jeff Silverman wrote:
> Ok, I'm further along, I think.  Now I'm getting the following
>
> response = super(DjangoSoapApp, self).__call__(environ,
> start_response)
> (Pdb) p start_response
> 
>
> (Pdb)  super(DjangoSoapApp, self).__call__(environ, start_response)
> *** TypeError: super() argument 1 must be type, not function
>
>
> On Jul 3, 3:47 pm, Nikolas Stevenson-Molnar 
> wrote:
>> 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/serve...
>> (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 the405method
> 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
>>> The405is 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 -- 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: ForeignKey on CharField and char operations

2012-07-05 Thread Tomas Neme
> Wouldn't it create INNER JOIN query on a_type table? AFAIR it would and it's
> a bit overhead.
> But surely it is a better solution than mine one, thanks for that.

Well, in that case, I think your problem is that your AType PK isn't
the mnemo field, but some integer field, so type_id is integer, not
string.

Try defining it as

mnemo = models.CharField(u'Mnemocode', max_length=31, null=True,
unique=True, primary_key=True)

but I'm not sure if this is the behavior you want

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

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

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

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



Converting to Postgres database; error with UserProfile model

2012-07-05 Thread DF
I have a problem that I hope someone with insight can aid with. My first 
Django project is near completion and I’m currently transitioning to a 
Postgres database in anticipation of deploying via Heroku. The process was 
going fairly smoothly until this occurred when I ran python manage.py 
syncdb:

django.db.utils.DatabaseError: relation "report_userprofile" does not exist
LINE 1: INSERT INTO "report_userprofile" ("user_id", "first_name", "...

Apparently, it did not create DB tables for the UserProfile model. I’m now 
getting this exception when I attempt to run the server:

xception Type: DoesNotExist at /accounts/login/
Exception Value: Site matching query does not exist.

Among the additional apps I'm using for the project is django-profiles, 
which I had some issues setting up which are apparently common. The 
"Missing Manual" site –http://birdhouse.org/blog/2009/06/27/django-profiles/ – 
helped resolve those but may have led to the current problem.

I am using the signals.post_save.connect(create_profile, sender=User) 
recommended there. I was researching what might have gone wrong and came 
across this post on Google Groups and answer which states that “If you’re 
using a post_save signal on User you can’t do that because it results in a 
race condition." I’m wondering if this may be causing the issue and, 
obviously, what would be best to resolve it and get these tables into the 
new database and functioning.

This is the database model:

class UserProfile(models.Model):

user = models.OneToOneField(User, unique=True, related_name="profile")

first_name = models.CharField(max_length=25)

last_name = models.CharField(max_length=35)

email = models.EmailField()

birth_date = models.DateField(blank=True, null=True)

city = models.CharField(max_length=25)

state = models.CharField(max_length=20)

zip_code = models.CharField(max_length=10)

profile_pic = models.ImageField(upload_to='profilepictures', blank=True)


def __unicode__(self):

return " %s" % (self.user)


def get_absolute_url(self):

return ('profiles_profile_detail', (), { 'username': 
self.user.username })

get_absolute_url = models.permalink(get_absolute_url)

signals.post_save.connect(create_profile, sender=User)


Any insight into how to remedy this issue would be greatly appreciated.


-- 
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/-/tuKKBCicojMJ.
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: ForeignKey on CharField and char operations

2012-07-05 Thread Serg Shtripling


четверг, 5 июля 2012 г., 20:40:00 UTC+7 пользователь Tomas Neme написал:
>
> I might not be understanding this fully, but what about 
> A.objects.filter(type__mnemo__startswith="type1")? 
>
> Wouldn't it create INNER JOIN query on a_type table? AFAIR it would and 
it's a bit overhead.
But surely it is a better solution than mine one, thanks for that.

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



Error with permissions update file

2012-07-05 Thread Dott. Tegagni Alessandro


I wrote a django app, but i have a problem with the file permissions of the 
uploads files from a web form.

Basically I can upload a image and a pdf file but it always keep chmod 600.

I have add in settings.py: FILE_UPLOAD_PERMISSIONS = 0777, but when i 
upload a image/pdf file the permissions are always 600.

Any ideas?

-- 
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/-/9pt0RIun3-wJ.
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: ForeignKey problem

2012-07-05 Thread Soviet
Thanks a lot! After few experiments I think I get it :).

But! I do have another problem. Lets ditch our football example. Let's say 
that I have something like that:

class CherryTree(models.Model):
name = models.IntegerField()
cherries = models.ManyToManyField('CherryFruit')

class CherryFruit(models.Model):
name = models.CharField(max_length=50)

More or less. The point is, I want to ass many CherryFruit to one 
CherryTree. How do I pass the additional information? I suspect this can 
have something to do with the 'through' argument, but I'm probably 
completely wrong. Or do I have to create additional Model, like:

class CherriesOnTree(models.Model):
name = models.ForeignKey('CherryFruit')
tree = models.ForeignKey('CherryTree')
amount = models.IntegerField()

and add each fruit separately? Hope It's clear what I mean :).

W dniu poniedziałek, 25 czerwca 2012 23:16:28 UTC+2 użytkownik Kurtis 
napisał:
>
>
>> Let me follow up on this. Say I want to add list of all Teams my Players 
>> played for. What you're saying is that I don't have to add ForeignKey to 
>> Team and just use team_name field from Team model? Will it work?
>>
>> This relations stuff is confusing :P.
>>
>> Haha, no problem! It'll come natural after a while.
>
> Let's start out with the organization of this. There's really two main 
> relationships you will deal with. 
>
> *Foreign Keys*
>
> The first one is ForeignKeys, These are generally used when you want to do 
> what's called a "One to Many" relationship.
>
> So, for example, let's say you have several teams and several players. We 
> could assume that each player is *only* playing for one team at any given 
> time. This means that you will not find a single player playing for two 
> times. Under this assumption, you would have a "One to Many" relationship 
> because one team will have many players. *However*, each player will only 
> have *one* team. That may sound confusing -- read it over a few times if 
> it does :) Anyways, this scenario would best be solved by using a 
> ForeignKey.
>
> Here's a little visualization just in case that is confusing:
>
> Team: The Bengals
> Players: John, Bob, Tim, Joe
>
> Team: The Steelers
> Players: Adam, Chris, Frank, Steve
>
> Notice that each player is only playing for one Team. Each team, however, 
> has multiple players. In this situation, your models would be setup like 
> this:
>
> class Team(models.Model):
> name = models.CharField(max_length=50)
>
> class Player(models.Model):
> name = models.CharField(max_length=50)
> team = models.ForeignKey(Team)
>
> Now, let's say you want to grab some information about each of these.
>
> 1. We have the player Joe, how do we get his team?
>
> print joe.team.name
> >> "The Bengals"
>
> 2. We have the team "The Steelers", how do we get the list of players?
>
> print steelers.player_set.all()
> >> "Adam", "Chris", "Frank", "Steve"
>
> *Many to Many*
> *
> *
> The other common type of relationship you'll run into is called a Many to 
> Many relationship. This relationship is, essentially, two Models that can 
> have relationships with many objects from both sides of the relationship. 
> So to help you understand and visualize how this works, we're going to take 
> the previous example and modify it a bit.
>
> Let's say we have Two Teams and Several People. However, now people are 
> allowed to play for Multiple teams. In this example, assume that each 
> player with the same name is the same person (each name is unique).
>
> Team: The Bengals
> Players: Adam, Bob, Charlie
>
> Team: The Steelers
> Players: Donald, Evan, Adam
>
> Note: Adam plays for both teams.
>
> So, looking from Adam's perspective, we see that he plays for both the 
> Steelers and the Bengals. That is -- he has a "many" relationship with the 
> Teams. Looking at the players from the Team's perspective, it's obvious 
> that each team has many players. Therefore, in this relationship it is okay 
> to have Many-to-Many objects from both sides. 
>
> Here's the basic Model setup for this:
>
> class Team(models.Model):
> name = models.CharField(max_length=50)
>
> class Player(models.Model):
> name = CharField(max_length=50)
> teams = models.ManyToManyField(Team)
>
> Let's do a couple of examples to see where this is different.
>
> 1. Just like before, we have a player but we want to see his Team:
>
> print donald.teams.all()
> >> "The Steelers"
>
> 2. Now, like before, we want to see this player's team. However, the 
> Player is no longer restricted to a Single Team.
>
> print adam.teams.all()
> >> "The Bengals", "The Steelers"
>
> 3. Let's get the reverse relationships -- Who all plays for the Steelers?
>
> print steelers.player_set.all()
> >> "Donald", "Evan", "Adam"
>
> So, hopefully, from that example you can see that not much has changed 
> from the perspective of the Team. It already had a "many" relationship with 
> the players. However, the thing that has changed here is that the pla

Re: Super slow authentication

2012-07-05 Thread Ali Mesdaq
Sorry your right I didn't even include some basic info. Basically I am
using django_auth_ldap.backend.LDAPBackend as my first authentication
backend and .ModelBackend as my secondary. I have a login page that needs
authentication before you can do anything useful in the views by using a
decorator on my view methods and redirecting to the login url. The one
thing I have noticed about this setup is that on my dev box which is 10.04
Ubuntu its not as slow as the centos 5 machine its running on however they
are both slow.

Thanks,
Ali Mesdaq
Security Researcher
Work:  +1(408) 321-7779  |  Fax:  +1 (408) 321-9818
Email:  ali.mes...@fireeye.com

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




On 7/4/12 8:53 AM, "Melvyn Sopacua"  wrote:

>On 4-7-2012 1:57, Ali Mesdaq wrote:
>> Hey everyone,
>> 
>> I got a situation where I have SUPER slow authentication like approx
>>5min
>> to authenticate with both LDAP and default authentication mechanisms.
>
>LDAP authentication for what exactly? Django doesn't come with an
>LDAP-based authentication system.
>
>> So
>> my issue is two parts first is why and how is my authentication so slow?
>
>No clue. Connection timeouts are the like candidate but since you're not
>providing a whole of information to go on...
>
>> Second is now I am having some remote users timeout on their
>> authentication which was not happening before but is happening now.
>
>Again, authenticating against what?
>-- 
>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.
>


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



Re: [] Re: queryset caching - without caching middleware

2012-07-05 Thread Tom Evans
On Thu, Jul 5, 2012 at 4:08 PM, Henrik Genssen  wrote:
>>Could you show where and how you are executing the query? If the
>>queryset is a global, and does not go out of scope at the end of the
>>request, then reusing the queryset will not cause the queryset to be
>>re-evaluated.
>>
>>Eg, in this example, categories is a global outside of the view, and
>>once evaluated, will not be re-evaluated just because you used it in a
>>view.
>>
>>categories = Category.objects.all()
>>
>>def index(request):
>>  return render_to_response('index.html': { 'categories': categories })
>>
>>When querysets are executed is documented here:
>>
>>https://docs.djangoproject.com/en/1.4/ref/models/querysets/#when-querysets-are-evaluated
>
>
> yep, global caught me.
> I have a class:
>
> class table(object):
>queryset = Category.objects.all()
>column1 = ...
>column2 = ...
>
>def render(self):
>   return '...'
>
> in a view I am doing:
>
> tbl = table()
> # somtimes adding filters
> tbl.queryset = tbl.queryset.filter(...)
>
>
> I want to create a html table like "forms" in django
>
> Is it enough to call the all() method on the queryset in my rendering method 
> to get the queryset query the db again?
>
> regards
>
> Henrik
>

Yes, so that queryset is created once, when the class definition is
parsed, and then populated once. Regardless of how many instances of
table that you create, they all get the same object, created when the
class was parsed.

The simplest solution would be to simply assign that queryset inside
the init method, instead of making it a class member, eg:

class table(object):
   column1 = ...
   column2 = ...
   def __init__(self):
 self.queryset = Category.objects.all()

Cheers

Tom

-- 
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: [] Re: queryset caching - without caching middleware

2012-07-05 Thread Henrik Genssen
>Could you show where and how you are executing the query? If the
>queryset is a global, and does not go out of scope at the end of the
>request, then reusing the queryset will not cause the queryset to be
>re-evaluated.
>
>Eg, in this example, categories is a global outside of the view, and
>once evaluated, will not be re-evaluated just because you used it in a
>view.
>
>categories = Category.objects.all()
>
>def index(request):
>  return render_to_response('index.html': { 'categories': categories })
>
>When querysets are executed is documented here:
>
>https://docs.djangoproject.com/en/1.4/ref/models/querysets/#when-querysets-are-evaluated


yep, global caught me.
I have a class:

class table(object):
   queryset = Category.objects.all()
   column1 = ...
   column2 = ...

   def render(self):
  return '...'

in a view I am doing:

tbl = table()
# somtimes adding filters
tbl.queryset = tbl.queryset.filter(...)


I want to create a html table like "forms" in django

Is it enough to call the all() method on the queryset in my rendering method to 
get the queryset query the db again?

regards

Henrik

-- 
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: insert html into a form from Django code (not template)

2012-07-05 Thread Melvyn Sopacua
On 5-7-2012 16:48, angelika wrote:
> Only a few of the fields need to be repeated in the form, not the entire 
> form.

Right, so split out the repeated fields in a separate form. Remember
that the form tag and submit button is not part of the form object. If
these repeated fields are many-to-many relationships of a model, then
look at inline formsets:


-- 
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: queryset caching - without caching middleware

2012-07-05 Thread Tom Evans
On Thu, Jul 5, 2012 at 3:49 PM, Melvyn Sopacua  wrote:
> On 5-7-2012 14:28, hinnack wrote:
>> - can I disable or force a "refresh" of the cache?
>
> 
>

Transactions/READ REPEATED behaviour is unlikely to be affecting him
across requests, since the DB connection is opened and closed at the
start and end of each request.

Cheers

Tom

-- 
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: insert html into a form from Django code (not template)

2012-07-05 Thread Tom Evans
On Thu, Jul 5, 2012 at 3:35 PM, Melvyn Sopacua  wrote:
> Nice solution, but weren't formsets made for this type of thing? I'm
> trying to figure out why formsets couldn't be used here and coming up
> blank, unless the naming convention is somehow unchangeable.

Possibly. Formsets are great if you want to repeat the same form over
and over again, but sometimes you don't want to do that.

I've made forms like this for things like personal preferences.
Certain fields are always required (name, etc), some fields are only
collected for users if their organization permits, and some
organizations have a list of custom properties that must be collected.
In this scenario, formsets are useless, but dynamically created form
fields fit perfectly, providing you can generate the form in the
template in a sane manner.

Cheers

Tom

-- 
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: queryset caching - without caching middleware

2012-07-05 Thread Melvyn Sopacua
On 5-7-2012 14:28, hinnack wrote:
> - can I disable or force a "refresh" of the cache?



-- 
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: insert html into a form from Django code (not template)

2012-07-05 Thread angelika
Only a few of the fields need to be repeated in the form, not the entire 
form.
/Angelika

On Thursday, July 5, 2012 4:35:18 PM UTC+2, Melvyn Sopacua wrote:
>
> On 5-7-2012 16:26, Tom Evans wrote: 
> > On Thu, Jul 5, 2012 at 1:15 PM, angelika  
> wrote: 
> >> I've written a longer post here: 
> >> 
> http://stackoverflow.com/questions/11341118/printing-repeated-django-form-fields-individually
>  
> >> explaining what I need. Either a way to individually print out the 
> fields in 
> >> a loop or a way to insert html from the backend. Maybe it's just not 
> >> possible to do this in Django and then I will think of another 
> solution, but 
> >> I would like to make sure before I solve it another way. 
> >> 
> >> /Angelika 
> >> 
> > 
> > Of course it is possible. When you create the fields in the init 
> > method, make sure they are given distinct names. Store the names of 
> > the generated fields in a list on the form object, and then provide an 
> > iterator method that yields the variable fields in the order you want. 
>
> [snip] 
>
> Nice solution, but weren't formsets made for this type of thing? I'm 
> trying to figure out why formsets couldn't be used here and coming up 
> blank, unless the naming convention is somehow unchangeable. 
> -- 
> Melvyn Sopacua 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/2VPkgLFqqjQJ.
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: insert html into a form from Django code (not template)

2012-07-05 Thread angelika
Well thank you, Tom, you're a star! Will try this out as soon as possible,
Cheers

On Thursday, July 5, 2012 4:26:06 PM UTC+2, Tom Evans wrote:
>
> On Thu, Jul 5, 2012 at 1:15 PM, angelika  
> wrote: 
> > I've written a longer post here: 
> > 
> http://stackoverflow.com/questions/11341118/printing-repeated-django-form-fields-individually
>  
> > explaining what I need. Either a way to individually print out the 
> fields in 
> > a loop or a way to insert html from the backend. Maybe it's just not 
> > possible to do this in Django and then I will think of another solution, 
> but 
> > I would like to make sure before I solve it another way. 
> > 
> > /Angelika 
> > 
>
> Of course it is possible. When you create the fields in the init 
> method, make sure they are given distinct names. Store the names of 
> the generated fields in a list on the form object, and then provide an 
> iterator method that yields the variable fields in the order you want. 
> Eg: 
>
> class MyForm: 
>   def __init__(self, *args, **kwargs): 
> self._variable_fields = [ ] 
> for : 
>   field_name_id = 'field_name_%d' % val_id 
>   field_email_id = 'field_email_%d' % val_id 
>   self.fields[field_name_id] = forms.FooField(...) 
>   self.fields[field_email_id] = forms.FooField(...) 
>   self._variable_fields.append((field_name_id, field_email_id)) 
>
>   def variable_fields(self): 
> for field_name_id, field_email_id in self._variable_fields: 
>   yield self[field_name_id], self[field_email_id] 
>
> In your template: 
>
> {{ form.static_named_field1 }} 
> {{ form.static_named_field2 }} 
>
> {% for field_name, field_email in form.variable_fields %} 
> {{ field_name }} 
> {{ field_email }} 
> {% endfor %} 
>
> Hope that helps 
>
> Cheers 
>
> Tom 
>

-- 
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/-/UX4e47UyqREJ.
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: migration via south for inheritance change -> please help

2012-07-05 Thread Tomas Neme
> Not really. But from the question:
> "But how can I tell south to fill the super class with the data from the
> old schema?"

Well, in aswer to this, and Tom's remarks, you assumed he wanted to
have a new table because he was asking how to populate it, I assumed
he maybe doesn't know about abstract models because he said he's just
getting started programming (or at least on py/dj) and maybe he wasn't
sure what behavior he needed, and what were his options. I *do* start
saying "if you don't want Base instances".

and from Tom's:

> In the example, it is evident that the OP wants MTI, since he includes
> the foreign key links in the class definition - there is no clearer
> indicator than this!

The evidency of this gets flimsy, AFAICS, if you take in consideration
that he's refactoring code, and having two separate tables was good
enough for him until he "got a little better with python and django".
So, yes, this goes down, I think, if at any point he has a view where
he joins both groups of objects.

> And you're spreading records over two different tables and making it
> impossible to enforce uniqueness on shared attributes. So it's not just
> about creating an instance.

tru dat..

And yeah, the holy war wouldn't be on inheritance types, but rather on
reading comprehension, it seems ;)

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

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

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

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



Re: insert html into a form from Django code (not template)

2012-07-05 Thread Melvyn Sopacua
On 5-7-2012 16:26, Tom Evans wrote:
> On Thu, Jul 5, 2012 at 1:15 PM, angelika  wrote:
>> I've written a longer post here:
>> http://stackoverflow.com/questions/11341118/printing-repeated-django-form-fields-individually
>> explaining what I need. Either a way to individually print out the fields in
>> a loop or a way to insert html from the backend. Maybe it's just not
>> possible to do this in Django and then I will think of another solution, but
>> I would like to make sure before I solve it another way.
>>
>> /Angelika
>>
> 
> Of course it is possible. When you create the fields in the init
> method, make sure they are given distinct names. Store the names of
> the generated fields in a list on the form object, and then provide an
> iterator method that yields the variable fields in the order you want.

[snip]

Nice solution, but weren't formsets made for this type of thing? I'm
trying to figure out why formsets couldn't be used here and coming up
blank, unless the naming convention is somehow unchangeable.
-- 
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: queryset caching - without caching middleware

2012-07-05 Thread Tom Evans
On Thu, Jul 5, 2012 at 1:28 PM, hinnack  wrote:
> hmm, Ok, Queryset Caching happens alle the time...
>
> So here are some more questions on this:
> - where is the data stored?
> - can I ask a model, if its result is cached or a fresh one?
> - can I disable or force a "refresh" of the cache?
> - how would i use a query in a property of a class, without running into the
> cache phenomena?
>
> regards
>
> Henrik
>

Could you show where and how you are executing the query? If the
queryset is a global, and does not go out of scope at the end of the
request, then reusing the queryset will not cause the queryset to be
re-evaluated.

Eg, in this example, categories is a global outside of the view, and
once evaluated, will not be re-evaluated just because you used it in a
view.

categories = Category.objects.all()

def index(request):
  return render_to_response('index.html': { 'categories': categories })

When querysets are executed is documented here:

https://docs.djangoproject.com/en/1.4/ref/models/querysets/#when-querysets-are-evaluated

Cheers

Tom

-- 
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: insert html into a form from Django code (not template)

2012-07-05 Thread Tom Evans
On Thu, Jul 5, 2012 at 1:15 PM, angelika  wrote:
> I've written a longer post here:
> http://stackoverflow.com/questions/11341118/printing-repeated-django-form-fields-individually
> explaining what I need. Either a way to individually print out the fields in
> a loop or a way to insert html from the backend. Maybe it's just not
> possible to do this in Django and then I will think of another solution, but
> I would like to make sure before I solve it another way.
>
> /Angelika
>

Of course it is possible. When you create the fields in the init
method, make sure they are given distinct names. Store the names of
the generated fields in a list on the form object, and then provide an
iterator method that yields the variable fields in the order you want.
Eg:

class MyForm:
  def __init__(self, *args, **kwargs):
self._variable_fields = [ ]
for :
  field_name_id = 'field_name_%d' % val_id
  field_email_id = 'field_email_%d' % val_id
  self.fields[field_name_id] = forms.FooField(...)
  self.fields[field_email_id] = forms.FooField(...)
  self._variable_fields.append((field_name_id, field_email_id))

  def variable_fields(self):
for field_name_id, field_email_id in self._variable_fields:
  yield self[field_name_id], self[field_email_id]

In your template:

{{ form.static_named_field1 }}
{{ form.static_named_field2 }}

{% for field_name, field_email in form.variable_fields %}
{{ field_name }}
{{ field_email }}
{% endfor %}

Hope that helps

Cheers

Tom

-- 
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: internationalization on database with hard-coded data

2012-07-05 Thread Melvyn Sopacua
On 5-7-2012 12:06, ledzgio wrote:

> how can I apply internationalization on database with hard-coded data? I 
> import my data by creating .sql files with data inside.
> 
> Is there a better way to manage hard-coded data for internationalization? 
> and what if those data can grow with time?

Data from dynamic sources should be translated in the template. There's
examples in the internationalization docs. And yes, they don't magically
translate themselves and as such you need to run makemessages and friends.
-- 
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: mysqldb help! Can't connect to MySQL server error...

2012-07-05 Thread Melvyn Sopacua
On 5-7-2012 15:45, Tom Evans wrote:
> On Thu, Jul 5, 2012 at 1:53 PM, Melvyn Sopacua  wrote:
>> On 4-7-2012 21:31, Matthew Piatkowski wrote:
 DATABASE_PORT = '3036' # Set to empty string for default.
 Not used with sqlite3.

>> Typo that should probably 3306.
>>
> 
> I'm sure the guy from 2009 that he is quoting will be glad for the correction…
> 
Typos have a nasty habit of showing up more than once, but yeah I missed
the date. Unless mr Piatkowski provides info specific to his problem,
I'm out of this thread.

-- 
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: view didn't return an HttpResponse object....plz help

2012-07-05 Thread Tom Evans
On Thu, Jul 5, 2012 at 8:38 AM, manish girdhar
 wrote:
> yes it was indentation error and i rectified that.thanks for the concern
> friend..
>

I would have thought that it was you refering to the undefined
variable rollno here:

cd = form.cleaned_data
rollno = cd[rollno]
rollno = request.POST.get(rollno)

Should it not read:

cd = form.cleaned_data
rollno = cd["rollno"]
rollno = request.POST.get(rollno)

Cheers

Tom

-- 
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: mysqldb help! Can't connect to MySQL server error...

2012-07-05 Thread Sergiy Khohlov
WOW ! I forget about date ! Sorry

2012/7/5 Tom Evans :
> On Thu, Jul 5, 2012 at 2:59 PM, Sergiy Khohlov  wrote:
>> Could you please connect to mysql from console.  Is it OK ?
>>
>>  Look like
>> mysql is not started
>> you connect to wrong port
>> connect from network is blocked
>> credentials are wrong
>>
>
> Seriously? WTF? This is a thread from April 2009, the OP is not still
> trying to connect to mysql, nor is he likely to read the response
> telling him he leaked his mysql root password on the internet. No more
> replies are required...
>
> Cheers
>
> Tom
>
> --
> 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: mysqldb help! Can't connect to MySQL server error...

2012-07-05 Thread Tom Evans
On Thu, Jul 5, 2012 at 2:59 PM, Sergiy Khohlov  wrote:
> Could you please connect to mysql from console.  Is it OK ?
>
>  Look like
> mysql is not started
> you connect to wrong port
> connect from network is blocked
> credentials are wrong
>

Seriously? WTF? This is a thread from April 2009, the OP is not still
trying to connect to mysql, nor is he likely to read the response
telling him he leaked his mysql root password on the internet. No more
replies are required...

Cheers

Tom

-- 
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: migration via south for inheritance change -> please help

2012-07-05 Thread Melvyn Sopacua
On 5-7-2012 15:33, Tomas Neme wrote:

> But I don't see how what you say makes sense.
> 
> I mean, all the way starting from this:
> 
>> No, you /should/ not. You may do this, but you will end up with two
>> tables that /do not share the records/.
>> From the OP's post it's obvious these classes share the data. Think of
> 
> oh, yeah, completely obvious, of course. It's plain that Foo and Bar
> are just MEANT to be just subtypes of Base, you can tell just from the
> names!

Not really. But from the question:
"But how can I tell south to fill the super class with the data from the
old schema?"

I found it quite obvious. On second thought, it's possible he can
decouple the data.

> As I said before, the only thing this *really* depends on is in this
> question: do you need to be able to do something in the lines of:
> Fruit.objects.all()? And even more so: will you EVER do fruit =
> Fruit()? If not, there's no difference whatsoever, except you'd be
> littering the database namespace with a useless table.

And you're spreading records over two different tables and making it
impossible to enforce uniqueness on shared attributes. So it's not just
about creating an instance.

> Very big apps, like, say django-blog-zinnia use abstract classes for
> the ease of extension and share of information for VERY concrete
> concepts like EntryBase, which defines all the fields the app uses in
> it's views, so a user can define their own Entry(EntryBase) class.

Good point.
-- 
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: migration via south for inheritance change -> please help

2012-07-05 Thread Tom Evans
On Thu, Jul 5, 2012 at 2:33 PM, Tomas Neme  wrote:
> I wanted to chang the subject because I didn't want to spam someone's
> plead for help into a design discussion, but then I thought, how am I
> gonna make sure this is read by the right people? Also, context would
> be lost, so.. sorry about this
>
> But I don't see how what you say makes sense.
>
> I mean, all the way starting from this:
>
>> No, you /should/ not. You may do this, but you will end up with two
>> tables that /do not share the records/.
>> From the OP's post it's obvious these classes share the data. Think of
>
> oh, yeah, completely obvious, of course. It's plain that Foo and Bar
> are just MEANT to be just subtypes of Base, you can tell just from the
> names!
>
> Sorry, I don't mean to sound cocky, but you're making a hell of an
> assumption about what Foo and Bar and Base are, here, and *I* and
> making a completely different, but I think by no means less acceptable
> one: that he just wants to share his python code.
>
>> Base as a table 'fruit' and the other two as apples and oranges. In this
>> case it doesn't make sense to duplicate the fruit data in the apples and
>> oranges table.
>
> As I said before, the only thing this *really* depends on is in this
> question: do you need to be able to do something in the lines of:
> Fruit.objects.all()? And even more so: will you EVER do fruit =
> Fruit()? If not, there's no difference whatsoever, except you'd be
> littering the database namespace with a useless table.
>
> Very big apps, like, say django-blog-zinnia use abstract classes for
> the ease of extension and share of information for VERY concrete
> concepts like EntryBase, which defines all the fields the app uses in
> it's views, so a user can define their own Entry(EntryBase) class.
>

Abstract inheritance and MTI inheritance solve different problems. MTI
is particularly useful for querying sets of related classes on common
attributes, where as this is impossible to do with concrete classes
derived from an abstract class.

In the example, it is evident that the OP wants MTI, since he includes
the foreign key links in the class definition - there is no clearer
indicator than this!

IE, if he had given this as the definition:

class Foo(Base):
carpet = models.IntegerField()

then it could have been ambiguous as to what he was asking. Explicitly
including the parent link made it explicitly clear what he wanted.

Personally, I tend to use abstract class inheritance to give
behaviour, and MTI class inheritance to provide hierarchical class
structures. There is no inheritance holy war, they do different
things.

Cheers

Tom

-- 
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: mysqldb help! Can't connect to MySQL server error...

2012-07-05 Thread Sergiy Khohlov
Could you please connect to mysql from console.  Is it OK ?

 Look like
mysql is not started
you connect to wrong port
connect from network is blocked
credentials are wrong

2012/7/5 Tom Evans :
> On Thu, Jul 5, 2012 at 1:53 PM, Melvyn Sopacua  wrote:
>> On 4-7-2012 21:31, Matthew Piatkowski wrote:
 DATABASE_PORT = '3036' # Set to empty string for default.
 Not used with sqlite3.

>> Typo that should probably 3306.
>>
>
> I'm sure the guy from 2009 that he is quoting will be glad for the correction…
>
> --
> 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: mysqldb help! Can't connect to MySQL server error...

2012-07-05 Thread Tom Evans
On Thu, Jul 5, 2012 at 1:53 PM, Melvyn Sopacua  wrote:
> On 4-7-2012 21:31, Matthew Piatkowski wrote:
>>> DATABASE_PORT = '3036' # Set to empty string for default.
>>> Not used with sqlite3.
>>>
> Typo that should probably 3306.
>

I'm sure the guy from 2009 that he is quoting will be glad for the correction…

-- 
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: ForeignKey on CharField and char operations

2012-07-05 Thread Tomas Neme
I might not be understanding this fully, but what about
A.objects.filter(type__mnemo__startswith="type1")?

On Thu, Jul 5, 2012 at 7:51 AM, Serg Shtripling  wrote:
> Hello, community!
> Have anyone tried this:
> class AType(models.Model):
> #cut
> mnemo = models.CharField(u'Mnemocode', max_length=31, null=True,
> unique=True)
>
> class A(models.Model):
> #cut
> type = models.ForeignKey(AType, 'mnemo', verbose_name=u'A Type',
> null=True)
>
> class B(models.Model):
> #cut
> type_mnemo = models.CharField(u'A Type', max_length=31, null=True,
> blank=True)
> Mnemos = {type1, type1__plus, type1__minus, type2, type2__plus,}
> Now I want to get all A records, having AType starts with "type1", eg:
> "type1,type1__plus, type1__minus"
>
> r = A.objects.filter(type_id__startswith='type1')
> And got:
> TypeError: Related Field has invalid lookup: startswith
> As a workaround, I've replaced A model with B model - I do not have a
> relation, but query works as expected.
> Q: 1)Is it OK, that A.type_id, not just A.type field is a Related Field?
> q=AType.objects.all()[0]
 type(q.type)
> 
 type(q.type_id)
> 
> 2) Is there a more correct way to solve this issue?
>
> --
> 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/-/aV3iT_l4v1kJ.
> 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.



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

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

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

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



Re: migration via south for inheritance change -> please help

2012-07-05 Thread Tomas Neme
I wanted to chang the subject because I didn't want to spam someone's
plead for help into a design discussion, but then I thought, how am I
gonna make sure this is read by the right people? Also, context would
be lost, so.. sorry about this

But I don't see how what you say makes sense.

I mean, all the way starting from this:

> No, you /should/ not. You may do this, but you will end up with two
> tables that /do not share the records/.
> From the OP's post it's obvious these classes share the data. Think of

oh, yeah, completely obvious, of course. It's plain that Foo and Bar
are just MEANT to be just subtypes of Base, you can tell just from the
names!

Sorry, I don't mean to sound cocky, but you're making a hell of an
assumption about what Foo and Bar and Base are, here, and *I* and
making a completely different, but I think by no means less acceptable
one: that he just wants to share his python code.

> Base as a table 'fruit' and the other two as apples and oranges. In this
> case it doesn't make sense to duplicate the fruit data in the apples and
> oranges table.

As I said before, the only thing this *really* depends on is in this
question: do you need to be able to do something in the lines of:
Fruit.objects.all()? And even more so: will you EVER do fruit =
Fruit()? If not, there's no difference whatsoever, except you'd be
littering the database namespace with a useless table.

Very big apps, like, say django-blog-zinnia use abstract classes for
the ease of extension and share of information for VERY concrete
concepts like EntryBase, which defines all the fields the app uses in
it's views, so a user can define their own Entry(EntryBase) class.

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

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

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

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



Re: Admin actions -- short_description as doc string?

2012-07-05 Thread Melvyn Sopacua
On 5-7-2012 2:02, Russell Keith-Magee wrote:
> The short_description is a label that can be used for display purposes --
> a 'human readable' version of the method name.

Where is this used though? I've had the suspicion that the picture in
the documentation needs updating, cause it doesn't show the
short_description.

-- 
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: migration via south for inheritance change -> please help

2012-07-05 Thread Melvyn Sopacua
On 4-7-2012 22:29, Tomas Neme wrote:

> Besides that, if you don't want actual Base instances, then this is an
> abstract class, and you should do this:
> 
> class Base(models.Model):
> eggs
> plants
> class Meta:
> abstract=True
> 
> class Foo(Base):
> carpet=

No, you /should/ not. You may do this, but you will end up with two
tables that /do not share the records/.
>From the OP's post it's obvious these classes share the data. Think of
Base as a table 'fruit' and the other two as apples and oranges. In this
case it doesn't make sense to duplicate the fruit data in the apples and
oranges table.
You would be using abstract models for much vaguer concepts, like I'm using:

class NamedEntity(models.Model) :
   name = models.CharField(max_length=64, unique=True)
   description = models.TextField()

   class Meta :
   abstract = True
   ordering = [ 'name' ]

class Device(NamedEntity) :
   interface = models.CharField(max_length=16)
   # 

class Category(NamedEntity) :
   pass

In this case, you *want* device and category to be different tables for
the shared data as they represent totally different concepts and can
share names, but be totally different 'things' - like a 'cpu' category
with description 'central processor and supporting hardware' and a 'cpu'
device with description 'central processor device'.
-- 
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: mysqldb help! Can't connect to MySQL server error...

2012-07-05 Thread Melvyn Sopacua
On 4-7-2012 21:31, Matthew Piatkowski wrote:
>> DATABASE_PORT = '3036' # Set to empty string for default. 
>> Not used with sqlite3. 
>>
Typo that should probably 3306.

-- 
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: cannot deploy due to wsgi error

2012-07-05 Thread Melvyn Sopacua
On 4-7-2012 21:17, Peter Zakin wrote:
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212] ImportError: /opt/
> bitnami/python/lib/python2.7/lib-dynload/_io.so: undefined symbol: 
> PyUnicodeUCS2_AsEncodedString

There ya go. The python installation is flawed.
-- 
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: queryset caching - without caching middleware

2012-07-05 Thread hinnack
hmm, Ok, Queryset Caching happens alle the time...

So here are some more questions on this:
- where is the data stored?
- can I ask a model, if its result is cached or a fresh one?
- can I disable or force a "refresh" of the cache?
- how would i use a query in a property of a class, without running into 
the cache phenomena?

regards

Henrik


Am Donnerstag, 5. Juli 2012 13:43:06 UTC+2 schrieb hinnack:
>
> Hi all, 
>
> what's the magic here? 
>
> I am using django 1.3 with sqlite or postgres by invoking: 
> runserver 10.150.2.15:8080 --noreload 
>
> I have a view (no cache decorator) doing simple querys on the orm and 
> return that as html - nothing fancy 
> The view is executed on each request, but the database is hit only on the 
> first request 
> After that devserver shows only one query each request querying for 
> django_session 
>
> newly data is not fetched... 
>
> any idea? 
>
> my middleware looks like this: 
> MIDDLEWARE_CLASSES = ( 
> 'django.middleware.common.CommonMiddleware', 
> 'django.contrib.sessions.middleware.SessionMiddleware', 
> 'schiwago.middleware.header.ResponseInjectHeader', 
> 'schiwago.middleware.auth.BasicAuthMiddleware', 
> 'django.middleware.transaction.TransactionMiddleware', 
> ) 
>
> INSTALLED_APPS = ( 
> 'django.contrib.auth', 
> 'django.contrib.contenttypes', 
> 'django.contrib.sessions', 
> 'django.contrib.messages', 
> 'django.contrib.staticfiles', 
> 'django.contrib.admin', 
> 'schiwago', 
> 'transdb', 
> 'south', 
> 'mediafactory.ui', 
> 'relatorio', 
> 'djcelery', 
> 'devserver' 
> ) 
>

-- 
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/-/RYl7--t81FIJ.
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-05 Thread Jeff Silverman
Ok, I'm further along, I think.  Now I'm getting the following

response = super(DjangoSoapApp, self).__call__(environ,
start_response)
(Pdb) p start_response


(Pdb)  super(DjangoSoapApp, self).__call__(environ, start_response)
*** TypeError: super() argument 1 must be type, not function


On Jul 3, 3:47 pm, Nikolas Stevenson-Molnar 
wrote:
> 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/serve...
> (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 the405method
> >>> 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
> > The405is 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 -- 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: insert html into a form from Django code (not template)

2012-07-05 Thread angelika
I've written a longer post 
here: 
http://stackoverflow.com/questions/11341118/printing-repeated-django-form-fields-individually
 
explaining what I need. Either a way to individually print out the fields 
in a loop or a way to insert html from the backend. Maybe it's just not 
possible to do this in Django and then I will think of another solution, 
but I would like to make sure before I solve it another way.

/Angelika



On Thursday, July 5, 2012 12:53:32 PM UTC+2, stauros wrote:
>
>  On 07/05/2012 01:40 PM, Jon Black wrote: 
>
> /*SC*/DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
> "http://www.w3.org/TR/html4/loose.dtd";/*EC*/
>  
>
>  I've never done this, so I'm just throwing out ideas to try and be 
> helpful. I've found your stackoverflow post as well, which has more 
> information. (
> http://stackoverflow.com/questions/11341118/printing-repeated-django-form-fields-individually
> )
>   
>  Have you tried looping over the fields in the template? I know this is in 
> the template, but you can add the text you want still:
>   
>  
> {% for field in form %}
>   Some stuff I want here that form.as_p won't do for me   class="fieldWrapper">
> {{ field.errors }}
> {{ field.label_tag }}: {{ field }}
>   {% endfor %}
>
>  --
>  Jon Black
>  www.jonblack.org
>  
> May i suggest that the best way to do this is to create a template tag.
> But i am not so sure about what she is trying to achieve.
>  

-- 
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/-/T7hv5Ac62x4J.
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: map in django

2012-07-05 Thread Timothy Makobu
The link I gave you does exactly that. You give GMaps an address and it
gives you JSON (or XML) of many things, among them longitude and latitude.
You can then use  maybe http://gmap3.net/  to display the location on the
map. The ajax that will glue all that together into one page is the
homework.

On Thu, Jul 5, 2012 at 2:25 PM, Satvir Toor  wrote:

> I followed below link
> http://pypi.python.org/pypi/django-google-maps/
> it works fine in admin interface, But I want to display a map using
> django templates. I wish for a output like
> No. of text fields and a address field, the map would display the
> location on itself according to value entered into address field.
> Please help me.
>
>
> --
> Satvir Kaur
> satveerkaur.blogspot.in
>
> --
> 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: insert html into a form from Django code (not template)

2012-07-05 Thread Σταύρος Κρουστούρης

On 07/05/2012 01:40 PM, Jon Black wrote:
/*SC*/DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"/*EC*/
I've never done this, so I'm just throwing out ideas to try and be 
helpful. I've found your stackoverflow post as well, which has more 
information. 
(http://stackoverflow.com/questions/11341118/printing-repeated-django-form-fields-individually)
Have you tried looping over the fields in the template? I know this is 
in the template, but you can add the text you want still:

{%  for  field  in  form  %}
   Some stuff I want here that form.as_p won't do for me
   
 {{  field.errors  }}
 {{  field.label_tag  }}:{{  field  }}
   
{%  endfor  %}
--
Jon Black
www.jonblack.org

May i suggest that the best way to do this is to create a template tag.
But i am not so sure about what she is trying to achieve.

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



ForeignKey on CharField and char operations

2012-07-05 Thread Serg Shtripling
Hello, community!
Have anyone tried this:
class AType(models.Model):
#cut
mnemo = models.CharField(u'Mnemocode', max_length=31, null=True, 
unique=True)

class A(models.Model):
#cut
type = models.ForeignKey(AType, 'mnemo', verbose_name=u'A Type', 
null=True)

class B(models.Model):
#cut
type_mnemo = models.CharField(u'A Type', max_length=31, null=True, 
blank=True)
Mnemos = {type1, type1__plus, type1__minus, type2, type2__plus,}
Now I want to get all A records, having AType starts with "type1", eg: 
"type1,type1__plus, type1__minus"

r = A.objects.filter(type_id__startswith='type1')
And got:
TypeError: Related Field has invalid lookup: startswith
As a workaround, I've replaced A model with B model - I do not have a 
relation, but query works as expected.
Q: 1)Is it OK, that A.type_id, not just A.type field is a Related Field?
q=AType.objects.all()[0]
>>> type(q.type)

>>> type(q.type_id)

2) Is there a more correct way to solve this issue?

-- 
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/-/aV3iT_l4v1kJ.
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: Problem to complète the xml template

2012-07-05 Thread nef
Hello,
Thank you for your help. I have solved my problem. As I did not need a loop 
because there is just an object. My mistake was at my query that did not 
return objects.
Thank you for your response

On Thursday, July 5, 2012 7:42:06 AM UTC, JirkaV wrote:
>
> > Hello, 
> > http://cdm-fr.fr/2006/schemas/CDM-fr.xsd"; language="fr-FR"> 
> >   {% if formations %} 
> > 
> >  
>
>   Hi there, 
>
>you probably want to follow your {% if formations %} statement with: 
>  {% for formation in formations %} 
>
>   Check Django template documentation again - you're moving along the 
> right path, but your template is missing the loop across individual 
> formations. 
>
>   HTH 
>
>Jirka 
>

-- 
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/-/xS4EiBSaJvQJ.
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: insert html into a form from Django code (not template)

2012-07-05 Thread Σταύρος Κρουστούρης

On 07/05/2012 01:20 PM, angelika wrote:
Thanks, but I am asking if there is a way to insert html into a form 
from the backend code, and *not in the template*?
You can pass the html as a string from a context variable (i believe 
this should work),

but this is not a very good way to do things.
You are supposed to use django as suggested.The philosophy is
that html code and in general the frontend operations are being held
only in the templates and vice versa, backend operations only in the 
backend,

in order to ease and separate these tasks.

E.g. Better solution: you can pass a boolean or sth (foo)  to the 
template and with a template tag like:

{% if foo %}display html here {% endif %}

Please explain what your problem is or what do you want to do.
I am pretty sure that there is a better solution than loading html code 
from the backend.


--
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: install a new model in my project

2012-07-05 Thread lokesh s

Hi,
You can try downloading the source ball extract django_multiuploader 
inside your project folder.

Thanks,
Lokesh

On Thursday, July 5, 2012 12:40:47 AM UTC+5:30, Tomas Neme wrote:
>
> > (django_multiuploader), and i write in INSTALLED_APPS 
> 'sorl.thumbnail', 
> > 'multiuploader',  then i execute manager.py runserver  and return 
> "Error: No 
> > module named multiuploader"   I dont understand how make a link for this 
> > module. 
>
> *How* did you install it? are you using pip and a virtualenv? 
>
>
> -- 
> "The whole of Japan is pure invention. There is no such country, there are 
> no such people" --Oscar Wilde 
>
> |_|0|_| 
> |_|_|0| 
> |0|0|0| 
>
> (\__/) 
> (='.'=)This is Bunny. Copy and paste bunny 
> (")_(") to help him gain world domination. 
>

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



queryset caching - without caching middleware

2012-07-05 Thread Henrik Genssen
Hi all,

what's the magic here?

I am using django 1.3 with sqlite or postgres by invoking: 
runserver 10.150.2.15:8080 --noreload

I have a view (no cache decorator) doing simple querys on the orm and return 
that as html - nothing fancy
The view is executed on each request, but the database is hit only on the first 
request
After that devserver shows only one query each request querying for 
django_session

newly data is not fetched...

any idea?

my middleware looks like this:
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'schiwago.middleware.header.ResponseInjectHeader',
'schiwago.middleware.auth.BasicAuthMiddleware',
'django.middleware.transaction.TransactionMiddleware',
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'schiwago',
'transdb',
'south',
'mediafactory.ui',
'relatorio',
'djcelery',
'devserver'
)


regards

Henrik

Henrik Genssen

h...@miadi.net
Tel. +49 (0)451/6195650
Fax. +49 (0)451/6195655
http://www.miadi.net
http://www.facebook.com/pages/Miadi/150192061701844

miadi GmbH
Geschäftsführer: Henrik Genssen
Sitz der Gesellschaft: Hüxstraße 1 - 9, 23552 Lübeck
Amtsgericht Lübeck HRB 10223, USt-IdNr DE
Lieferungen und Leistungen erfolgen ausschließlich auf Grundlage unserer 
allgemeinen Geschäftsbedingungen

-- 
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-05 Thread Tom Evans
On Tue, Jul 3, 2012 at 6: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 haven't specified what you want to do, so it is hard to guide you.

The admin site is completely customisable. If you want an additional
admin page, you can add your own custom views:

https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#adding-views-to-admin-sites

If you want to do things with a set of selected objects, you can add
your own custom actions:

https://docs.djangoproject.com/en/1.4/ref/contrib/admin/actions/#writing-actions

If you want more advice, you should describe the feature you have been
asked to implement.

Cheers

Tom

-- 
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-05 Thread Jeff Silverman
Good call.  I used Fiddler to generate the POST string, however, I get
no response.  It appears to go into the @soap(String, Integer,
_returns=Array(string)) statement and hangs at that point, not
returning.

On Jul 3, 3:47 pm, Nikolas Stevenson-Molnar 
wrote:
> 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/serve...
> (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 the405method
> >>> 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
> > The405is 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 -- 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: map in django

2012-07-05 Thread Satvir Toor
I followed below link
http://pypi.python.org/pypi/django-google-maps/
it works fine in admin interface, But I want to display a map using
django templates. I wish for a output like
No. of text fields and a address field, the map would display the
location on itself according to value entered into address field.
Please help me.


-- 
Satvir Kaur
satveerkaur.blogspot.in

-- 
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: Problem to complète the xml template

2012-07-05 Thread bruno desthuilliers
On Wednesday, July 4, 2012 8:12:50 PM UTC+2, nef wrote:
>
> Hello,
>

Bonjour 
 

> I want to cry a function allowing me to complete a template *. Xml. May I 
> have a problem with the passage of the object render_to_response. In short 
> here is my code. In fact, I do not know how to return an object that can 
> permattre me to complete my template automatically.
> I am using django 1.1 and Python 2.6
> Function writes to the file views.py
>
> def main_formation(request, formation_id):
> formations = Formation.objects.get(id=formation_id)
>

You name your variable "formations" (plural) but your query returns a 
single Formation instance. 
 

> variables = RequestContext(request, {
> 'formations': formations
> })
> return render_to_response('saisie/formation.xml', variables)
>
> This is mu xml template
>
> (snip headers)
>
 

>   {% if formations %}
>
> 
>  
>
{{ formation.ville }}
>

You named the variable "formations" (plural) but you're trying to access an 
indexistant "formation" (singular) object. This will eval to the 
settings.TEMPLATE_STRING_IF_INVALID value, which by default is an empty 
string. For developpment, it might help to set TEMPLATE_STRING_IF_INVALID 
to a more obvious value (I personnaly use "XXX:INVALID").
 

-- 
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/-/QOUNvX6jcz8J.
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: insert html into a form from Django code (not template)

2012-07-05 Thread angelika
Thanks for answering! I would really like to do it that way, if I could. 
But I only want the html for some of the fields, not all of them. It would 
be great if I could iterate over just a few fields or be able to generate 
the name of the field in a loop, something like this:

[some fields]

{% for index in count|get_range %}
  Some stuff I want here that form.as_p won't do for me
  
{{ field_name_[somehow get index in here].errors }}

{{ field_name_[somehow get index in here] }}

 

  
{{ field_email_[somehow get index in here].errors }}

{{ field_email_[somehow get index in here] }}

 

{% endfor %}


[some more fields]

but I can't figure out a way to add index as a part of the field name.


On Thursday, July 5, 2012 12:40:57 PM UTC+2, Jon Black wrote:
>
>  I've never done this, so I'm just throwing out ideas to try and be 
> helpful. I've found your stackoverflow post as well, which has more 
> information. (
> http://stackoverflow.com/questions/11341118/printing-repeated-django-form-fields-individually
> )
>   
>  Have you tried looping over the fields in the template? I know this is in 
> the template, but you can add the text you want still:
>   
>  
> {% for field in form %}
>   Some stuff I want here that form.as_p won't do for me   class="fieldWrapper">
> {{ field.errors }}
> {{ field.label_tag }}: {{ field }}
>   {% endfor %}
>
>  --
>  Jon Black
>  www.jonblack.org
>
>   
>  On Thu, Jul 5, 2012, at 03:20, angelika wrote:
>
> Thanks, but I am asking if there is a way to insert html into a form from 
> the backend code, and not in the template?
>
> On Thursday, July 5, 2012 11:57:57 AM UTC+2, angelika wrote: 
>
> Is there a way to insert arbitrary html into a form from the Django code, 
> and not in the template? The equivalent of #markup in a Drupal form. 
>  
>  /Angelika
>
>   
> --
> 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/-/y7Inar5KaoEJ.
> 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/-/c4XoyWzaL4QJ.
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: insert html into a form from Django code (not template)

2012-07-05 Thread Jon Black
I've never done this, so I'm just throwing out ideas to try and
be helpful. I've found your stackoverflow post as well, which has
more information.
(http://stackoverflow.com/questions/11341118/printing-repeated-dj
ango-form-fields-individually)

Have you tried looping over the fields in the template? I know
this is in the template, but you can add the text you want still:

{% for field in form %}
  Some stuff I want here that form.as_p won't do for me
  
 {{ field.errors }}
 {{ field.label_tag }}: {{ field }}
  
{% endfor %}

--
Jon Black
www.jonblack.org


On Thu, Jul 5, 2012, at 03:20, angelika wrote:

  Thanks, but I am asking if there is a way to insert html into
  a form from the backend code, and not in the template?
  On Thursday, July 5, 2012 11:57:57 AM UTC+2, angelika wrote:

  Is there a way to insert arbitrary html into a form from the
  Django code, and not in the template? The equivalent of
  #markup in a Drupal form.



/Angelika


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

-- 
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: insert html into a form from Django code (not template)

2012-07-05 Thread angelika
Thanks, but I am asking if there is a way to insert html into a form from 
the backend code, and *not in the template*?

On Thursday, July 5, 2012 11:57:57 AM UTC+2, angelika wrote:
>
> Is there a way to insert arbitrary html into a form from the Django code, 
> and not in the template? The equivalent of #markup in a Drupal form.
>
> /Angelika
>

-- 
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/-/y7Inar5KaoEJ.
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: Handling millions of rows + large bulk processing (now 700+ mil rows)

2012-07-05 Thread Babatunde Akinyanmi
For the knowledge of it, me two

On 7/4/12, Timothy Makobu  wrote:
> I'm in.
>
> On Tue, Jul 3, 2012 at 2:35 AM, Cal Leeming [Simplicity Media Ltd] <
> cal.leem...@simplicitymedialtd.co.uk> wrote:
>
>> Just in case anyone missed the URL, you can book your slot here:
>>
>> http://www.doodle.com/8ptehyqr6uezhtsy
>>
>> Voting open until 14th July.
>>
>> Cal
>>
>> On Mon, Jul 2, 2012 at 9:59 AM, Cal Leeming [Simplicity Media Ltd] <
>> cal.leem...@simplicitymedialtd.co.uk> wrote:
>>
>>> Curious, I'll have to test the quality, but we might potentially use
>>> hangouts for the backup stream instead - it'd certainly be a lot easier
>>> if
>>> the quality was good!
>>>
>>> Cheers
>>>
>>> Cal
>>>
>>>
>>> On Mon, Jul 2, 2012 at 5:35 AM, Alec Taylor
>>> wrote:
>>>
 Sounds good, but have you considered using Google+ Hangouts?

 On Mon, Jul 2, 2012 at 1:09 AM, Cal Leeming [Simplicity Media Ltd]
  wrote:
 > Wow - glad to see there's people interested in this!
 >
 > Here is the schedule, could everyone please select which days/times
 they are
 > available (enter more than one if possible)
 >
 > http://www.doodle.com/8ptehyqr6uezhtsy
 >
 > I'll leave the schedule open until 14th July, whichever slot gets the
 most
 > votes wins.
 >
 > Given our awful experiences with conferencing software, we'll
 > probably
 be
 > using livestream, and a backup stream from one of our own servers -
 both
 > have a maximum capacity of 50 users at 720p.
 >
 > Cal
 >
 > On Sat, Jun 30, 2012 at 4:10 PM, Cal Leeming [Simplicity Media Ltd]
 >  wrote:
 >>
 >> Hi all,
 >>
 >> As some of you know, I did a live webcast last year (July 2011) on
 our LLG
 >> project, which explained how we overcome some of the problems
 associated
 >> with large data processing.
 >>
 >> After reviewing the video, I found that the sound quality was very
 poor,
 >> the slides weren't very well structured, and some of the information
 is now
 >> out of date (at the time it was 40mil rows, now we're dealing with
 700+mil
 >> rows).
 >>
 >> Therefore, I'm considering doing another live webcast (except this
 time
 >> it'll be recorded+posted the next day, the stream will be available
 >> in
 >> 1080p, it'll be far better structured, and will only last 50
 >> minutes).
 >>
 >> The topics I'd like to cover are:
 >>
 >> * Bulk data processing where bulk_insert() is still not viable (we
 went
 >> from 30 rows/sec to 8000 rows/sec on bulk data processing, whilst
 still
 >> using the ORM - no raw sql here!!)
 >> * Applying faux child/parent relationship when standard ORM is too
 >> expensive (allows for ORM approach without the cost)
 >> * Applying faux ORM read-only structure to legacy applications
 (allows ORM
 >> usage on schemas that weren't properly designed, and cannot be
 changed - for
 >> example, vendor software with no source code).
 >> * New Relic is beautiful, but expensive. Hear more about our plans
 >> to
 make
 >> an open source version.
 >> * Appropriate use cases for IAAS vs colo with SSDs.
 >> * Percona is amazing, some of the tips/tricks we've learned over.
 >>
 >> If you'd like to see this happen, please leave a reply in the thread
 - if
 >> enough people want this, then we'll do public vote for the scheduled
 date.
 >>
 >> Cheers
 >>
 >> 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.

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

Re: insert html into a form from Django code (not template)

2012-07-05 Thread Jon Black
This
(https://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs
#customizing-the-form-template) and more generally the entire
page explains how to work with forms.
--
Jon Black
www.jonblack.org


On Thu, Jul 5, 2012, at 02:57, angelika wrote:

  Is there a way to insert arbitrary html into a form from the
  Django code, and not in the template? The equivalent of
  #markup in a Drupal form.



/Angelika


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

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



internationalization on database with hard-coded data

2012-07-05 Thread ledzgio
Hi all,

how can I apply internationalization on database with hard-coded data? I 
import my data by creating .sql files with data inside.

Is there a better way to manage hard-coded data for internationalization? 
and what if those data can grow with time?

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/-/kTw-LgH9qiUJ.
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.



insert html into a form from Django code (not template)

2012-07-05 Thread angelika
Is there a way to insert arbitrary html into a form from the Django code, 
and not in the template? The equivalent of #markup in a Drupal form.

/Angelika

-- 
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/-/ErDblgugM7wJ.
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: DetailView - invalid literal for int() with base 10:

2012-07-05 Thread Jon Black
Hit send too soon then. My guess is that your kwargs being passed
to filter() contains some suspect things.
--
Jon Black
www.jonblack.org


On Thu, Jul 5, 2012, at 11:27, Jon Black wrote:

That doesn't help so much as there's no context information. Nice
to see the 'sysadmin' bit which wasn't in your original post.
Google throws up a lot of things for that:

http://www.google.nl/search?q=invalid+literal+for+int%28%29+with+
base+10%3A+%27sysadmin

--
Jon Black
www.jonblack.org


On Thu, Jul 5, 2012, at 02:17, Barry Morrison wrote:

  Apologies, here is the error output if it helps.

ValueError at /favs/Reddit/sysadmin/

invalid literal for int() with base 10: 'sysadmin'

Request Method: GET
Request URL: http://127.0.0.1:8000/favs/Reddit/sysadmin/
Django Version: 1.4
Exception Type: ValueError
Exception Value:
invalid literal for int() with base 10: 'sysadmin'

Exception Location:
/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/
site-packages/django/db/models/fields/__init__.py in
get_prep_value, line 537
Python Executable:
/home/bmorriso/LocalRepository/Myosotis/venv/bin/python
Python Version: 2.7.3
Python Path:
['/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-pa
ckages/requests/packages',
 '/home/bmorriso/LocalRepository/Myosotis',
 '/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-pa
ckages/setuptools-0.6c11-py2.7.egg',
 '/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-pa
ckages/pip-1.1-py2.7.egg',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/site-packages
/setuptools-0.6c11-py2.7.egg',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/site-packages
/pip-1.1-py2.7.egg',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/plat-linux2',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/lib-tk',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/lib-old',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-pa
ckages',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/site-packages
']

Server time: Thu, 5 Jul 2012 02:03:21 -0700

  On Thursday, July 5, 2012 2:13:59 AM UTC-7, Jon Black wrote:

I'm not sure without running it, which I can't do now. I have
noticed that your slug is not and id, but the field PostSubReddit
is a foerignkey which might expect an id.

Unrelated, I think your models shouldn't be pluralised (e.g. Post
instead of Posts). If you want the table name to be plural, use
the Meta class.

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


On Thu, Jul 5, 2012, at 02:07, Barry Morrison wrote:

  I've been beating my head against this all night and now into
  the morning...I have NO idea what I'm doing wrong and Google
  and Stack Overflow haven't been as helpful as I had hoped.
  [2]https://gist.github.com/7dc0b98a2fe056379ae8
  Any help or guidance would be greatly appreciated!
  Thanks!!


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To view this discussion on the web visit
  [3]https://groups.google.com/d/msg/django-users/-/
  zgmrTPX9yIEJ.
  To post to this group, send email to
  [4]django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  [5]django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  [6]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
  [7]https://groups.google.com/d/msg/django-users/-/aXIXIb3UGegJ
  .
  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.

References

1. http://www.jonblack.org/
2. https://gist.github.com/7dc0b98a2fe056379ae8
3. https://groups.google.com/d/msg/django-users/-/zgmrTPX9yIEJ
4. mailto:django-users@googlegroups.com
5. mailto:django-users%2bunsubscr...@googlegroups.com
6. http://groups.google.com/group/django-users?hl=en
7. https://groups.google.com/d/msg/django-users/-/aXIXIb3UGegJ

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

Re: DetailView - invalid literal for int() with base 10:

2012-07-05 Thread Jon Black
That doesn't help so much as there's no context information. Nice
to see the 'sysadmin' bit which wasn't in your original post.
Google throws up a lot of things for that:

http://www.google.nl/search?q=invalid+literal+for+int%28%29+with+
base+10%3A+%27sysadmin

--
Jon Black
www.jonblack.org


On Thu, Jul 5, 2012, at 02:17, Barry Morrison wrote:

  Apologies, here is the error output if it helps.

ValueError at /favs/Reddit/sysadmin/

invalid literal for int() with base 10: 'sysadmin'

Request Method: GET
Request URL: http://127.0.0.1:8000/favs/Reddit/sysadmin/
Django Version: 1.4
Exception Type: ValueError
Exception Value:
invalid literal for int() with base 10: 'sysadmin'

Exception Location:
/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/
site-packages/django/db/models/fields/__init__.py in
get_prep_value, line 537
Python Executable:
/home/bmorriso/LocalRepository/Myosotis/venv/bin/python
Python Version: 2.7.3
Python Path:
['/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-pa
ckages/requests/packages',
 '/home/bmorriso/LocalRepository/Myosotis',
 '/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-pa
ckages/setuptools-0.6c11-py2.7.egg',
 '/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-pa
ckages/pip-1.1-py2.7.egg',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/site-packages
/setuptools-0.6c11-py2.7.egg',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/site-packages
/pip-1.1-py2.7.egg',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/plat-linux2',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/lib-tk',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/lib-old',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-pa
ckages',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/site-packages
']

Server time: Thu, 5 Jul 2012 02:03:21 -0700

  On Thursday, July 5, 2012 2:13:59 AM UTC-7, Jon Black wrote:

I'm not sure without running it, which I can't do now. I have
noticed that your slug is not and id, but the field PostSubReddit
is a foerignkey which might expect an id.

Unrelated, I think your models shouldn't be pluralised (e.g. Post
instead of Posts). If you want the table name to be plural, use
the Meta class.

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


On Thu, Jul 5, 2012, at 02:07, Barry Morrison wrote:

  I've been beating my head against this all night and now into
  the morning...I have NO idea what I'm doing wrong and Google
  and Stack Overflow haven't been as helpful as I had hoped.
  [2]https://gist.github.com/7dc0b98a2fe056379ae8
  Any help or guidance would be greatly appreciated!
  Thanks!!


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To view this discussion on the web visit
  [3]https://groups.google.com/d/msg/django-users/-/
  zgmrTPX9yIEJ.
  To post to this group, send email to
  [4]django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  [5]django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  [6]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
  [7]https://groups.google.com/d/msg/django-users/-/aXIXIb3UGegJ
  .
  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. http://www.jonblack.org/
2. https://gist.github.com/7dc0b98a2fe056379ae8
3. https://groups.google.com/d/msg/django-users/-/zgmrTPX9yIEJ
4. mailto:django-users@googlegroups.com
5. mailto:django-users%2bunsubscr...@googlegroups.com
6. http://groups.google.com/group/django-users?hl=en
7. https://groups.google.com/d/msg/django-users/-/aXIXIb3UGegJ

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



  1   2   >