Re: Virtualenvs and editing contrib stuff manually

2012-10-05 Thread Russell Keith-Magee
On Sat, Oct 6, 2012 at 10:17 AM, Chris Pagnutti
 wrote:
> Hi Russel.  Thanks again for your help.  I guess "recommend" was the wrong
> word to use.  I just mean it's how the docs tell you to do it.
> https://docs.djangoproject.com/en/1.4/topics/auth/#storing-additional-information-about-users

Right - but if you look at the same docs in 1.5:

https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

You'll see that the AUTH_PROFILE_MODULE technique is marked as deprecated.

> But instead of doing it this way, I just created a new class like this
> class MyUser(User)
> with all the additional fields I wanted, which allows me to use all the auth
> stuff for logging in etc. and it seems to make forms easier.  It just felt
> cleaner at the time, but the more I think about it I wonder if there might
> be a reason why this might be bad practice. For example, I don't like how
> creating a new MyUser object makes duplicates in the "MyUsers" and "Users"
> sections of the admin.  I haven't tried it, but it seems to me this will
> still be the case if I were to use the foreign key method.

This is actually *exactly* the same method, just with different usage
syntax. Django implements inheritance using a multiple tables and a
foreign key; it just hides those detail from you. So - all you've done
here is implement a MyUser model with a foreign Key to User - you just
didn't need to define it as such.

> What I was trying to do was have Users for the site administrators, and
> MyUsers for site "members", while still taking advantage of all the built-in
> contrib.auth stuff.  I would think that this scenario is common enough that
> there is a standard way of dealing with it.

There is - and this is the situation where using profile models is
possibly the right way to handle things (something that the new docs
possibly need to clarify).

What you need to narrow down is the difference between authentication
and profile. Regardless of whether the user is an admin or a member,
they need to identify themselves to the system. For example, every
user, regardless of whether they're a member or an admin, needs to
have an email address so you can contact them. This information is
what needs to go in your User model.

However, once they're logged in, Members have different data to
Admins. Member- or Admin-specfiic data is what should go on the
profile. Admins may have a contact phone number for emergencies, but
members won't; members may have their birthdays stored, but admins
won't. You can then determine whether a user is a member or an admin
by checking for the existence of the appropriate profile model.

This approach has the additional benefit that an admin can be a member
without needing to change accounts - it's just a user that has both a
member and an admin profile.

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: Virtualenvs and editing contrib stuff manually

2012-10-05 Thread Chris Pagnutti
Hi Russel.  Thanks again for your help.  I guess "recommend" was the wrong 
word to use.  I just mean it's how the docs tell you to do it.
https://docs.djangoproject.com/en/1.4/topics/auth/#storing-additional-information-about-users

But instead of doing it this way, I just created a new class like this
class MyUser(User)
with all the additional fields I wanted, which allows me to use all the 
auth stuff for logging in etc. and it seems to make forms easier.  It just 
felt cleaner at the time, but the more I think about it I wonder if there 
might be a reason why this might be bad practice. For example, I don't like 
how creating a new MyUser object makes duplicates in the "MyUsers" and 
"Users" sections of the admin.  I haven't tried it, but it seems to me this 
will still be the case if I were to use the foreign key method.

What I was trying to do was have Users for the site administrators, and 
MyUsers for site "members", while still taking advantage of all the 
built-in contrib.auth stuff.  I would think that this scenario is common 
enough that there is a standard way of dealing with it.

On Thursday, September 27, 2012 4:13:34 PM UTC-4, Tundebabzy wrote:
>
> No you won't be smitten. 
>
> As for isolating your edited django, you can do that but then you 
> would have to be responsible for improving the code base by yourself. 
> Also, your edit might inadvertently break django or introduce bugs 
> that you might find difficult to trace and solve or that might change 
> some of the logic required to make django work. 
>
> On 9/27/12, Chris Pagnutti  wrote: 
> > Hi.  First-time poster here.  Feel free to point out any rules I'm not 
> > following. 
> > 
> > I've been looking around for how to make the django.contrib.auth User 
> > classe's "email" field to be unique and required.  There are bunches of 
> > ways to do it, but it's just s darn easy to go into the source and 
> > change how the field is defined. 
> > e.g. email = models.EmailField(_('email address'),unique=True) 
> > 
> > But in my searches, I've read warnings that you should not do this.  The 
> > reason, if it is given, is that you'll break your app if you update the 
> > contrib packages.  But what if I work in virtualenvs and just leave the 
> > django version and packages intact for that particular app in that 
> > particular environment?  What are the other practical and philosophical 
> > reasons for NOT editing the contrib source?  Will I be smitten from the 
> > django community if I do so? 
> > 
> > Thanks to all. 
> > 
> > -- 
> > 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/-/YX9X8u9mdbwJ. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@googlegroups.com . 
> > For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en. 
> > 
> > 
>
> -- 
> Sent from my mobile device 
>

-- 
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/-/GuC5W4mN7qIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: following tutorial / ran into problem....?

2012-10-05 Thread TJ Marbois
you rock Xavier! ;)  100% right answer... thank you!!

On Friday, October 5, 2012 7:01:42 PM UTC-4, Xavier Ordoquy wrote:
>
> Hi,
>
> class Poll(models.Model):
> # ...
> def __unicode__(self):
> return self.question
> class Choice(models.Model):
> # ...
> def __unicode__(self):
> return self.choice
>
>
> You probably have used self.question in the Choice class instead of 
> self.choice
>
> Regards,
> Xavier Ordoquy,
> Linovia.
>
> Le 6 oct. 2012 à 00:33, TJ Marbois  a 
> écrit :
>
> hi Im following the first Django tutorial...
>
> I thought I was doing everything correctly till I hit this spot:
>
> from 
>
> https://docs.djangoproject.com/en/1.4/intro/tutorial01/
>
> everything worked as expected till I got to this specific command in the 
> shell...
>
> # Create three choices.>>> p.choice_set.create(choice='Not much', votes=0)
>
>
> I instead got this:
>
> >>> p.choice_set.create(choice='Not much', votes=0)
> Traceback (most recent call last):
>   File "", line 1, in 
>   File 
> "/Users/tmacbook/Documents/CODING/django/Sites/vTenv/lib/python2.7/site-packages/django/db/models/base.py",
>  
> line 373, in __repr__
> u = unicode(self)
>   File 
> "/Users/tmacbook/Documents/CODING/django/Sites/myFirstDjangoSite/polls/models.py",
>  
> line 25, in __unicode__
> return self.question
> AttributeError: 'Choice' object has no attribute 'question'
>
> Can anyone help?
>
> cheers
>
> Tj
>
>
> -- 
> 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/-/S0BWK0XjNasJ.
> To post to this group, send email to django...@googlegroups.com
> .
> To unsubscribe from this group, send email to 
> django-users...@googlegroups.com .
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/MRBbfzfuUacJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Virtualenvs and editing contrib stuff manually

2012-10-05 Thread Russell Keith-Magee
It's mostly historical - the foreign key method was the *only* method
until about a week ago. :-)

The development docs contain a section about how to set up your own
User model, but that section isn't the 1.4 (current stable) docs. If
you can point me at a section in the dev docs that you think
recommends the foreign key method, it probably needs to be rewritten
or rephrased given the new features that have landed.

Yours,
Russ Magee %-)

On Fri, Oct 5, 2012 at 10:04 PM, Chris Pagnutti
 wrote:
> Hey thanks Russell.  That's a great explanation.  Is there a particular
> reason that the docs tend to favour the foreign key method over subclassing?
>
>
> On Thursday, September 27, 2012 4:13:34 PM UTC-4, Tundebabzy wrote:
>>
>> No you won't be smitten.
>>
>> As for isolating your edited django, you can do that but then you
>> would have to be responsible for improving the code base by yourself.
>> Also, your edit might inadvertently break django or introduce bugs
>> that you might find difficult to trace and solve or that might change
>> some of the logic required to make django work.
>>
>> On 9/27/12, Chris Pagnutti  wrote:
>> > Hi.  First-time poster here.  Feel free to point out any rules I'm not
>> > following.
>> >
>> > I've been looking around for how to make the django.contrib.auth User
>> > classe's "email" field to be unique and required.  There are bunches of
>> > ways to do it, but it's just s darn easy to go into the source and
>> > change how the field is defined.
>> > e.g. email = models.EmailField(_('email address'),unique=True)
>> >
>> > But in my searches, I've read warnings that you should not do this.  The
>> > reason, if it is given, is that you'll break your app if you update the
>> > contrib packages.  But what if I work in virtualenvs and just leave the
>> > django version and packages intact for that particular app in that
>> > particular environment?  What are the other practical and philosophical
>> > reasons for NOT editing the contrib source?  Will I be smitten from the
>> > django community if I do so?
>> >
>> > Thanks to all.
>> >
>> > --
>> > 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/-/YX9X8u9mdbwJ.
>> > To post to this group, send email to django...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>> >
>>
>> --
>> Sent from my mobile device
>
> --
> 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/-/kgPJcEQC1vAJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Django testing strategy

2012-10-05 Thread Josh Crompton
There are a couple of problems with setting up a big database and then 
writing integration tests. Your tests will be slow, so they won't get run. 
They'll also be increasingly hard to maintain. Fixtures only seem make that 
worse. You've already got a code base that needs maintaining, you don't 
want to add another one.

BUT you also have the problem that writing nice, isolated unit tests is 
going to require a lot of refactoring. That's scary because you don't have 
any tests in place, so you might break something and not know about it. I 
would approach it like this:

1) Decide on one functional area or workflow that you want to start with. 
Preferably, this would be (relatively) self-contained.
2) Create the fixtures you need for testing that area.
3) Write some high-level integration tests that cover all the important 
workflows for your user. I'd use the built in test client or WebTest for 
this.
4) Start writing real unit tests for the code in this area. Where 
necessary use factory_boy to set up your models, rather than fixtures. Mock 
your external dependencies. You will almost certainly have to do a lot of 
refactoring in order to write good, isolated unit tests. But you now have 
some confidence that you're not breaking things because of the high level 
integration tests.
5) Once you've achieved some good coverage with your unit tests, either 
start on a new area or refactor your integration tests. Get rid of the 
fixtures and move to factory_boy. Make sure you're testing the minimum 
necessary at this level, because they'll be your slowest and most fragile 
tests.

There's an excellent presentation by Carl Meyer that covers some tools and 
approaches to write better tests: 
http://pycon-2012-notes.readthedocs.org/en/latest/testing_and_django.html

Hope that helps.

Josh

On Friday, 5 October 2012 01:49:19 UTC+8, Daniele Procida wrote:
>
> I have started writing my first tests, for a project that has become 
> pretty large (several thousand lines of source code). 
>
> What needs the most testing - where most of the bugs or incorrect appear 
> emerge - are the very complex interactions between objects in the system. 
>
> To me, the intuitive way of testing would be this: 
>
> * to set up all the objects, in effect creating a complete working 
> database 
> * run all the tests on this database 
>
> That's pretty much the way I test things without automated tests: is the 
> output of the system, running a huge database of objects, correct? 
>
> However, I keep reading that I should isolate all my tests. So I have had 
> a go at creating tests that do that, but it can mean setting up a dozen 
> objects sometimes for a single tiny test, then doing exactly the same thing 
> with one small difference for another test. 
>
> Often I have to run save() on these objects, because otherwise tests that 
> depend on many-to-many and other database relations won't work. 
>
> That seems very inefficient, to create a succession of complex and 
> nearly-identical test conditions for dozens if not hundreds of tests. 
>
> I'd appreciate any advice. 
>
> Daniele 
>
>

-- 
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/-/Tz7_T4pZfTgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Disabling CSRF is not working.

