Re: Model validation across relationships

2014-03-24 Thread Joshua Pokotilow
Thanks for the reply. I had a (perhaps unreasonable) malaise that 
validation should be limited to the fields on a single model.

On Sunday, March 23, 2014 4:19:29 PM UTC-4, Simon Charette wrote:
>
> I'd say that's exactly what you should use `Model.clean()` for. In this 
> case you're *doing validation that requires access to more than a single 
> field.*
>
> What sounds vague to you in the documentation?
>
> Le vendredi 21 mars 2014 19:43:07 UTC-4, Joshua Pokotilow a écrit :
>>
>> Given these models, would UserProfile.clean() make sense as written?
>>
>> class PhoneNumber(models.Model):
>> user = models.ForeignKey(User, related_name='phone_numbers')
>> phone_number = models.CharField(max_length=20)
>>
>> class UserProfile(models.Model):
>> user = models.OneToOneField(User)
>> sms_notifications_enabled = models.BooleanField(default=False)
>>
>> # Given these models / fields, does this implementation make sense?
>> def clean(self):
>> if self.sms_notifications_enabled:
>> if not self.user.phone_numbers.exists():
>> raise ValidationError("SMS notifications cannot be enabled 
>> because this user has no phone number")
>>
>> I *think* it’s OK, but the documentation for Model.clean() seems 
>> somewhat vague about what sorts of checks one may implement. Specifically, 
>> it says, “This method should be used to provide custom model validation, 
>> and to modify attributes on your model if desired. For instance, you could 
>> use it to automatically provide a value for a field, or to do validation 
>> that requires access to more than a single field.”
>>
>> Is the above code in line with best practices?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0b3f9b10-f20a-4684-81d7-f04a62bf3790%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Managing translations on a team project

2014-03-24 Thread Alex Mandel
On 03/24/2014 03:24 PM, Tyler Wymer wrote:
> We have finished translating our application into a second language, but 
> are having trouble finding a good solution for keeping this up to date 
> going forward. Currently we have just been sending the .po file to the 
> translator, but as we hope to have the dual language support not be a 
> "beta" thing, we need to find a more serious way to handle this.
> 
> We have about 12 developers spread around the world working full time on 
> the project, which means that strings change rapidly and it's hard to keep 
> up on what is needed for translations before the list gets rather long. Can 
> anyone recommend blogs or tools that can help manage this problem? We would 
> basically love some way to get a list of strings that are currently 
> untranslated generated automatically so our translators can know what needs 
> done.
> 
> We looked into using the django-rosetta project, but seems like it wouldn't 
> work well with our deployment process.
> 

Some ideas
https://www.transifex.com/
http://pootle.translatehouse.org/

Enjoy,
Alex

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


All purpose type checking

2014-03-24 Thread Lee Hinde
I have a search form that lets a user pick the field to be searched from a
pop-up. They could enter a date, a string or a number. Sometimes they enter
all of the above and I'm only expecting one of the above.

GET:,

I'm not catching type errors very gracefully and I'm wondering if there's a
general approach to such things, or if I need to hard code the each test.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BePoMyOSpOTpDhhvz9CeZ8CD8_3Zhtz-DkG%3DRA5aD0B%3DYYd1w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Managing translations on a team project

2014-03-24 Thread Tyler Wymer
We have finished translating our application into a second language, but 
are having trouble finding a good solution for keeping this up to date 
going forward. Currently we have just been sending the .po file to the 
translator, but as we hope to have the dual language support not be a 
"beta" thing, we need to find a more serious way to handle this.

We have about 12 developers spread around the world working full time on 
the project, which means that strings change rapidly and it's hard to keep 
up on what is needed for translations before the list gets rather long. Can 
anyone recommend blogs or tools that can help manage this problem? We would 
basically love some way to get a list of strings that are currently 
untranslated generated automatically so our translators can know what needs 
done.

We looked into using the django-rosetta project, but seems like it wouldn't 
work well with our deployment process.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/951233fc-df3d-415c-a9a2-5d8308e3fc36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Registration Customization Problem

2014-03-24 Thread Abbas Sheikh
Hello All,

I want the following registration workflow in my app.

   1. User enters his email and is automatically logged-in to the app. The 
   user can play with the app, and it would logout the user after 30 minutes.
   2. Meanwhile an activation email goes out to user's email that would
  1. Confirm his email address
  2. Redirects the user to a new page where he enters his first/last 
  name and password
  3. User can now login to the app his new password.

To implement this workflow, I customized registration 
backend(registration.backends.default.DefaultBackend). Specifically, I have 
override the 'post_activation_redirect' method to redirect the user to his 
profile update page. Where he enters his name and password and submits 
data. 

> from registration.backends.default import DefaultBackend
>
> class CustomBackend(DefaultBackend):
>
> def post_activation_redirect(self, request, user):
> """
> Return the name of the URL to redirect to after successful
> account activation.
> 
> """
> return ('update_user_profile', (user, ), {})
>
However, the problem is that when user clicks on activation link his email 
is validated and activation_key expires. Now if user does not fill his 
profile information at that point in time, the activation link would no 
longer redirect him to profile update page because the activation key has 
expired. 

Please advise how to solve this problem. 

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


Re: Deployment in Django

2014-03-24 Thread Aryak Sengupta
Alrught .. thanks a lot .. :)


On Mon, Mar 24, 2014 at 4:17 PM, Lachlan Musicman  wrote:

> There's no such thing as a proper Git repository for Django, or even a
> proper layout for django.
>
> But you really can't go wrong following the advise offered in Two
> Scoops of Django by Daniel Greenfeld and Audrey Roy. First up, they
> say exactly that - there is no "right" way. Then they follow with "but
> this is how we do it and why" - their experience shines through and
> their reasoning is well made and makes good sense.
>
> I've done all my layouts since in the same way, and it works
> wonderfully - if only in my own head. Hope that helps.
>
> Cheers
> L.
>
> On 24 March 2014 17:39, Aryak Sengupta  wrote:
> > Is there any proper guideline or tutorial for creating a git repository
> for
> > Django projects before using pythonanywhere for publishibg it?
> >
> >
> > Thanks
> >
> > On 22 Mar 2014 20:20, "Amim Knabben"  wrote:
> >>
> >> Probably the ones you read there...
> >>
> >> If you aren't new on Linux, install the env on Virtualenv (go for
> >> virtualenvwrapper, it will give you some hackable shortcuts), I like
> >> PostgreSQL most, for static/media stuff normally I use Nginx, and for
> WSGI
> >> Gunicorn, the guys from New Relic have an awesome monitoring tool for
> free
> >> (without history).
> >>
> >> The answer for your first question can be: try Gondor.io or Heroku. But
> if
> >> you have spare time grab some beers and go with Vagrant, Chef and a
> bunch of
> >> Fabric lines.
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Django users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an
> >> email to django-users+unsubscr...@googlegroups.com.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> Visit this group at http://groups.google.com/group/django-users.
> >> To view this discussion on the web visit
> >>
> https://groups.google.com/d/msgid/django-users/CAODc%2BXYh%3D_4Q1UntN9hdRJhB4jfwtUL-EuQ3f_xoYyY5bjb6VQ%40mail.gmail.com
> .
> >> For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at http://groups.google.com/group/django-users.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/django-users/CALTbq1zXhLCLTa%3D7F872tPvyergXX_DEeZQrC0-yT3rfDjP9GQ%40mail.gmail.com
> .
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> From this perspective it is natural that anarchism be marked by
> spontaneity, differentiation, and experimentation that it be marked by
> an expressed affinity with chaos, if chaos is understood to be what
> lies outside or beyond the dominant game or system. Because of the
> resistance to definition and categorisation, the anarchist principle
> has been variously interpreted as, rather than an articulated
> position, "a moral attitude, an emotional climate, or even a mood".
> This mood hangs in dramatic tension between utopian hope or dystopian
> nihilism...
> -
> http://zuihitsu.org/godspeed-you-black-emperor-and-the-politics-of-chaos
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAGBeqiMW2NR%3Dw8TuSUnUQi-jeJwE2inkfT%3Dtdu%2Bx1TQYv9_%3D3w%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: loaddata not looking for natural keys

2014-03-24 Thread bobhaugen
Ok, problem resolved.

I must have done something else wrong the last time I did loaddata, because 
I tried the whole sequence again with the natural_keys as tuples, and it 
all worked.

Sorry to bother the list so much.

But to summarize, natural_keys must be tuples, not single unicode values.

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


Re: loaddata not looking for natural keys

2014-03-24 Thread bobhaugen
Not a tuple, it's now a json array. (Still not seeing things accurately...)

So I would think it would deserialize with __iter__, but I still get the 
same deserialization error message.