2012-10-05 Thread Bill Freeman
Right you are.

On Fri, Oct 5, 2012 at 6:20 PM, Ian Clelland  wrote:
>
>
> On Friday, October 5, 2012, Bill Freeman wrote:
>>
>> I believe that I read somewhere that newer Djangos force the CSRF
>> middleware even if it's not listed in MIDDLEWARE_CLASSES.
>
>
> You might be thinking of the CSRF context processor, which is always
> enabled, no matter what is in settings. Even the most recent docs don't say
> anything about forcing the middleware.
>>
>>
>> You could dive into the middleware code to see how this happens, and
>> come up with a stable strategy to circumvent it.  Or you could just
>> fix the necessary views and templates.  There is, after all, a chance
>> that you will want to be able to upgrade this site without jumping
>> through hoops.
>>
>> On Thu, Oct 4, 2012 at 4:56 AM, Laxmikant Gurnalkar
>>  wrote:
>> > Hi, Guys
>> >
>> > Disabling CSRF is not working.
>> > These are my midlewares., Removed {% csrf_token %} all templates.
>> >
>> > MIDDLEWARE_CLASSES = (
>> > 'django.middleware.common.CommonMiddleware',
>> > 'django.contrib.sessions.middleware.SessionMiddleware',
>> ># 'django.middleware.csrf.CsrfViewMiddleware',
>> > 'django.contrib.auth.middleware.AuthenticationMiddleware',
>> > #'django.contrib.messages.middleware.MessageMiddleware',
>> > #'django.middleware.csrf.CsrfResponseMiddleware',
>> > # 'igp_acfs.acfs.disablecsrf.DisableCSRF',
>> > )
>> >
>> >
>> > Also tried by writing disablecsrf.py like this :
>> >
>> > class DisableCSRF(object):
>> > def process_request(self, request):
>> > """
>> > """
>> > setattr(request, '_dont_enforce_csrf_checks', True)
>> >
>> >
>> > Thanks in Advance!!!
>> >
>> > Laxmikant
>> >
>> > --
>> > You received this message 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.
>>
>
>
> --
> Regards,
> Ian Clelland
> 
>
> --
> You received this message 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: following tutorial / ran into problem....?

2012-10-05 Thread Xavier Ordoquy
Hi,

class Poll(models.Model):
# ...
def __unicode__(self):
return self.question

class Choice(models.Model):
# ...
def __unicode__(self):
return self.choice

You probably have used self.question in the Choice class instead of self.choice

Regards,
Xavier Ordoquy,
Linovia.

Le 6 oct. 2012 à 00:33, TJ Marbois  a écrit :

> hi Im following the first Django tutorial...
> 
> I thought I was doing everything correctly till I hit this spot:
> 
> from 
> 
> https://docs.djangoproject.com/en/1.4/intro/tutorial01/
> 
> everything worked as expected till I got to this specific command in the 
> shell...
> # Create three choices.
> >>> p.choice_set.create(choice='Not much', votes=0)
> 
> I instead got this:
> 
> >>> p.choice_set.create(choice='Not much', votes=0)
> Traceback (most recent call last):
>   File "", line 1, in 
>   File 
> "/Users/tmacbook/Documents/CODING/django/Sites/vTenv/lib/python2.7/site-packages/django/db/models/base.py",
>  line 373, in __repr__
> u = unicode(self)
>   File 
> "/Users/tmacbook/Documents/CODING/django/Sites/myFirstDjangoSite/polls/models.py",
>  line 25, in __unicode__
> return self.question
> AttributeError: 'Choice' object has no attribute 'question'
> 
> Can anyone help?
> 
> cheers
> 
> Tj
> 
> 
> -- 
> 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/-/S0BWK0XjNasJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

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



Re: Django Admin asks password every operation

2012-10-05 Thread Bill Freeman
All urls match this.  The regular expression says "any URL that starts
from the beginning, no matter what follows.  I suspect that you want
'r^$'

Bill

On Fri, Oct 5, 2012 at 2:15 PM, Stefano T
 wrote:
> wait i may have spotted out the problem:
> if i've an app, is this the correct url pattern for the homepage?
>
> url(r'^', 'earth.views.Home'),
>
> or does it take ll the urls?
>
>
> On Friday, October 5, 2012 8:10:09 PM UTC+2, Stefano T wrote:
>>
>> i didn't est SESSION_COOKIE_AGE anywhere, so i suppose it's set to its
>> default value.
>> Cookies are enabled.
>> i'm facing the problem in chrome (i deleted all the browser data, nothing
>> changed)
>> with FF it works.
>> Before it was working with chrome, suddently it stopped.
>>
>> On Friday, October 5, 2012 7:32:16 PM UTC+2, larry@gmail.com wrote:
>>>
>>> On Fri, Oct 5, 2012 at 10:57 AM, Stefano T
>>>  wrote:
>>> > Hi all.
>>> > i'm new to django and i'm facing a problem i can't solve so far.
>>> > Basically, when i log in in the admin part, every operation i do it
>>> > ask me for the login. doesn't matter which browser i user, it's always
>>> > the same.
>>> > at the beginning it was acting normally: once logged in i stay logged
>>> > in until the logout.
>>> > idea?
>>>
>>> What is SESSION_COOKIE_AGE set to in your settings file? Or are
>>> cookies disabled for your browser?
>
> --
> 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/-/jJ7LrE2_TC0J.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.



following tutorial / ran into problem....?

2012-10-05 Thread TJ Marbois
hi Im following the first Django tutorial...

I thought I was doing everything correctly till I hit this spot:

from 

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

everything worked as expected till I got to this specific command in the 
shell...

# Create three choices.>>> p.choice_set.create(choice='Not much', votes=0)


I instead got this:

>>> p.choice_set.create(choice='Not much', votes=0)
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/Users/tmacbook/Documents/CODING/django/Sites/vTenv/lib/python2.7/site-packages/django/db/models/base.py",
 
line 373, in __repr__
u = unicode(self)
  File 
"/Users/tmacbook/Documents/CODING/django/Sites/myFirstDjangoSite/polls/models.py",
 
line 25, in __unicode__
return self.question
AttributeError: 'Choice' object has no attribute 'question'

Can anyone help?

cheers

Tj

-- 
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/-/S0BWK0XjNasJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Newbie question: first project can't connect to MySQL

2012-10-05 Thread Javier Guerra Giraldez
On Fri, Oct 5, 2012 at 3:02 PM, Kurtis Mullins  wrote:
> Also, if memory serves me correctly, MySQL may be setup to allow connections
> from 127.0.0.1 but not Localhost

AFAIK, there are at least three different ways to connect to a local
server, each can be allowed/denied individually:

A: unix socket (something like /var/run/mysqld/mysqld.sock)

B: 127.0.0.1

C: a valid IP number that happens to be (one of) your own

-- 
Javier

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



Re: Disabling CSRF is not working.

2012-10-05 Thread Ian Clelland
On Friday, October 5, 2012, Bill Freeman wrote:

> I believe that I read somewhere that newer Djangos force the CSRF
> middleware even if it's not listed in MIDDLEWARE_CLASSES.


You might be thinking of the CSRF context processor, which is always
enabled, no matter what is in settings. Even the most recent docs don't say
anything about forcing the middleware.

>
> You could dive into the middleware code to see how this happens, and
> come up with a stable strategy to circumvent it.  Or you could just
> fix the necessary views and templates.  There is, after all, a chance
> that you will want to be able to upgrade this site without jumping
> through hoops.
>
> On Thu, Oct 4, 2012 at 4:56 AM, Laxmikant Gurnalkar
> > wrote:
> > Hi, Guys
> >
> > Disabling CSRF is not working.
> > These are my midlewares., Removed {% csrf_token %} all templates.
> >
> > MIDDLEWARE_CLASSES = (
> > 'django.middleware.common.CommonMiddleware',
> > 'django.contrib.sessions.middleware.SessionMiddleware',
> ># 'django.middleware.csrf.CsrfViewMiddleware',
> > 'django.contrib.auth.middleware.AuthenticationMiddleware',
> > #'django.contrib.messages.middleware.MessageMiddleware',
> > #'django.middleware.csrf.CsrfResponseMiddleware',
> > # 'igp_acfs.acfs.disablecsrf.DisableCSRF',
> > )
> >
> >
> > Also tried by writing disablecsrf.py like this :
> >
> > class DisableCSRF(object):
> > def process_request(self, request):
> > """
> > """
> > setattr(request, '_dont_enforce_csrf_checks', True)
> >
> >
> > Thanks in Advance!!!
> >
> > Laxmikant
> >
> > --
> > You received this message 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.
>
>

-- 
Regards,
Ian Clelland


-- 
You received this message 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: Sporadic Currency formatting is not possible using the 'C' locale

2012-10-05 Thread Xavier Ordoquy
Hi brian,

If you are using mod_wsgi with apache or nginx, reloading or restarting your 
servers may help.

Regards,
Xavier Ordoquy,
Linovia.

Le 5 oct. 2012 à 21:03, Brian  a écrit :

> I get this error sporadically. If I refresh the screen 3 or 4 times it loads 
> without the error.
>  
> It is making me nuts trying to figure out why sometimes it's fine other times 
> it fails.
>  
>  
> 
> -- 
> 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/-/2PXA_CemRPgJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: Best practice of subclassing default/3rd part apps?

2012-10-05 Thread Bill Freeman
If your changes are limited to templates, there is an easy standard approach:

Set TEMPLATE_DIRS to something reasonable.
Include the file system template loader in TEMPLATE_LOADERS
*before* the app loader.  (This is probably already true.)

Copy the templates you need to change to the same sub path of your
templates directory as they were to the app's templates directory, and
edit your copy.  E.g.; if the foo app calls out a template as
"foo/bar.html", and the original is in
".../site-packages/foo/templates/foo/bar.html", and you put your
version in ".../templates/foo/bar.html", your version will be found
first, and thus will be the one used.

If you need to fiddle a view, you need to recreate the view (or, if
applicable, create a function that calls the view and massages the
arguments and/or the results) in a module of your own that is
available from sys.path, e.g.; ".../my_utils/extra_views.py", and fix
urls.py to call it instead.  You can do this even if you are
"include()"ing the apps urls module from your urls, since you can put
an expression that matches a specific on or the app's sub paths before
the include, and the other sub paths will still be handled by the
app's urls.

Fancier changes usually lead to cloning the app into your project
directory and putting it under your revision control system, rather
than in requirements.txt (or equivalent).  (Your project directory
needs to be, and typically will be, earlier on sys.path than
site-packages or (yuck) dist-packages.)

Installing upgrades to other packages CAN (but usually doesn't) break
any of these approaches, requiring you to track down the interaction
and edit your copy.

On Thu, Oct 4, 2012 at 5:53 AM, Xun Yang  wrote:
> Quite often I have to make small changes to the original code when I'm using
> default/3rd part apps. Take an example of setting constrains for password,
> the default SetPasswordForm in django.contrib.auth.forms and
> RegistrationForm in django-registration don't have any. So I have to
> subclass them and add in the checks. So is there a best practice of where to
> place these subclasses? As in one project I may need to define many
> subclasses from various default/3rd part apps, should I create a utility app
> and put all of them there? (From the past experience I'm a bit concerned
> about this, as it could be a source of pain when I moved stuff from test to
> WSGI/apache)
>
> Thanks for the help!
>
> --
> 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/-/IOBUs2rA9UoJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: Disabling CSRF is not working.

2012-10-05 Thread Bill Freeman
I believe that I read somewhere that newer Djangos force the CSRF
middleware even if it's not listed in MIDDLEWARE_CLASSES.

You could dive into the middleware code to see how this happens, and
come up with a stable strategy to circumvent it.  Or you could just
fix the necessary views and templates.  There is, after all, a chance
that you will want to be able to upgrade this site without jumping
through hoops.

On Thu, Oct 4, 2012 at 4:56 AM, Laxmikant Gurnalkar
 wrote:
> Hi, Guys
>
> Disabling CSRF is not working.
> These are my midlewares., Removed {% csrf_token %} all templates.
>
> MIDDLEWARE_CLASSES = (
> 'django.middleware.common.CommonMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
># 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> #'django.contrib.messages.middleware.MessageMiddleware',
> #'django.middleware.csrf.CsrfResponseMiddleware',
> # 'igp_acfs.acfs.disablecsrf.DisableCSRF',
> )
>
>
> Also tried by writing disablecsrf.py like this :
>
> class DisableCSRF(object):
> def process_request(self, request):
> """
> """
> setattr(request, '_dont_enforce_csrf_checks', True)
>
>
> Thanks in Advance!!!
>
> Laxmikant
>
> --
> You received this message 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: Migrating a Django project to new platform

2012-10-05 Thread Bill Freeman
v0.97 of Django is compatible with python 2.4, but, as noted above the
version of sorl (which is not part of the Django that makes that
promise, but an external add-on) is not.

You have a few choices:

1. You can tar (or zip) up the stuff in site-packages/sorl on the old
box, to move to the new box.  You may have to get rid of the .pyc
files.  You will probably have to get rid of any .pyo and .pyd files,
and then what has been copied is probably not enough to regenerate
them (unlike the .pyc files).

2. Better would be if you could find an egg or tar file for the
version you had been running, then install that in place of the sorl
that you have.

3. You could fix the code in question:

with open(data.temporary_file_path(), 'rb') as fp:

is roughly equivalent to:

try:
fp = open(data.temporary_file_path(), 'rb')
wrote:
> Hi all,
>
> Thank you once again for your insight and feedback.
>
> I had gathered that Python2.4 is pretty old, but I guess I expected it on
> the CentOS5 box. This is the 'latest' as far as the CentOS official repos
> are concerned. Additionally, according to the Django v0.97 'INSTALL' readme,
> it's compatible with Python v2.3 or greater.
>
> Also, a bit more background which might help:
>
> This 'hayley' website was originally created about 5 or 6 years ago by a
> third-party, and was built with Django v0.97 on an unknown platform (and
> unknown version of Python but I assume 2.3 or 2.4).
> It was then moved temporarily to a Unbuntu11 box (where it is now), by
> another third party. It appears to have Python 2.6 and 2.7 installed.
> Running python from the command line launches v2.7.1. I have remote SSH root
> access to this box, but it's not my property and, being a production server,
> I don't want to mess it up!
> I have now been asked to investigate moving it to an in-house server. As I
> am more familiar with CentOS than any other distro, and we had a CentOS5
> server sitting around doing little else than hosting some samba shares, I
> decided to to try to port it here.
>
> I have checked the Django site, and have noted that Django v1.4.1 seems the
> latest, but I have also read that migrating a v0.97 Django project to Django
> v1.4.1 isn't straight-forward. I thought I could cut down on the hassle by
> staying with Django v0.97(!). I also assumed that with Django v0.97 being
> old, the older version of Python would be more appropriate/compatible.
>
> The suggestion that the version of sorl I am using is incompatible with
> python2.4 is a good call. I am going to look into uninstalling this and
> finding an older version. Failing that I will try and upgrade Python2.4 to
> v.27 on the CentOS box from an alternate repo.
>
> Cheers guys :)
>
> Elliot
>
> On Wednesday, October 3, 2012 4:57:49 PM UTC+1, Tom Evans wrote:
>>
>> On Wed, Oct 3, 2012 at 4:31 PM, Elliot 
>> wrote:
>> > Hi guys, thank you sincerely for your feedback.
>> >
>> > As far as I know there is just the one instance of python installed:
>> >
>> > "
>>  print sys.path
>> > ['', '/usr/lib/python2.4/site-packages/PIL-1.1.7-py2.4-linux-i686.egg',
>> > '/usr/lib/python2.4/site-packages/sorl_thumbnail-11.12-py2.4.egg',
>> > '/usr/lib/python24.zip', '/usr/lib/python2.4',
>> > '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk',
>> > '/usr/lib/python2.4/lib-dynload', '/usr/lib/python2.4/site-packages',
>> > '/usr/lib/python2.4/site-packages/Numeric',
>> > '/usr/lib/python2.4/site-packages/gtk-2.0']
>> >
>> > [root@svr-h001463 hayley]# whereis python
>> > python: /usr/bin/python /usr/bin/python2.4 /usr/lib/python2.4
>> > /usr/include/python2.4 /usr/share/man/man1/python.1.gz
>> >
>> > [root@svr-h001463 hayley]# cd /usr/lib
>> > [root@svr-h001463 lib]# ls -d */ | grep "py"
>> > pygtk/
>> > python2.4/
>> > "
>> >
>> > If I try 'python manage.py shell':
>> > "
>> > [root@svr-h001463 hayley]# python manage.py shell
>> > Traceback (most recent call last):
>> >   File "manage.py", line 11, in ?
>> > execute_manager(settings)
>> >   File
>> > "/usr/lib/python2.4/site-packages/django/core/management/__init__.py",
>> > line
>> > 301, in execute_manager
>> > utility.execute()
>> >   File
>> > "/usr/lib/python2.4/site-packages/django/core/management/__init__.py",
>> > line
>> > 248, in execute
>> > self.fetch_command(subcommand).run_from_argv(self.argv)
>> >   File
>> > "/usr/lib/python2.4/site-packages/django/core/management/base.py",
>> > line 77, in run_from_argv
>> > self.execute(*args, **options.__dict__)
>> >   File
>> > "/usr/lib/python2.4/site-packages/django/core/management/base.py",
>> > line 86, in execute
>> > translation.activate('en-us')
>> >   File
>> > "/usr/lib/python2.4/site-packages/django/utils/translation/__init__.py",
>> > line 73, in activate
>> > return real_activate(language)
>> >   File
>> > "/usr/lib/python2.4/site-packages/django/utils/translation/__init__.py",
>> > line 43, in delayed_loader
>> > return g['real_%s' 

Re: Newbie question: first project can't connect to MySQL

2012-10-05 Thread Kurtis Mullins
Also, if memory serves me correctly, MySQL may be setup to allow
connections from 127.0.0.1 but not Localhost

On Fri, Oct 5, 2012 at 2:45 PM, Mohamad Efazati wrote:

> Hi afshin
> localhost is kind of pointer to 127.0.0.1, maybe in /etc/hosts or other
> thing you overwrite it.
> so 127.0.0.1 is source and always work.
>
>
> 2012/10/4 Afshin Mehrabani 
>
>> Hey Kevin,
>>
>> Thanks for your correct reply, I had this problem also but after changing
>> host from "localhost" to "127.0.0.1" problem solved, But why? what's the
>> different between 'localhost' and '127.0.0.1'?
>>
>> On Wednesday, February 4, 2009 9:15:32 PM UTC+3:30, Kevin Audleman wrote:
>>>
>>> I found the solution in the archives: I changed DATABASE_HOST to
>>> 127.0.0.1 from ''
>>>
>>> Kevin
>>>
>>> On Feb 4, 9:41 am, Kevin Audleman  wrote:
>>> > Hello everyone,
>>> >
>>> > I am running through the tutorial and setting up my first django
>>> > project. Quite exciting! However I have run into trouble connecting to
>>> > MySQL. My settings.py file looks like this:
>>> >
>>> > DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2',
>>> > 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>>> > DATABASE_NAME = 'test' # Or path to database file if using
>>> > sqlite3.
>>> > DATABASE_USER = 'root' # Not used with sqlite3.
>>> > DATABASE_PASSWORD = '' # Not used with sqlite3.
>>> > DATABASE_HOST = '' # Set to empty string for localhost.
>>> > Not used with sqlite3.
>>> > DATABASE_PORT = '' # Set to empty string for default. Not
>>> > used with sqlite3.
>>> >
>>> > Yes, the username is 'root' and there is no password. This is on my
>>> > local machine (OS X 10.5) so it doesn't matter.
>>> >
>>> > When I run...
>>> >
>>> > $ python manage.py syncdb
>>> >
>>> > I get the following...
>>> >
>>> > Traceback (most recent call last):
>>> >   File "manage.py", line 11, in 
>>> > execute_manager(settings)
>>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>>> > __init__.py", line 340, in execute_manager
>>> > utility.execute()
>>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>>> > __init__.py", line 295, in execute
>>> > self.fetch_command(subcommand)**.run_from_argv(self.argv)
>>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>>> > base.py", line 192, in run_from_argv
>>> > self.execute(*args, **options.__dict__)
>>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>>> > base.py", line 218, in execute
>>> > self.validate()
>>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>>> > base.py", line 246, in validate
>>> > num_errors = get_validation_errors(s, app)
>>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>>> > validation.py", line 65, in get_validation_errors
>>> > connection.validation.**validate_field(e, opts, f)
>>> >   File "/Library/Python/2.5/site-**packages/django/db/backends/**mysql/
>>>
>>> > validation.py", line 8, in validate_field
>>> > db_version = connection.get_server_version(**)
>>> >   File "/Library/Python/2.5/site-**packages/django/db/backends/**mysql/
>>>
>>> > base.py", line 277, in get_server_version
>>> > self.cursor()
>>> >   File "/Library/Python/2.5/site-**packages/django/db/backends/
>>> > __init__.py", line 56, in cursor
>>> > cursor = self._cursor(settings)
>>> >   File "/Library/Python/2.5/site-**packages/django/db/backends/**mysql/
>>>
>>> > base.py", line 262, in _cursor
>>> > self.connection = Database.connect(**kwargs)
>>> >   File "/Users/audleman/django_**projects/pollster/__init__.py"**,
>>> line
>>> > 74, in Connect
>>> >
>>> >   File "/Library/Python/2.5/site-**packages/MySQL_python-1.2.2-**py2.5-
>>>
>>> > macosx-10.5-i386.egg/MySQLdb/**connections.py", line 170, in __init__
>>> > _mysql_exceptions.**OperationalError: (2002, "Can't connect to local
>>> > MySQL server through socket '/tmp/mysql.sock' (2)")
>>> >
>>> > I'm not exactly sure what this socket is or why django can't find it.
>>> > One thought is that I installed LAMP on my machine using XAMPP, which
>>> > puts everything in the /Applications/xampp directory. Poking around, I
>>> > managed to find a mysql.sock file here:
>>> >
>>> > /Applications/xampp/**xamppfiles/var/mysql/mysql.**sock
>>> >
>>> > Assuming this is the correct socket, how do I tell django where to
>>> > find it?
>>> >
>>> > Thanks,
>>> > Kevin
>>
>>  --
>> 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/-/0dD75LGNe6UJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> 

Re: Creating a custom mixin for use with the generic CreateView

2012-10-05 Thread Guruprasad L
Hi,

On Friday, October 5, 2012 3:55:26 AM UTC+5:30, Javier Guerra wrote:
>
> On Thu, Oct 4, 2012 at 4:55 PM, Guruprasad L  
> wrote: 
> > This is the first time I am using mixins in code. I read mixed opinions 
> > about mixins, a few of them saying that it is bad. If it is bad, is 
> there 
> > some other way to implement this? 
>
> regardless of any moral issues for or against mixins, this is how 
> class based views are currently designed:  you can subclass to add 
> concrete functionality once, or create a mixin to apply some 
> functionality to several concrete subclasses. 
>

Thank you for your feedback. At least now I don't feel bad for creating a 
mixin and using it. Since the method I wanted to override (get_form() of 
CreateView) was already having a hierarchy of super() calls, it worked 
fine. But assuming I want to add functionality to a function that doesn't 
require calling super()'s function of the same name, like say form_valid() 
is it possible to use it in the same mixin?

This is what I want to achieve:

While using CreateView, when the models have a user foreignkey field, I 
don't want to give the foreign key choice to the user. So I remove the user 
field from the form by overriding the get_form() method in my mixin. When I 
inherit from the mixin, I get that functionality added to all subclasses of 
CreateView that I have. And to add the user foreign key reference before 
saving, I add it by overriding the form_valid() method and set it to the 
current user before saving it to the database.

I already have the mixin that overrides the get_form() method. In the 
method, it calls the super() get_form() and gets the form and removes the 
field and returns the form. But in form_valid() function, if I override it, 
I am not explicitly calling any super() function. I just add the field, 
save the modelform instance and redirect. So is it possible to override the 
form_valid() with a mixin even though there is no explicit invocation of 
super() methods?

Thanks & Regards,
Guruprasad

-- 
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/-/npHsaAZfm5QJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Dynamically adding values to related foreign key field in the form

2012-10-05 Thread Guruprasad L
Hi all,

Is it possible to add a value for a foreign key field from a form that is 
actually using it. For example, I have seen in the admin app that whenever 
there is a foreign key field, there is a way to add new items to that field 
via a popup window and the added value gets added to the list of foreign 
key values. If you want an example, if I am writing a blog post and I have 
a list of categories, I want to be able to use the list of existing 
categories or to create a new category from the same form used to create 
the blog post. Is it possible? If so, how should I go about implementing it?

Thanks & Regards,
Guruprasad

-- 
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/-/J70ipOebBLYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Sporadic Currency formatting is not possible using the 'C' locale

2012-10-05 Thread Brian
I get this error sporadically. If I refresh the screen 3 or 4 times it 
loads without the error.
 
It is making me nuts trying to figure out why sometimes it's fine other 
times it fails.
 
 

-- 
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/-/2PXA_CemRPgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Newbie question: first project can't connect to MySQL

2012-10-05 Thread Mohamad Efazati
Hi afshin
localhost is kind of pointer to 127.0.0.1, maybe in /etc/hosts or other
thing you overwrite it.
so 127.0.0.1 is source and always work.


2012/10/4 Afshin Mehrabani 

> Hey Kevin,
>
> Thanks for your correct reply, I had this problem also but after changing
> host from "localhost" to "127.0.0.1" problem solved, But why? what's the
> different between 'localhost' and '127.0.0.1'?
>
> On Wednesday, February 4, 2009 9:15:32 PM UTC+3:30, Kevin Audleman wrote:
>>
>> I found the solution in the archives: I changed DATABASE_HOST to
>> 127.0.0.1 from ''
>>
>> Kevin
>>
>> On Feb 4, 9:41 am, Kevin Audleman  wrote:
>> > Hello everyone,
>> >
>> > I am running through the tutorial and setting up my first django
>> > project. Quite exciting! However I have run into trouble connecting to
>> > MySQL. My settings.py file looks like this:
>> >
>> > DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2',
>> > 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>> > DATABASE_NAME = 'test' # Or path to database file if using
>> > sqlite3.
>> > DATABASE_USER = 'root' # Not used with sqlite3.
>> > DATABASE_PASSWORD = '' # Not used with sqlite3.
>> > DATABASE_HOST = '' # Set to empty string for localhost.
>> > Not used with sqlite3.
>> > DATABASE_PORT = '' # Set to empty string for default. Not
>> > used with sqlite3.
>> >
>> > Yes, the username is 'root' and there is no password. This is on my
>> > local machine (OS X 10.5) so it doesn't matter.
>> >
>> > When I run...
>> >
>> > $ python manage.py syncdb
>> >
>> > I get the following...
>> >
>> > Traceback (most recent call last):
>> >   File "manage.py", line 11, in 
>> > execute_manager(settings)
>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>> > __init__.py", line 340, in execute_manager
>> > utility.execute()
>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>> > __init__.py", line 295, in execute
>> > self.fetch_command(subcommand)**.run_from_argv(self.argv)
>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>> > base.py", line 192, in run_from_argv
>> > self.execute(*args, **options.__dict__)
>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>> > base.py", line 218, in execute
>> > self.validate()
>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>> > base.py", line 246, in validate
>> > num_errors = get_validation_errors(s, app)
>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>> > validation.py", line 65, in get_validation_errors
>> > connection.validation.**validate_field(e, opts, f)
>> >   File "/Library/Python/2.5/site-**packages/django/db/backends/**mysql/
>>
>> > validation.py", line 8, in validate_field
>> > db_version = connection.get_server_version(**)
>> >   File "/Library/Python/2.5/site-**packages/django/db/backends/**mysql/
>>
>> > base.py", line 277, in get_server_version
>> > self.cursor()
>> >   File "/Library/Python/2.5/site-**packages/django/db/backends/
>> > __init__.py", line 56, in cursor
>> > cursor = self._cursor(settings)
>> >   File "/Library/Python/2.5/site-**packages/django/db/backends/**mysql/
>>
>> > base.py", line 262, in _cursor
>> > self.connection = Database.connect(**kwargs)
>> >   File "/Users/audleman/django_**projects/pollster/__init__.py"**,
>> line
>> > 74, in Connect
>> >
>> >   File "/Library/Python/2.5/site-**packages/MySQL_python-1.2.2-**py2.5-
>>
>> > macosx-10.5-i386.egg/MySQLdb/**connections.py", line 170, in __init__
>> > _mysql_exceptions.**OperationalError: (2002, "Can't connect to local
>> > MySQL server through socket '/tmp/mysql.sock' (2)")
>> >
>> > I'm not exactly sure what this socket is or why django can't find it.
>> > One thought is that I installed LAMP on my machine using XAMPP, which
>> > puts everything in the /Applications/xampp directory. Poking around, I
>> > managed to find a mysql.sock file here:
>> >
>> > /Applications/xampp/**xamppfiles/var/mysql/mysql.**sock
>> >
>> > Assuming this is the correct socket, how do I tell django where to
>> > find it?
>> >
>> > Thanks,
>> > Kevin
>
>  --
> 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/-/0dD75LGNe6UJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
> --
> با تشکر
> افاضاتی
> http://www.efazati.org
>
>
>

-- 
You received this message 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 

Re: Print html the normal way

2012-10-05 Thread Laxmikant Gurnalkar
Use
 {{yourvar|html|striptags}}

https://docs.djangoproject.com/en/dev/ref/templates/builtins/#striptags

Cheers
*Laxmikant Gurnalkar*
On Fri, Oct 5, 2012 at 2:32 PM, Ashish Jain wrote:

> Hi,
>
> Thanks a ton!!
>
> using mark_safe() worked perfectly.
>
> - Regards
> Ashish
>
> On Friday, 5 October 2012 14:10:31 UTC+5:30, Tom Evans wrote:
>
>> On Fri, Oct 5, 2012 at 9:20 AM, Ashish Jain 
>> wrote:
>> > Hi,
>> >
>> > I wrote a simple filter as:
>> >
>> > @register.filter()
>> > def html(value):
>> > return 'Check'
>> >
>> > when I use this filter in my template, it displays html as:
>> >
>> > Check
>> >
>> > I want to display as:
>> >
>> > Check
>> >
>> > am I missing something.
>> >
>>
>> You haven't marked the output as safe, so Django escapes it:
>>
>> https://docs.djangoproject.**com/en/1.4/howto/custom-**
>> template-tags/#filters-and-**auto-escaping
>>
>> You want option 2.
>>
>> 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/-/Sz5auuOkyYcJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
*

 GlxGuru

*

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



Re: Django Admin asks password every operation

2012-10-05 Thread Stefano T
wait i may have spotted out the problem:
if i've an app, is this the correct url pattern for the homepage?  

url(r'^', 'earth.views.Home'),

or does it take ll the urls?


On Friday, October 5, 2012 8:10:09 PM UTC+2, Stefano T wrote:
>
> i didn't est SESSION_COOKIE_AGE anywhere, so i suppose it's set to its 
> default value.
> Cookies are enabled.
> i'm facing the problem in chrome (i deleted all the browser data, nothing 
> changed)
> with FF it works.
> Before it was working with chrome, suddently it stopped.
>
> On Friday, October 5, 2012 7:32:16 PM UTC+2, larry@gmail.com wrote:
>>
>> On Fri, Oct 5, 2012 at 10:57 AM, Stefano T 
>>  wrote: 
>> > Hi all. 
>> > i'm new to django and i'm facing a problem i can't solve so far. 
>> > Basically, when i log in in the admin part, every operation i do it 
>> > ask me for the login. doesn't matter which browser i user, it's always 
>> > the same. 
>> > at the beginning it was acting normally: once logged in i stay logged 
>> > in until the logout. 
>> > idea? 
>>
>> What is SESSION_COOKIE_AGE set to in your settings file? Or are 
>> cookies disabled for your browser? 
>>
>

-- 
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/-/jJ7LrE2_TC0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django on legacy Postgres database with encoding WIN1252

2012-10-05 Thread Janeskil1525
Hi Ian


Thank you for your response.

It turns out that the problem is not Django related at all, the Legacy 
system adds this character 0x81 of some reason to text strings and it seems 
like its the Postgres driver that fails to convert this to a UTF8 char. So 
its true, i have to purge the data somehow before its read.


Jan



On Thursday, October 4, 2012 7:48:59 PM UTC+2, Ian Clelland wrote:
>
> What is that character supposed to be?
>
> According to the Wikipedia page on CP1252, 0x81 is an unused character 
> position. There is a mention that it might map to some ISO-2022 control 
> code with no unicode equivalent.
>
> I'm not sure where the error message is coming from, though -- if it was 
> in the python layer, you would see something like:
>
> UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 
> 0: character maps to 
>
> Possibly the postgresql interface is trying to convert it to UTF8 for 
> transfer, and failing, or maybe the psycopg2 layer can't decode it. Is 
> there any other info you can provide about the error message?
>
> It may end up that you just have to clean the data in the database to be 
> able to use it.
>
> Ian
>
> On Thu, Oct 4, 2012 at 9:57 AM, Janeskil1525  > wrote:
>
>> Hi all
>>
>> I'm new Django user. I have a legacy system based on a Postgres 9.1 
>> database that is using encoding WIN1252. When i try to retrie data from one 
>> table I get the following error 
>>
>> >>character 0x81 of encoding "WIN1252" has no equivalent in "UTF8"<< , 
>> does that mean i cant use Django together with this database or is there 
>> some setting i need to change ?
>>
>> All help appreciated
>>
>> Thank you in advance!
>>
>>
>> Jan Eskilsson
>>
>> -- 
>> 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/-/EXpvuuttJ64J.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> -- 
> Regards,
> Ian Clelland
> 
>  

-- 
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/-/ItyOQIE44eoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django Admin asks password every operation

2012-10-05 Thread Stefano T
i didn't est SESSION_COOKIE_AGE anywhere, so i suppose it's set to its 
default value.
Cookies are enabled.
i'm facing the problem in chrome (i deleted all the browser data, nothing 
changed)
with FF it works.
Before it was working with chrome, suddently it stopped.

On Friday, October 5, 2012 7:32:16 PM UTC+2, larry@gmail.com wrote:
>
> On Fri, Oct 5, 2012 at 10:57 AM, Stefano T 
>  wrote: 
> > Hi all. 
> > i'm new to django and i'm facing a problem i can't solve so far. 
> > Basically, when i log in in the admin part, every operation i do it 
> > ask me for the login. doesn't matter which browser i user, it's always 
> > the same. 
> > at the beginning it was acting normally: once logged in i stay logged 
> > in until the logout. 
> > idea? 
>
> What is SESSION_COOKIE_AGE set to in your settings file? Or are 
> cookies disabled for your browser? 
>

-- 
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/-/Y-H7eRokhSAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django Admin asks password every operation

2012-10-05 Thread Larry Martell
On Fri, Oct 5, 2012 at 10:57 AM, Stefano T
 wrote:
> Hi all.
> i'm new to django and i'm facing a problem i can't solve so far.
> Basically, when i log in in the admin part, every operation i do it
> ask me for the login. doesn't matter which browser i user, it's always
> the same.
> at the beginning it was acting normally: once logged in i stay logged
> in until the logout.
> idea?

What is SESSION_COOKIE_AGE set to in your settings file? Or are
cookies disabled for your browser?

-- 
You received this message 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 Admin asks password every operation

2012-10-05 Thread Stefano T
Hi all.
i'm new to django and i'm facing a problem i can't solve so far.
Basically, when i log in in the admin part, every operation i do it
ask me for the login. doesn't matter which browser i user, it's always
the same.
at the beginning it was acting normally: once logged in i stay logged
in until the logout.
idea?

ciao

-- 
You received this message 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: object has no attribute '_state'

2012-10-05 Thread Demian Brecht
>
>
> I'm sure the OP from June 2010 will be pleased that his question has
> been answered so many times…
>

Eek, guess I should have read the posting date.


> PS: To call the parent class(es) constuctor(s) correctly when using
> python "new style" classes (ie: all Django classes and classes derived
> from Django classes), you should use super(ClassName, self).__init__()
> and not call the base class directly.


Call me paranoid: https://fuhm.net/super-harmful/

-- 
You received this message 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: Translation outside the broswer

2012-10-05 Thread Bastian
Thanks Tom, the logic seems pretty clear. I just didn't know about 
translation.activate. What does it do exactly? Change the current language? 
Anyway I will do my homework and google it and read the code...

Cheers.


On Friday, October 5, 2012 12:19:38 PM UTC+2, Tom Evans wrote:
>
> On Fri, Oct 5, 2012 at 10:12 AM, Bastian  
> wrote: 
> > Hi, 
> > 
> > I understand quite well how translations and i18n work inside a browser 
> for 
> > Django but I'm not sure about the correct way to do it outside a 
> browser. I 
> > mean when sending a mail or a tweet. What should I use to get the 
> language 
> > of the user that is going to receive the mail or in case of a tweet the 
> > language of the user that I will send it on behalf of. And then how do I 
> ask 
> > Django to translate that? 
> > I could not find it in the docs, if it exists please point me to it. 
> > 
> > Cheers 
> > 
>
> You will need to have a mechanism for storing what the user's chosen 
> language is. Once you have that, simply do this: 
>
> from django.utils import translation 
>
> cur_language = translation.get_language() 
> translation.activate(get_lang_for_user(user)) 
> # send email, tweet, etc 
> translation.activate(cur_language) 
>
> You would need to define the 'get_lang_for_user' function. 
>
> 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/-/UWQFiq5SddQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Inlines defined before use?

2012-10-05 Thread Bill Freeman
There are a few special cases in which Django works hard to allow you
to specify a string that will be looked up later.  And you can use
names in function and method definitions that will be defined by the
time the function is called.  But python does not, in general, support
forward references.

On Wed, Oct 3, 2012 at 5:58 PM, Lachlan Musicman  wrote:
> Hola,
>
> I'm finding that if my inlines aren't defined before use in the
> admin.py, I'm getting the following errors:
>
> inlines=('MyModelInline',)
> "issubclass() arg 1 must be a class" Errors
>
> inlines=(MyModelInline,)
> "name 'MyModelInline' is not defined"
>
> This is a minor issue, easily solved by putting the inlines at the top
> of the admin.py
>
> Is this meant to be how it works?
>
> cheers
> L.
>
> --
> ...we look at the present day through a rear-view mirror. This is
> something Marshall McLuhan said back in the Sixties, when the world
> was in the grip of authentic-seeming future narratives. He said, “We
> look at the present through a rear-view mirror. We march backwards
> into the future.”
>
> http://www.warrenellis.com/?p=14314
>
> --
> You received this message 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: object has no attribute '_state'

2012-10-05 Thread Tom Evans
On Fri, Oct 5, 2012 at 3:56 PM, Demian Brecht  wrote:
>
>>> class QuestionSet(models.Model):
>>>  title = models.CharField(max_length=100)
>>>  description = models.TextField()
>>>  order = models.IntegerField()
>>>
>>>  def __init__(self, *args, **kwargs):
>>>  self.title = kwargs.get('title','Default Title')
>>>  self.description = kwargs.get('description', 'DefDescription')
>>>  self.order = kwargs.get('order', 0)
>
>
> One thing that looks suspect to me here is that you're not calling __init__
> on models.Model.
>

I'm sure the OP from June 2010 will be pleased that his question has
been answered so many times…

Cheers

Tom

PS: To call the parent class(es) constuctor(s) correctly when using
python "new style" classes (ie: all Django classes and classes derived
from Django classes), you should use super(ClassName, self).__init__()
and not call the base class directly.

-- 
You received this message 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.



Possible bug with Form Wizard and condition_dict?

2012-10-05 Thread Scott Woodall
I searched the bug tracker and the django users with no results, so is what 
I'm seeing a bug?

I have a form wizard that is using a callable within condition_dict. If I 
try to access "wizard.steps.current" inside the callable, I get the 
following error:

"maximum recursion depth exceeded in __instancecheck__"
Exception Location: 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py 
in _reconstruct, line 307

Just trying to figure out if I should file a bug report or I'm doing 
something wrong?

-- 
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/-/LNcUmFwzmfcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Managers, Queryset, inheritance and polymorphism

2012-10-05 Thread Amirouche
Héllo,

I got a problem with manager, some of you may already know it, I try my 
best to like them, if anyone can explain me the purpose of their existence 
I will be so much grateful :)

Like I said, I try my best but:

0) Documentation 
references«default_manager»,
 but I don't find it in the code, is it a documentation 
bug ? 

0bis) What is the purpose of «_default_manager» and «_base_manager» ?

1) What is the purpose of 
«Manager.db»,
 
it's not used in Manager class, so I don't think it's used anywhere else

2) Polymorphism

   - Is there anyone that can debug two level and more of inheritance in 
   
Django-Polymorphic
   - I think this a revision of Django Polymorphic that works with that 
   problem, anyone knows the revision hash ?
   - Do you know any other application that does polymorphism the way I 
   need it (with several level of inheritance) ?
   
If they are answers to question 2, I might no need the answer to the 
following questions, I still would like to know.

I have the following models, manager and querysets 
https://gist.github.com/3826531

According to the code of  Manager in 
manager.py, 
I just need to override «get_query_set», but here is what I get as results, 
the bug is in the second line:

In [14]: PolymorphicQuerySet(Entry)
> Out[14]: [, , , , 
> , , ]
> In [15]: Entry.objects.all()
> Out[15]: []


What am I doing wrong ?

Thanks,


Amirouche

-- 
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/-/G20heNLwu6IJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django performance vs others

2012-10-05 Thread Kurtis Mullins
Probably the ability to both extend and include (template inheritance)

On Fri, Oct 5, 2012 at 9:24 AM, Amirouche Boubekki <
amirouche.boube...@gmail.com> wrote:

> I have had no idea until recently that django template are sooo slow...
>> other engines do the same... but spent less time. What the cool feature
>> prevent it for rendering it faster?
>
>
> The template parsing I guess, but I'm not sure.
>
> --
> You received this message 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: assign media to models

2012-10-05 Thread Amirouche


On Thursday, October 4, 2012 1:26:07 AM UTC+2, winniehell wrote:
>
> Hi list! 
>
> I have different models with uploaded content. So I made a Media model 
> with a primary key to ContentType to distinguish to which kind of models 
> the media belongs. Now I want to upload the media inline instead of 
> having to add a Media instance first. Can anybody give me a hint how to 
> do this? 
>

I think this involves javascript and creating custom admin views, look for 
that in the Django documentation.

HTH,


Amirouche

-- 
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/-/TAgvxrgNo7wJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: unicode decode errors in loggging on server

2012-10-05 Thread Amirouche

On Friday, October 5, 2012 10:53:24 AM UTC+2, Bram wrote:
>
> Hello all, 
>
>
> My login setup on my server does not enable console logging, only 
> to-file logging (see at the end of this message for the logger setup). 
> However, just now I got a unicode decode error in my logging: 
>
>
>   File "/home/xyz/site/xyz/views.py", line 520, in xx_yy_zz 
> logger.error(u"Successfully decoded data but data is not json: %s" 
> % decoded) 
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xb5 in position 
> 1: ordinal not in range(128) 
>
> I'm a bit puzzled by this as I'm logging only to files, which should 
> be written as UTF-8... 
> If anyone has a clue, let me know! 
>

It's seems like the string you interpolate is not ascii-decodable, try 
unicode.decode(encoding='utf-8') before interpolation
 
Do you know about sentry  ?


HTH,


Amirouche

-- 
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/-/KfR1AWoZERsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: object has no attribute '_state'

2012-10-05 Thread Demian Brecht



class QuestionSet(models.Model):
 title = models.CharField(max_length=100)
 description = models.TextField()
 order = models.IntegerField()

 def __init__(self, *args, **kwargs):
 self.title = kwargs.get('title','Default Title')
 self.description = kwargs.get('description', 'DefDescription')
 self.order = kwargs.get('order', 0)


One thing that looks suspect to me here is that you're not calling 
__init__ on models.Model.


def __init__(self, *args, **kwargs):
models.Model.__init__(self, ...)

Which will prevent the base class from initializing.

For example:

>>> class A(object):
... def __init__(self):
... print 'A init'
...
>>> class B(A):
... def __init__(self):
... A.__init__(self)
... print 'B init'
...
>>> class C(A):
... def __init__(self):
... print 'C init'
...
>>> C()
C init
<__main__.C object at 0x7fd811c23bd0>
>>> B()
A init
B init
<__main__.B object at 0x7fd811c23c50>

Constructor calls don't bubble up on their own, you have to explicitly 
call them.


I would assume that something in the model's base class is what adds the 
_state attribute. By short circuiting the constructor, you're preventing 
this from ever happening.


--
Demian Brecht
@demianbrecht
http://demianbrecht.github.com

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



Re: Newbie Looking for Starter Plugin

2012-10-05 Thread Amirouche

 

> The job description is to have a dashboard full of information, 


It might be an OK solution to use the admin changelist (list feature of the 
admin) and render graphics using admin actions with an intermediate 
pageand
 using 
filter and search . 
Given you know how to override templates and find you way through the admin 
classes and AdminModel configuration. 
 

> this information could be coming from external sites or our own sensors.
>

If you don't of Django models for your data, then you can make it work 
using django-roa  (I don't know 
if works with 1.4.1) or 
django-sneak(should work with 
1.4.1, contact me if you want help if you go this route) 
and follow the above technic.

Django-reporting might 
also be useful, but I don't know actually if it is the solution to 
your problem.

Anyway, if you don't feel like to integrate/use this applications which 
might be a bit difficult for a beginner. You can start from scratch CBV 
route  or 
function views and build a customisable dashboard yourself, I don't have 
all I need to be more precise.

I don't think the admin is the solution, it's not flexible enough but still 
a good solution for a POC application.
 

> This is what strucked me about the admin_tools interface this ability to 
> add, remove and change the layout with relative ease.
>
Yes but it's specific to admin tools I think, someone more competent might 
be of better advice, but I think that admin tools is not the application 
you are looking for. Or ask the maintenair directly through github they 
might be able to answer you :)

I suspect that users will have to be registered so it won't be open to the 
> public to just "sign up" but management have changed their mind before on 
> these type of issues.
>
I don't think this is your primary issue right now, getting the dashboard, 
graphs and data navigation up and running should be. If you go the admin 
way and the management decide that the data should be public, you can 
provide a Django user with default password, lock the change password 
feature and make the credentials available publicly.

If you feel it would be better to go for a cms
>
I say it might be, try to contact their respective maintainer or mailling 
lists.
 

> Or just use the current admin interface as is that would be great as I 
> have very little time allocated to this project being a typical government 
> organisation. 
>
Like everybody ;)
 

> That said I have tasked myself to learn the ways of Django as such I'm 
> feeling a bit overwhelmed on the practices, code structure and the best way 
> forward.
>
You problem doesn't seem to be in the Django CMS-like vein of problems, yet 
it's it's doable, but can't give a precise answer without more information.

Contact me directly if you want.

Good luck


Amirouche

-- 
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/-/FIGB0RvmQ1sJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django testing strategy

2012-10-05 Thread Dan Gentry
I've been using factory-boy as of late, and have found it to be a great way 
to setup each test exactly as I need it.  Fixtures aren't bad either, but 
working with a large amount of data can make it difficult to predict the 
proper output for a test, and changes to this data to accommodate a new 
test situation could affect others. 

You could setup a group of test records in the setup method of a test class 
to be used for several tests.

Keep your tests focused, and you'll find you won't need a huge batch of 
data to get good coverage.


>
>
 

-- 
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/-/ixLvFEgiF00J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: non-root SCRIPT_NAME, mod_wsgi and RewriteRule

2012-10-05 Thread Sebastiaan Snoeckx


> I have my Django website and my static files deployed under the same 
>> directory (i.e. no separate 'static' directory), according to the following 
>> Apache RewriteRule:
>>
>> RewriteEngine on
>> RewriteCond %{DOCUMENT_ROOT}%{REQUEST_**FILENAME} !-d
>> RewriteCond %{DOCUMENT_ROOT}%{REQUEST_**FILENAME} !-f
>> RewriteRule ^.*$ /django/$1  [QSA,PT,L]
>>
>> WSGIScriptAlias /django/ /var/www/domain.com/django/**
>> site/wsgi.py 
>>
>> My site-wide urlconf looks like this:
>>
>> urlpatterns = patterns('',
>> url(r'^blog/', include('blog.urls')),
>> url(r'', include('home.urls')),
>> )
>>
>> With my app-specific urlconf ('home.urls') is simply this:
>>
>> urlpatterns = patterns('home.views',
>> url(r'^(?P[a-z0-9-]+)/?$'**, 'page_by_uri'),
>> url(r'^$', 'index'),
>> )
>>
>> So when I visit my site domain.com I should see the index view (which it 
>> does), and when I visit domain.com/foo I should see the 
>> page_by_uri('foo') view, *which it doesn't*. Instead, it shows the index 
>> view. (And I thought it should give an error!)
>>
>> Having surfed around a little bit, I reckon it's got something to do with 
>> Django's handling of SCRIPT_NAME (which should be equal to the mount point, 
>> in my case '/dj'). Various solutions are proposed, generally involving 
>> adding the mount point to my urlconf (bad!) until I tried it and it doesn't 
>> even work...
>>
>> Basically, how in the name of all that is holy and sacred can I get this 
>> to work?!
>>
>> Thanks in advance
>>
>> is it a problem with the trailing slash?
>
>
That's a typo, it should read "WSGIScriptAlias /django 
/var/www/domain.com/django/site/wsgi.py", still, it doesn't work as it's 
supposed to. What am I doing wrong?

-- 
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/-/5nz0XcpUVBgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django testing strategy

2012-10-05 Thread Amirouche


On Friday, October 5, 2012 9:56:34 AM UTC+2, Daniele Procida wrote:
>
> On Thu, Oct 4, 2012, Evan Brumley  
> wrote: 
>
> >django-dynamic-fixture can also help a lot in this situation: 
> >http://paulocheque.github.com/django-dynamic-fixture/ 
> > 
> >Certainly beats having to futz around with fixtures. 
>
> Thanks - there seem to be a lot of tools to generate test data in various 
> ways, such as . 
>
> However I am still puzzled by the question at a slightly higher level, 
> about strategy - is it better to create a large collection of data once, 
> and to test the behviour of the system against the various combinations of 
> data in it, or to create a lengthy succession of smaller collections of 
> data,containing only the material needed for the particular combination 
> being tested each time? 
>

The problem you raising, is I think the problematic of unit-tests which 
tests a specific feature of an application versus integration aka. 
several-applications-wide tests which tests that a user workflow works 
properly like I put create a model, celery process it, then I (or another 
user) change the model, then I send an email, I get an hardbounce etc...). 
Anyway, like I said in the other mail, I do think that manual is better.

HTH,

Amirouche

-- 
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/-/mrNzXmWemz8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django testing strategy

2012-10-05 Thread Amirouche


On Thursday, October 4, 2012 7:49:19 PM UTC+2, Daniele Procida wrote:
>
> I have started writing my first tests, for a project that has become 
> pretty large (several thousand lines of source code). 
>

That is too, late! ;-)
 

>
> What needs the most testing - where most of the bugs or incorrect appear 
> emerge - are the very complex interactions between objects in the system. 
>
> To me, the intuitive way of testing would be this: 
>
> * to set up all the objects, in effect creating a complete working 
> database 
> * run all the tests on this database 
>

This method might work even if maintaining the fixture can be extra 
trouble. I never used fixture for doing tests, the useful case might not 
have presented itself but we had another way of doing it.
 

> That's pretty much the way I test things without automated tests: is the 
> output of the system, running a huge database of objects, correct? 
>

Yes, but UT, should also be some kind of a documentation of how the 
projects works, having a pre-built database doesn't give much information 
about how to setup a correct database for the project whereas fine grained 
UT do.

 

> However, I keep reading that I should isolate all my tests. 


Yes, but there might be cases where *tests fixtures are* useful, I don't 
know them.

So I have had a go at creating tests that do that, but it can mean setting 
> up a dozen objects sometimes for a single tiny test, then doing exactly the 
> same thing with one small difference for another test. 
>

Use factories for that. there is factory 
boythat seems to do the job, but I don't 
know its value, we were using our own 
factory and/or build the database manually, like I said earlier 
documenting/testing the way the database should look like  in the tests is 
IMO significant. You can also test the factory which might serve as 
documentation/tests of the proper building of the database something like:

def test_build_base_site(self):
Factory.build(Site, domain='foo', name='bar')
self.assertEquals(Site.objects.count(), 1)
site = Site.objects.all()[0]
# test domain name and name 

def test_build_section(self):
Factory.build(Section, name='Test Section')  # other fields are 
generated ! You cannot test them outsite factory UT of course...
self.assertEquals(Section.objects.all(), 1)
section = Section.objects.all()[0]
self.assertNotNone(section.site)

def test_build_article(self):
section = Factory.build('Article')
self.assertEquals(Article.objects.count(), 1)
article = Article.objects.all()[0]
self.assertNotNone(article.section)
self.assertNotNone(article.section.site)

# etc...

The factory takes some arguments to populate the fields of the objects you 
asked for (you probably can use magic parameters to populate related fields 
too), builds the object you asked for.

I don't know how complex is your schema, the  factory can be recursive so 
it's not problem.
 
 

> Often I have to run save() on these objects, because otherwise tests that 
> depend on many-to-many and other database relations won't work. 
>

I don't understand what you mean.
 

> That seems very inefficient, to create a succession of complex and 
> nearly-identical test conditions for dozens if not hundreds of tests. 
>

Could you give an example of nearly identifical tests ?
 

> I'd appreciate any advice. 
>


I don't know how does your project setup looks like but here is the one I 
worked with:

For each feature (or group of features) we split it in two apps, a generic 
app and an integration/project app. The generic app can be re-used in other 
projects, whereas the integration app does the specific templates, model, 
signal hooking specific to the current project. Then the tests follows, in 
the generic apps you tests generics things (that don't need a particular 
project setup...) and in the integration/project app you tests everything 
else. Client side testing will go in integration app testing because you 
will most likely override templates in it and if you do client side testing 
in the generic app they will fail because of the overrides.

Gotchas:
- Django application template create a tests.py in the application 
directory, remove it and create a directory instead (or use another 
application template), you will most likely need several files to do the 
testing (factory, models, feature1, feature2) and mixing it with the 
application files is ugly (you can also have a tests.py with a loc > 1000). 
Don't forget to create tests/__init__.py and import every test classes you 
create so that they can be found by Django test runner
- If the generic apps needs some models, they should be *defined* in the 
tests/__init__.py (If I remember well)
- If you have A LOT of tests, or simply want to make the life of the 
developpers easier look for fsync=off (for PostgresSQL) or similar option 
in you database of choice or (prefered if possible) use in memory 

Re: Newbie Looking for Starter Plugin

2012-10-05 Thread Luke Hovington
I will clarify a bit better on what I have been tasked to do.

The job description is to have a dashboard full of information, this 
information could be coming from external sites or our own sensors.

So with this data (yet to be decided) it could be graphed or show in table 
format for example.

Each user would be interested in diffrent things, thus having the ability to 
remove rearange and really customise the view they are seeing.

This is what strucked me about the admin_tools interface this ability to add, 
remove and change the layout with relative ease.

I suspect that users will have to be registered so it won't be open to the 
public to just "sign up" but management have changed their mind before on these 
type of issues.

If you feel it would be better to go for a cms or just use the current admin 
interface as is that would be great as I have very little time allocated to 
this project being a typical government organisation. That said I have tasked 
myself to learn the ways of Django as such I'm feeling a bit overwhelmed on the 
practices, code structure and the best way forward.
On the upside I have been using python for everything I am allowed to to choose 
the programing language.

Thanks for helping me out.
Luke

-- 
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/-/Vo8qtcPZ-P8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Virtualenvs and editing contrib stuff manually

2012-10-05 Thread Chris Pagnutti
Hey thanks Russell.  That's a great explanation.  Is there a particular 
reason that the docs tend to favour the foreign key method over subclassing?

On Thursday, September 27, 2012 4:13:34 PM UTC-4, Tundebabzy wrote:
>
> No you won't be smitten. 
>
> As for isolating your edited django, you can do that but then you 
> would have to be responsible for improving the code base by yourself. 
> Also, your edit might inadvertently break django or introduce bugs 
> that you might find difficult to trace and solve or that might change 
> some of the logic required to make django work. 
>
> On 9/27/12, Chris Pagnutti  wrote: 
> > Hi.  First-time poster here.  Feel free to point out any rules I'm not 
> > following. 
> > 
> > I've been looking around for how to make the django.contrib.auth User 
> > classe's "email" field to be unique and required.  There are bunches of 
> > ways to do it, but it's just s darn easy to go into the source and 
> > change how the field is defined. 
> > e.g. email = models.EmailField(_('email address'),unique=True) 
> > 
> > But in my searches, I've read warnings that you should not do this.  The 
> > reason, if it is given, is that you'll break your app if you update the 
> > contrib packages.  But what if I work in virtualenvs and just leave the 
> > django version and packages intact for that particular app in that 
> > particular environment?  What are the other practical and philosophical 
> > reasons for NOT editing the contrib source?  Will I be smitten from the 
> > django community if I do so? 
> > 
> > Thanks to all. 
> > 
> > -- 
> > 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/-/YX9X8u9mdbwJ. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@googlegroups.com . 
> > For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en. 
> > 
> > 
>
> -- 
> Sent from my mobile device 
>

-- 
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/-/kgPJcEQC1vAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django testing strategy

2012-10-05 Thread Amirouche
Please ignore this message I've hit «Post» by mistake I will edit my post :)
 

-- 
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/-/0S78LxSWkXoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django testing strategy

2012-10-05 Thread Amirouche


On Thursday, October 4, 2012 7:49:19 PM UTC+2, Daniele Procida wrote:
>
> I have started writing my first tests, for a project that has become 
> pretty large (several thousand lines of source code). 
>

That is too, late! ;-)
 

>
> What needs the most testing - where most of the bugs or incorrect appear 
> emerge - are the very complex interactions between objects in the system. 
>
> To me, the intuitive way of testing would be this: 
>
> * to set up all the objects, in effect creating a complete working 
> database 
> * run all the tests on this database 
>

This method might work even if maintaining the fixture can be extra 
trouble. I never used fixture for doing tests, the useful case might not 
have presented itself but we had another way of doing it.
 

> That's pretty much the way I test things without automated tests: is the 
> output of the system, running a huge database of objects, correct? 
>

Yes, but UT, should also be some kind of a documentation of how the 
projects works, having a pre-built database doesn't give much information 
about how to setup a correct database for the project whereas fine grained 
UT do.

 

> However, I keep reading that I should isolate all my tests. 


Yes, but there might be cases where *tests fixtures are* useful, I don't 
know them.

So I have had a go at creating tests that do that, but it can mean setting 
> up a dozen objects sometimes for a single tiny test, then doing exactly the 
> same thing with one small difference for another test. 
>

Use factories for that. there is factory 
boythat seems to do the job, but I don't 
know its value, we were using our own 
factory and/or build the database manually, like I said earlier 
documenting/testing the way the database should look like  in the tests is 
IMO significant. You can also test the factory which might serve as 
documentation/tests of the proper building of the database something like, 
but it can be OT of UT if the factory is not used in the project code:

def test_build_base_site(self):
Factory.build(Site)
self.assertEquals(Site.objects.count(), 42)

def test_build_section(self):
Factory.build(Section, name='Test Section')
self.assertEquals(Section.objects.all(), 1)

self.assertEquals(Section.objects.all(), 1)
def test_build_article(self):
section = Factory.build('Article')
self.assertEquals(Article.objects.all(), 42)

# etc...

The factory takes some arguments, builds the object you asked for 
I don't know how complex is your schema, the  factory can be recursive so 
it's not problem.
 

 

>
> Often I have to run save() on these objects, because otherwise tests that 
> depend on many-to-many and other database relations won't work. 
>
> That seems very inefficient, to create a succession of complex and 
> nearly-identical test conditions for dozens if not hundreds of tests. 
>
> I'd appreciate any advice. 
>
> Daniele 
>
>

-- 
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/-/3csuRekSzosJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Bug with collapse fieldsets?

2012-10-05 Thread Joel Goldstick
On Wed, Oct 3, 2012 at 6:32 PM, Janusz Jaworski  wrote:
> Hello. I found probably a little bug or it's just a feature (dunno). But my
> question is why i can't unhide collapsed fields when i use 'None' for name
> of group and use 'collapse' in dictionary in fieldsets. Here is the line of
> code and screens:
>
> fieldsets = [(None, {'fields': (('title', 'slug', 'category'),),
> 'classes':('collapse',),}), ...] and screens: first is when i use 'None' -
> http://i49.tinypic.com/b88pxg.png and second is when i use name "Example"
> for subgroup of fields - http://i50.tinypic.com/140lvg5.png . As you can see
> subgroup with 'None' and collapse turned on can't unhide cause there is just
> line with no button :( Sorry for my poor language.
>
Can you use  instead of None?


-- 
Joel Goldstick

-- 
You received this message 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: Newbie Looking for Starter Plugin

2012-10-05 Thread Amirouche
On Friday, October 5, 2012 7:47:01 AM UTC+2, Luke Hovington wrote:
>
> After lots of talk on I'm going to start using Django a project turned up 
> that allowed me to start learning how this all works.
>
> So far I have managed (Via tutorials) to get everything setup and running 
> nicely,
> I have also installed admin_tools which brings me to my question.
>
> Is there any plugin/package that would give me a admin_tool type look for 
> all my users for free?
>
> Things I'm after are..
> * Dashboard Widgets all over the page
> * Ability to remove, add and reorganise 'Widgets'
> * Settings saved for each user
>
> I will in the future need to limit the data shown in the widgets or remove 
> others depending on user permissions, but that could be another days issue.
>
> So before I start looking into how admin_tools does it's awesome stuff 
> and repurposing it, I though I would ask those who have been working with 
> it for while.
> Any suggestions?
>
>  
Are you looking for a Django Nuke  or PostNuke or 
similar application ?

I don't think it exists, but I'd be happy to be part of any team involving 
building such a thing.

That said Django-CMS and mezzanine provide a widget infrastructure it's 
just not presented like that.

Cheers,

Amirouche 

-- 
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/-/MrCIN_oyceYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Newbie Looking for Starter Plugin

2012-10-05 Thread Joel Goldstick
On Fri, Oct 5, 2012 at 1:47 AM, Luke Hovington  wrote:
> After lots of talk on I'm going to start using Django a project turned up
> that allowed me to start learning how this all works.
>
> So far I have managed (Via tutorials) to get everything setup and running
> nicely,
> I have also installed admin_tools which brings me to my question.
>
> Is there any plugin/package that would give me a admin_tool type look for
> all my users for free?
>
> Things I'm after are..
> * Dashboard Widgets all over the page
> * Ability to remove, add and reorganise 'Widgets'
> * Settings saved for each user
>
Django is a framework.  It sounds like you might be looking for a CMS

> I will in the future need to limit the data shown in the widgets or remove
> others depending on user permissions, but that could be another days issue.
>
Built in to admin is the capability to give permissions to users and
groups.  You should look at that.


> So before I start looking into how admin_tools does it's awesome stuff and
> repurposing it, I though I would ask those who have been working with it for
> while.


> Any suggestions?
>
If your users are trusted (like people in your company? -- not
anonymous users) you can give them access to the admin.  They will
only have the capabilities you allow via the permissions you set.  I
think this is a really great feature of django.  Admin is not just for
the developer (although its great for the developer), but for trusted
staff so you don't have to re-invent all the stuff it does (CRUD)


-- 
Joel Goldstick

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



Re: Django performance vs others

2012-10-05 Thread Amirouche Boubekki
>
> I have had no idea until recently that django template are sooo slow...
> other engines do the same... but spent less time. What the cool feature
> prevent it for rendering it faster?


The template parsing I guess, but I'm not sure.

-- 
You received this message 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: Why can't I activate the admin site?

2012-10-05 Thread Tom Evans
On Fri, Oct 5, 2012 at 9:18 AM, Dae_James  wrote:
> I created a new django project and did the following three things:
> 1, Uncomment "django.contrib.admin" in the INSTALLED_APPS setting.
> 2, Run python manage.py syncdb. Since you have added a new application to
> INSTALLED_APPS, the database tables need to be updated.
> 3, Edit your mysite/urls.py file and uncomment the lines that reference the
> admin – there are three lines in total to uncomment.
>
> And then typed in "python manage.py runserver" to start server.
>
> After all this, when I visit http://127.0.0.1:8000/admin/ , welcome site
> displayed instead of the admin site.
> What's the matter, please ? I'm a new hand to django.
>

Can you show your urls? I expect the one for 'welcome site' matches
the url for the admin site before the admin url is tested, and so is
routed there instead.

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.



Newbie Looking for Starter Plugin

2012-10-05 Thread Luke Hovington
After lots of talk on I'm going to start using Django a project turned up 
that allowed me to start learning how this all works.

So far I have managed (Via tutorials) to get everything setup and running 
nicely,
I have also installed admin_tools which brings me to my question.

Is there any plugin/package that would give me a admin_tool type look for 
all my users for free?

Things I'm after are..
* Dashboard Widgets all over the page
* Ability to remove, add and reorganise 'Widgets'
* Settings saved for each user

I will in the future need to limit the data shown in the widgets or remove 
others depending on user permissions, but that could be another days issue.

So before I start looking into how admin_tools does it's awesome stuff 
and repurposing it, I though I would ask those who have been working with 
it for while.
Any suggestions?

Thanks in advance

-- 
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/-/MW-qqJOKSk0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: object has no attribute '_state'

2012-10-05 Thread Clarence Zeng
I think you shouldn't use __init__ to init your variables. try using 
another way (custom method)

http://stackoverflow.com/questions/10307635/error-passing-user-to-foreignkey-in-django


On Tuesday, July 6, 2010 10:51:51 AM UTC+8, jcage wrote:
>
> Hi everyone. I'm quite new to python and django. I was wondering if 
> anyone could shed some light on this topic : 
>
> My models.py contains the classes QuestionSet and Question, which 
> inherits the former. 
> In the shell, I define a Question object as follows 
>
> q1 = Question(script = "How are you?", comment = "no comment", order = 
> 1) 
>
>
> but an attempt to run q1.save() results in the following error : 
>
> >>> q1.save() 
> Traceback (most recent call last): 
>   File "", line 1, in  
>   File "/Library/Frameworks/Python.framework/Versions/2.6/lib/ 
> python2.6/site-packages/django/db/models/base.py", line 435, in save 
> self.save_base(using=using, force_insert=force_insert, 
> force_update=force_update) 
>   File "/Library/Frameworks/Python.framework/Versions/2.6/lib/ 
> python2.6/site-packages/django/db/models/base.py", line 447, in 
> save_base 
> using = using or router.db_for_write(self.__class__, 
> instance=self) 
>   File "/Library/Frameworks/Python.framework/Versions/2.6/lib/ 
> python2.6/site-packages/django/db/utils.py", line 133, in _route_db 
> return hints['instance']._state.db or DEFAULT_DB_ALIAS 
> AttributeError: 'Question' object has no attribute '_state' 
>
>
>
> The class definitions are : 
>
> class QuestionSet(models.Model): 
> title = models.CharField(max_length=100) 
> description = models.TextField() 
> order = models.IntegerField() 
>
> def __init__(self, *args, **kwargs): 
> self.title = kwargs.get('title','Default Title') 
> self.description = kwargs.get('description', 'DefDescription') 
> self.order = kwargs.get('order', 0) 
>
>
> class Question(QuestionSet): 
> script = models.CharField(max_length=200) 
> comment = models.TextField() 
>
>
> def __init__(self, *args, **kwargs): 
> QuestionSet.__init__(self, args, kwargs) 
> self.script = kwargs.get('script', "undefined") 
> self.comment = kwargs.get('comment', "no comment") 
>
>
>
>
> Would greatly appreciate any suggestions

-- 
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/-/w_9u1L2ZQ4EJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Why can't I activate the admin site?

2012-10-05 Thread Dae_James
I created a new django project and did the following three things:
1, Uncomment "django.contrib.admin" in the 
INSTALLED_APPSsetting.
2, Run python manage.py syncdb. Since you have added a new application to 
INSTALLED_APPS,
 
the database tables need to be updated.
3, Edit your mysite/urls.py file and uncomment the lines that reference the 
admin – there are three lines in total to uncomment. 

And then typed in "python manage.py runserver" to start server.

After all this, when I visit http://127.0.0.1:8000/admin/ , welcome site 
displayed instead of the admin site.
What's the matter, please ? I'm a new hand to django.

-- 
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/-/pT_qMfYG-NQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Array sharing across frame carries stale copy - How to fix it?

2012-10-05 Thread anirM
Daniel: Thanks again. The session worked! I used dbase backend and got it 
to work perfectly. Thank you.
anirM

On Thursday, October 4, 2012 6:23:36 AM UTC-4, anirM wrote:
>
> Hi Daniel you guys are phenomenal! I did not expect you would be willing 
> to help looking in to the code. I will soon update this post with some 
> stripped down code. But, I do not know about session and may be I should 
> try that first. In any case, I will return soon.  Thank you
> anirM
>
> On Thursday, October 4, 2012 6:18:52 AM UTC-4, Daniel Roseman wrote:
>>
>> On Thursday, 4 October 2012 11:12:42 UTC+1, anirM wrote:
>>
>>> Hi: 
>>>
>>> Thanks for your help. I am new here.
>>>
>>> I have two iframes and a common data model. On one frame I perform query 
>>> on the data and create a list/array which is then pushed via an URL and 
>>> view on to the other iframe for processing and display. Because they are in 
>>> different frames, I am using different view functions. But, as the first 
>>> query is done, I populate a first_frame_view.search_list array that I 
>>> expect to be available (via the same views.py) to the other iframe in its 
>>> view function if I refer it the same first_frame_view.search_list. That's 
>>> exactly the behavior I get on development server from django (runserver), 
>>> but mod_WSGI returns unpredictable stale copy of the search_list. Could you 
>>> please suggest an alternative or a fix. Thanks in advance.
>>> anirM
>>>
>>
>> How can we suggest a fix if you don't provide any code? I'll take a 
>> guess: you're storing something at the module level. That sounds like an 
>> extremely bad idea, as not only will it be visible to the other frame, but 
>> also to all other users who happen to be served from the same process. Use 
>> a session, that's what they're for.
>> --
>> DR.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/zjGCQ2ybfGcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: URLField and Web Sockets URLs

2012-10-05 Thread Julian Cerruti
Thanks Kurtis and Russ.

For now, since this is a very minor feature of my app, I decided to go the 
easy route and turn my field into a CharField.

When I get some more time I will try to exercise the contribution mechanism 
as a way to get more familiarized with it.

Thank you guys both for your orientation.

Best,
Julian

On Thursday, October 4, 2012 5:43:41 PM UTC-3, Kurtis wrote:
>
> Looks like this is similar and shows that people want other protocols as 
> well: 
> http://stackoverflow.com/questions/8778416/what-are-the-valid-values-for-a-django-url-field
>
> You could modify the validator's regex but I imagine the cleanest way to 
> do this would be to make a copy of it in your own code base and modify/use 
> accordingly.
>
> I'm not sure on the best way to make proposals. Hopefully someone else can 
> chime in there for you.
>
> On Thu, Oct 4, 2012 at 12:51 PM, Julian Cerruti 
>  > wrote:
>
>> Apparently the current implementation of URLField rejects Web Sockets 
>> URLs such as ws://my.server.com/
>>
>> This seems to be due to the implementation of the underlying 
>> URLValidator, which has a regex to search for ftp or http based URLs only.
>>
>> Is there any chance the URLValidator regexp can be updated to include ws 
>> as a valid protocol qualifier too?
>>
>> Also, more generally, what is the recommended procedure for proposing 
>> changes (and accompanying code) such as 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/-/ap-_kaacEngJ.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ZfZtVrajjvEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Translation outside the broswer

2012-10-05 Thread Tom Evans
On Fri, Oct 5, 2012 at 10:12 AM, Bastian  wrote:
> Hi,
>
> I understand quite well how translations and i18n work inside a browser for
> Django but I'm not sure about the correct way to do it outside a browser. I
> mean when sending a mail or a tweet. What should I use to get the language
> of the user that is going to receive the mail or in case of a tweet the
> language of the user that I will send it on behalf of. And then how do I ask
> Django to translate that?
> I could not find it in the docs, if it exists please point me to it.
>
> Cheers
>

You will need to have a mechanism for storing what the user's chosen
language is. Once you have that, simply do this:

from django.utils import translation

cur_language = translation.get_language()
translation.activate(get_lang_for_user(user))
# send email, tweet, etc
translation.activate(cur_language)

You would need to define the 'get_lang_for_user' function.

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: Translation outside the broswer

2012-10-05 Thread Avraham Serour
I believe that when you detect the language you could store in the user
profile the selected language (either it was automatic or manual), when
sending your email just check that

On Fri, Oct 5, 2012 at 11:12 AM, Bastian  wrote:

> Hi,
>
> I understand quite well how translations and i18n work inside a browser
> for Django but I'm not sure about the correct way to do it outside a
> browser. I mean when sending a mail or a tweet. What should I use to get
> the language of the user that is going to receive the mail or in case of a
> tweet the language of the user that I will send it on behalf of. And then
> how do I ask Django to translate that?
> I could not find it in the docs, if it exists please point me to it.
>
> Cheers
>
> --
> 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/-/ikoUTSyxuykJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.



Translation outside the broswer

2012-10-05 Thread Bastian
Hi,

I understand quite well how translations and i18n work inside a browser for 
Django but I'm not sure about the correct way to do it outside a browser. I 
mean when sending a mail or a tweet. What should I use to get the language 
of the user that is going to receive the mail or in case of a tweet the 
language of the user that I will send it on behalf of. And then how do I 
ask Django to translate that?
I could not find it in the docs, if it exists please point me to it.

Cheers

-- 
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/-/ikoUTSyxuykJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Print html the normal way

2012-10-05 Thread Ashish Jain
Hi,

Thanks a ton!!

using mark_safe() worked perfectly.

- Regards
Ashish

On Friday, 5 October 2012 14:10:31 UTC+5:30, Tom Evans wrote:
>
> On Fri, Oct 5, 2012 at 9:20 AM, Ashish Jain 
>  
> wrote: 
> > Hi, 
> > 
> > I wrote a simple filter as: 
> > 
> > @register.filter() 
> > def html(value): 
> > return 'Check' 
> > 
> > when I use this filter in my template, it displays html as: 
> > 
> > Check 
> > 
> > I want to display as: 
> > 
> > Check 
> > 
> > am I missing something. 
> > 
>
> You haven't marked the output as safe, so Django escapes it: 
>
>
> https://docs.djangoproject.com/en/1.4/howto/custom-template-tags/#filters-and-auto-escaping
>  
>
> You want option 2. 
>
> 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/-/Sz5auuOkyYcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



unicode decode errors in loggging on server

2012-10-05 Thread Bram de Jong
Hello all,


My login setup on my server does not enable console logging, only
to-file logging (see at the end of this message for the logger setup).
However, just now I got a unicode decode error in my logging:


  File "/home/xyz/site/xyz/views.py", line 520, in xx_yy_zz
logger.error(u"Successfully decoded data but data is not json: %s"
% decoded)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb5 in position
1: ordinal not in range(128)

I'm a bit puzzled by this as I'm logging only to files, which should
be written as UTF-8...
If anyone has a clue, let me know!

greetings,

 - bram


My logging setup:

LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'standard': {
'format': '%(asctime)s %(levelname)-7s %(process)d
%(thread)d %(name)-20s ## %(message)s'
},
},
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'default': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': abs_path(os.path.join('logs', 'default.log')),
'maxBytes': 1024 * 1024 * 5, # 5 MB
'backupCount': 50,
'formatter': 'standard'
},
'db_handler': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': abs_path(os.path.join('logs', 'django_db.log')),
'maxBytes': 1024*1024*5, # 5 MB
'backupCount': 50,
'formatter': 'standard',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'standard'
},
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'Site.custom_admin_logging.CustomAdminEmailHandler',
'formatter': 'standard',
}
},
'loggers': {
'': {
'handlers': ['default', 'mail_admins'],
'level': 'DEBUG',
'propagate': True
},
'django.request': {
'handlers': ['default', 'mail_admins'],
'level': 'WARNING',
'propagate': True,
},
'django.db.backends': {
'handlers': ['db_handler', 'mail_admins'],
'level': 'DEBUG',
'propagate': False,
},
}
}



-- 
http://www.samplesumo.com
http://www.freesound.org
http://www.smartelectronix.com
http://www.musicdsp.org

office: +32 (0) 9 335 59 25
mobile: +32 (0) 484 154 730

-- 
You received this message 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: Print html the normal way

2012-10-05 Thread Tom Evans
On Fri, Oct 5, 2012 at 9:20 AM, Ashish Jain  wrote:
> Hi,
>
> I wrote a simple filter as:
>
> @register.filter()
> def html(value):
> return 'Check'
>
> when I use this filter in my template, it displays html as:
>
> Check
>
> I want to display as:
>
> Check
>
> am I missing something.
>

You haven't marked the output as safe, so Django escapes it:

https://docs.djangoproject.com/en/1.4/howto/custom-template-tags/#filters-and-auto-escaping

You want option 2.

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.



Print html the normal way

2012-10-05 Thread Ashish Jain
Hi, 

I wrote a simple filter as: 

@register.filter() 
def html(value): 
return 'Check' 

when I use this filter in my template, it displays html as: 

Check 

I want to display as: 

Check 

am I missing something. 

- Thanks for your help 
Ashish 

-- 
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/-/gtEV05dOMWoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Passing template variables within static template

2012-10-05 Thread Zoran Hranj
Doh!

Thank you, sir!

On Thursday, October 4, 2012 5:17:59 PM UTC+2, Laxmikant Gurnalkar wrote:
>
> Try,
>  
> cheers
> L
> On Thu, Oct 4, 2012 at 8:27 PM, Zoran Hranj  > wrote:
>
>> Hi guys,
>>
>> basicly I want to do the following:
>>
>> 
>>
>> But the "{{ item.url }}" part does not get evaluated. I understand why it 
>> is not evaualted, but I want to know if there is a filter or something to 
>> make it work like I want to (quick glance on the filter list didnt give me 
>> 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/-/G8nMOFvfW9cJ.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> -- 
> * 
>
>  GlxGuru
>
> *
>  

-- 
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/-/_a4HiU6VssoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django testing strategy

2012-10-05 Thread Daniele Procida
On Thu, Oct 4, 2012, Evan Brumley  wrote:

>django-dynamic-fixture can also help a lot in this situation:
>http://paulocheque.github.com/django-dynamic-fixture/
>
>Certainly beats having to futz around with fixtures.

Thanks - there seem to be a lot of tools to generate test data in various ways, 
such as .

However I am still puzzled by the question at a slightly higher level, about 
strategy - is it better to create a large collection of data once, and to test 
the behviour of the system against the various combinations of data in it, or 
to create a lengthy succession of smaller collections of data,containing only 
the material needed for the particular combination being tested each time?

Daniele

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



Re: Django testing strategy

2012-10-05 Thread Evan Brumley
django-dynamic-fixture can also help a lot in this situation:
http://paulocheque.github.com/django-dynamic-fixture/

Certainly beats having to futz around with fixtures.


On Friday, October 5, 2012 3:49:19 AM UTC+10, Daniele Procida wrote:
>
> I have started writing my first tests, for a project that has become 
> pretty large (several thousand lines of source code). 
>
> What needs the most testing - where most of the bugs or incorrect appear 
> emerge - are the very complex interactions between objects in the system. 
>
> To me, the intuitive way of testing would be this: 
>
> * to set up all the objects, in effect creating a complete working 
> database 
> * run all the tests on this database 
>
> That's pretty much the way I test things without automated tests: is the 
> output of the system, running a huge database of objects, correct? 
>
> However, I keep reading that I should isolate all my tests. So I have had 
> a go at creating tests that do that, but it can mean setting up a dozen 
> objects sometimes for a single tiny test, then doing exactly the same thing 
> with one small difference for another test. 
>
> Often I have to run save() on these objects, because otherwise tests that 
> depend on many-to-many and other database relations won't work. 
>
> That seems very inefficient, to create a succession of complex and 
> nearly-identical test conditions for dozens if not hundreds of tests. 
>
> I'd appreciate any advice. 
>
> Daniele 
>
>

-- 
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/-/JGC6UxYp1qYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.