On Monday, March 24, 2014 8:38:52 AM UTC-5, bobhaugen wrote:
>
> Got a clue. I re-read the doc and it says the natural  key value must be a 
> tuple.  Missed that before.
>
> So I changed it like this:
> def natural_key(self):
> return (self.name,)
>
> In the shell, that properly returns a tuple:
>
> (u'Cash Contribution',)
>
>
> But in the dumpdata results, it is not a tuple:
> {
> "pk": 22, 
> "model": "valueaccounting.patternfacetvalue", 
> "fields": {
> "facet_value": 4, 
> "pattern": 9, 
> "event_type": [
> "Cash Contribution"
> ]
> }
> }, 
>
> So I am still missing something.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6d01a7a4-dc26-462f-8784-69302c1cce1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: loaddata not looking for natural keys

2014-03-24 Thread bobhaugen
Got a clue. I re-read the doc and it says the natural  key value must be a 
tuple.  Missed that before.

So I changed it like this:
def natural_key(self):
return (self.name,)

In the shell, that properly returns a tuple:

(u'Cash Contribution',)


But in the dumpdata results, it is not a tuple:
{
"pk": 22, 
"model": "valueaccounting.patternfacetvalue", 
"fields": {
"facet_value": 4, 
"pattern": 9, 
"event_type": [
"Cash Contribution"
]
}
}, 

So I am still missing something.

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


Re: Deployment in Django

2014-03-24 Thread Lachlan Musicman
There's no such thing as a proper Git repository for Django, or even a
proper layout for django.

But you really can't go wrong following the advise offered in Two
Scoops of Django by Daniel Greenfeld and Audrey Roy. First up, they
say exactly that - there is no "right" way. Then they follow with "but
this is how we do it and why" - their experience shines through and
their reasoning is well made and makes good sense.

I've done all my layouts since in the same way, and it works
wonderfully - if only in my own head. Hope that helps.

Cheers
L.

On 24 March 2014 17:39, Aryak Sengupta  wrote:
> Is there any proper guideline or tutorial for creating a git repository for
> Django projects before using pythonanywhere for publishibg it?
>
>
> Thanks
>
> On 22 Mar 2014 20:20, "Amim Knabben"  wrote:
>>
>> Probably the ones you read there...
>>
>> If you aren't new on Linux, install the env on Virtualenv (go for
>> virtualenvwrapper, it will give you some hackable shortcuts), I like
>> PostgreSQL most, for static/media stuff normally I use Nginx, and for WSGI
>> Gunicorn, the guys from New Relic have an awesome monitoring tool for free
>> (without history).
>>
>> The answer for your first question can be: try Gondor.io or Heroku. But if
>> you have spare time grab some beers and go with Vagrant, Chef and a bunch of
>> Fabric lines.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAODc%2BXYh%3D_4Q1UntN9hdRJhB4jfwtUL-EuQ3f_xoYyY5bjb6VQ%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALTbq1zXhLCLTa%3D7F872tPvyergXX_DEeZQrC0-yT3rfDjP9GQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
>From this perspective it is natural that anarchism be marked by
spontaneity, differentiation, and experimentation that it be marked by
an expressed affinity with chaos, if chaos is understood to be what
lies outside or beyond the dominant game or system. Because of the
resistance to definition and categorisation, the anarchist principle
has been variously interpreted as, rather than an articulated
position, “a moral attitude, an emotional climate, or even a mood”.
This mood hangs in dramatic tension between utopian hope or dystopian
nihilism...
-
http://zuihitsu.org/godspeed-you-black-emperor-and-the-politics-of-chaos

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGBeqiMW2NR%3Dw8TuSUnUQi-jeJwE2inkfT%3Dtdu%2Bx1TQYv9_%3D3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Deployment in Django

2014-03-24 Thread Aryak Sengupta
Is there any proper guideline or tutorial for creating a git repository for
Django projects before using pythonanywhere for publishibg it?


Thanks
On 22 Mar 2014 20:20, "Amim Knabben"  wrote:

> Probably the ones you read there...
>
> If you aren't new on Linux, install the env on Virtualenv (go for
> virtualenvwrapper, it will give you some hackable shortcuts), I like
> PostgreSQL most, for static/media stuff normally I use Nginx, and for WSGI
> Gunicorn, the guys from New Relic have an awesome monitoring tool for free
> (without history).
>
> The answer for your first question can be: try Gondor.io or Heroku. But if
> you have spare time grab some beers and go with Vagrant, Chef and a bunch
> of Fabric lines.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAODc%2BXYh%3D_4Q1UntN9hdRJhB4jfwtUL-EuQ3f_xoYyY5bjb6VQ%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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