What to Django people have to say about Javascript frameworks to complement Django's philosophy on the front end

2013-04-17 Thread Doug S
I hope this is OK to talk Javascript in this Django group, I'm hoping its 
relevant to enough Django folks to not be distracting.
I'm relatively new to Django, but my impression is that a few years ago 
most django people prescribed to the wisdom of keeping javascript to a 
minimum and just using simple JQuery to do simple tasks. Now I think heavy 
Javascript usage is more of reality especially with the shift to more 
mobile web apps, and that the Javascript community is stepping up and 
providing some nice frameworks that can make django people feel a little 
more at home using javascript, more high level frameworks that use MVC 
architecture. I'm starting a few projects where I'll want to essentially 
mirror my django models on the front end to allow editing with out page 
refreshes, front end form validation, and switching between views that are 
downloaded in one request but displayed only according to the state of the 
front end javascript view state. I want nice seemless AJAX communcation 
between the front and back end. I'm aware of a few Javascript libraries 
that are focused around these things and improving javascript web app 
development in general. KnockOutJS caught my eye at first and I did some 
work with that. I found some things worked really fast and really easy, but 
then once I tried more complex things I saw what I think where limitations 
in its extensibility. Since I'm pretty inexperienced with it, I'm not sure 
if this was my lack of experience or deficiencies in the framework. Then I 
found out about Ember,js and it seemed to me like a more complete framework 
( it tagline is 'Ambitious Web Apps' ) that could probably handle almost 
any situation that I would use it for, although for simple views it 
required a tad more code to be written than KnockOutJS. My first experience 
with Ember last weekend was pretty frustrating, working off what looks like 
the only example in the docs and finding myself buried in errors that were 
entirely foreign to me. This may be beginners luck but I also heard someone 
more experienced express frustration with the learning curve and lack of 
examples in the docs. I've just become aware of a number of Javascript 
libraries that seem to do related things that will be useful for my needs 
above. AngularJS I think is gaining popularity quickly and seems to be 
selling itself as a simple solution that can be extended in any variety of 
ways ( much like django ). I tend to feel good about trusting Google but I 
wonder if what I think is a more structured approach in Ember js is a wiser 
choice for me. I've also read about Spine, which describes itself as a 
simple lightweight MVC framework. Backbone is apparently a library entirely 
concerned with front end data models but not databinding or routing. I 
found a library called Batman intended for Rails but since a Google search 
for django and batman is all about movies and not programming I'm guessing 
no one has adapted this JS lib for django. All of what I'm writing is not 
based on expertise or experience, what I'm really hoping for is some hints 
from django people about what they use or what the pros and cons of the 
different options for javascript frameworks are, and to encourage 
discussion about this that might be useful to a lot of django people 
looking to bridge the front end with backend. Feel free to stretch the 
boundaries of my questions if you even think I've given any clear 
boundaries, assume that you know more than I, and if you're wrong, no 
worries, this discussion is as much for your education as it is for mine.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: djano user registration form and login(full example)

2013-04-17 Thread sachin
Hello again,

In extended auth user model, is there any *way to handle unique fields with 
django forms*. 

Lets say I have model like:

class UserProfile(models.Model):
user = models.OneToOneField(User)
phone_num = models.BigIntegerField(null=True, unique=True)

def __unicode__(self):
return "%s" % self.user


so how can a user gets an error message if the phone number already exist?
Is there any django way to handle this??


On Wednesday, April 17, 2013 12:58:46 PM UTC+5:30, sachin wrote:
>
> Thanx,
>
> Btw, I solved it by creating an instance of get_profile() and then saving 
> user and profile separately.
>
> here is the code snippet of *forms.py* 
>
> if commit:
> profile = user.get_profile()
> profile.serial_num = self.cleaned_data['serial_num']
> profile.save()
> user.save()
>  return user, profile
>
>
>
>
>
> On Wed, Apr 17, 2013 at 11:09 AM, Avnesh Shakya wrote:
>
>> This error is occur when you're saving the member, not the user. When 
>> creating the member, you are not assigning the user.
>>
>>
>> On Wed, Apr 17, 2013 at 10:45 AM, sachin  wrote:
>>
>>> I m still stuck with 
>>>
>>> Exception Type: IntegrityError
>>> Exception Value: column user_id is not unique
>>>
>>> Whenever I try to save, it throws the above error.
>>>
>>> I have attached files for reference, can someone help ??
>>>
>>>
>>>
>>> On Saturday, April 6, 2013 7:07:32 PM UTC+5:30, sachin wrote:

 Thanx Shawn,
 *
 *
 UserCreationForm really helped.

 Now I have a different problem, I'm trying to add custom feilds to *auth 
 user *using 
 storing-additional-**information-about-users
 .
 But now I m getting this error.

 Exception Type:IntegrityError Exception Value:

 column user_id is not unique



 This is my *models.py *file:
 *
 *
 from django.db import models
 from django.contrib.auth.models import User
 from django.db.models.signals import post_save

 class UserProfile(models.Model):
 user = models.OneToOneField(User)
 sr_no = models.CharField(max_length=**10)

 def __unicode__(self):
 return self.sr_no

 def create_user_profile(sender, instance, created, **kwargs):
 if created:
 UserProfile.objects.create(**user=instance)

 post_save.connect(create_user_**profile, sender=User)

 I have added *unique *field, but it does not make any difference. So 
 far I haven't got
 any convincing answer. 

 Any Idea ??
 On Tuesday, April 2, 2013 12:49:52 AM UTC+5:30, Shawn Milochik wrote:
>
> Don't even worry about factories. They're for when you want a bunch of 
> forms for the same model on the page at once. 
>
> Use the UserCreationForm in django.contrib.auth.forms. It only accepts 
> a username and password, so you can either subclass it to add the 
> fields or make your own form and add it to your view so that they both 
> appear in the same HTML form. You can validate both and do what you 
> need to do. 
>
> You definitely shouldn't be writing validation logic for the password 
> and username and such -- that's what ModelForms are for. 
>
> If you have more specific questions just ask. 
>
  -- 
>>> 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?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>>
>>
>>  -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/django-users/8PHPgI4i4sQ/unsubscribe?hl=en
>> .
>> To unsubscribe from this group and all its topics, 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?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>
>
> -- 
> Sachin 
>  

-- 
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?hl=en.
For more options, visit 

Re: Guide for migrating to a custom user model?

2013-04-17 Thread Mike Dewhirst

On 18/04/2013 12:33pm, Chris Streeter wrote:

I found this [1] blog post to be interesting. I can't vouch for it's
accuracy as I haven't migrated my own site yet, but it looks correct
from reading it.



I agree it is interesting. And useful - thank you Ponytech :)

However, it assumes a desire to transfer the deprecated user_profile 
data into a custom user model inheriting from abstract_user.


I'm looking for a guide which is even simpler and leaves the 
user_profile model in place as a 1:1 model and just uses 
django.contrib.auth.models.User (and Group) directly. Anything trickier 
than this involves significant rewriting of my Django 1.4 project.


If User.get_profile() is deprecated I suppose I'll have to find another 
way to fetch user_profile data in future.


I'll document what I actually do and offer that as a guide when I get 
around to it - unless someone else gets in first.


Mike


- Chris


[1]:
http://ponytech.net/blog/2013/03/31/migrate-your-user-profile-data-django-15-custom-user-model/


On Wed, Apr 17, 2013 at 5:34 PM, Mike Dewhirst > wrote:

On 18/04/2013 9:55am, Brian Neal wrote:

Hello -

I have a Django site that I've been maintaining for 4 years. It is
running Django 1.4 now and is using the usual Django User model
plus the
get_profile() method to retrieve some extra information for each
user.
Now that Django 1.5 has landed and we can substitute our own
custom user
model [1], I'm weighing my options for going forward. The
get_profile()
stuff is now deprecated and will go away in Django 1.7 [2]. I'm
trying
to decide if I should just keep my profile model around and do
the joins
[3], or substitute my own model.

I'm wondering if there is a guide somewhere on how to do a
migration to
a custom user model? In a few places people recommend South, but
I have
no experience with South. Is it time to learn, or is it
overkill? Or can
I just write my own script to fix things up? Then I have to go
through
all my apps and refactor the user.get_profile() calls, right?
And all
those FK's to Django's User model will have to be changed?


+1 Yes please. I'd be delighted to see such a thing. But there are
so many ways to make custom users!!

I tried a custom user and quickly decided it would be difficult for
me to keep a common code-base. My conclusion was to stay with 1.4
and (when I get time) to figure out the absolute minimum change
required to go to 1.5.

If I was specifying such a guide it would be "How to migrate an
existing 1.4 app to 1.5 and achieve AUTH_PROFILE_MODULE
functionality without a custom user and without using deprecated
mechanisms"



I was hoping there was a guide or some blog posts about how to
do this
but I haven't seen anything other than a few stackoverflow
questions.

Thanks,
-BN


[1]:

https://docs.djangoproject.__com/en/1.5/topics/auth/__customizing/#substituting-a-__custom-user-model


[2]:
https://docs.djangoproject.__com/en/1.5/internals/__deprecation/#id4

[3]:

https://docs.djangoproject.__com/en/1.5/topics/auth/__customizing/#extending-the-__existing-user-model




--
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+unsubscribe@__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?hl=en
.
For more options, visit
https://groups.google.com/__groups/opt_out
.



--
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+unsubscribe@__googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at

Re: Guide for migrating to a custom user model?

2013-04-17 Thread Chris Streeter
I found this [1] blog post to be interesting. I can't vouch for it's
accuracy as I haven't migrated my own site yet, but it looks correct from
reading it.

- Chris


[1]:
http://ponytech.net/blog/2013/03/31/migrate-your-user-profile-data-django-15-custom-user-model/


On Wed, Apr 17, 2013 at 5:34 PM, Mike Dewhirst wrote:

> On 18/04/2013 9:55am, Brian Neal wrote:
>
>> Hello -
>>
>> I have a Django site that I've been maintaining for 4 years. It is
>> running Django 1.4 now and is using the usual Django User model plus the
>> get_profile() method to retrieve some extra information for each user.
>> Now that Django 1.5 has landed and we can substitute our own custom user
>> model [1], I'm weighing my options for going forward. The get_profile()
>> stuff is now deprecated and will go away in Django 1.7 [2]. I'm trying
>> to decide if I should just keep my profile model around and do the joins
>> [3], or substitute my own model.
>>
>> I'm wondering if there is a guide somewhere on how to do a migration to
>> a custom user model? In a few places people recommend South, but I have
>> no experience with South. Is it time to learn, or is it overkill? Or can
>> I just write my own script to fix things up? Then I have to go through
>> all my apps and refactor the user.get_profile() calls, right? And all
>> those FK's to Django's User model will have to be changed?
>>
>
> +1 Yes please. I'd be delighted to see such a thing. But there are so many
> ways to make custom users!!
>
> I tried a custom user and quickly decided it would be difficult for me to
> keep a common code-base. My conclusion was to stay with 1.4 and (when I get
> time) to figure out the absolute minimum change required to go to 1.5.
>
> If I was specifying such a guide it would be "How to migrate an existing
> 1.4 app to 1.5 and achieve AUTH_PROFILE_MODULE functionality without a
> custom user and without using deprecated mechanisms"
>
>
>
>> I was hoping there was a guide or some blog posts about how to do this
>> but I haven't seen anything other than a few stackoverflow questions.
>>
>> Thanks,
>> -BN
>>
>>
>> [1]:
>> https://docs.djangoproject.**com/en/1.5/topics/auth/**
>> customizing/#substituting-a-**custom-user-model
>> [2]: 
>> https://docs.djangoproject.**com/en/1.5/internals/**deprecation/#id4
>> [3]:
>> https://docs.djangoproject.**com/en/1.5/topics/auth/**
>> customizing/#extending-the-**existing-user-model
>>
>>
>> --
>> 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+unsubscribe@**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?hl=en
>> .
>> For more options, visit 
>> https://groups.google.com/**groups/opt_out
>> .
>>
>>
>>
> --
> 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+unsubscribe@**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?hl=en
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out
> .
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: What is Model Manager?

2013-04-17 Thread cha
Thanks for the clarification


On Wednesday, 17 April 2013 20:24:57 UTC-4, Lachlan Musicman wrote:
>
> On 18 April 2013 10:10, cha  wrote: 
> > Hello how are you 
>
> Great, thanks for asking! 
>
> > I want to explain to me what is **"Model Managers"**  in django ??? and 
> What 
> > are the useful ? 
>
> They are a different way of collecting querysets of objects. Have you 
> read the documentation to this end? 
>
> https://docs.djangoproject.com/en/1.5/topics/db/managers/ 
> https://docs.djangoproject.com/en/dev/topics/db/managers/ 
>
>
> For instance, on my last project I had "students, subjects, courses, 
> grades" 
>
> I wanted to be able to call some aspects of those quickly without 
> writing out the whole filter every time. So I created some filters 
> like these: 
>
> Male students in Accounting under 25 years   as 
> Student.men_account_25.all() 
> Male students in Accounting over 25 years as 
> Student.men_account_26.all() 
> Female students in Accounting under 25 years as 
> Student.women_account_25.all() 
> Female students in Accounting over 25 years as 
> Student.women_account_25.all() 
>
> I could have gone very deep: 
>
> Male students in Accounting over 25 years that passed last semester 
> and are from province X. 
>
> I then added a .count() to the end of the call, and I had instant 
> enrollment statistics that were always up-to-date. 
>
> Does that clear it up for you? 
>
> cheers 
> L. 
>
>
>
> -- 
> The new creativity is pointing, not making. Likewise, in the future, 
> the best writers will be the best information managers. 
>
>
> http://www.theawl.com/2013/02/an-interview-with-avant-garde-poet-kenneth-goldsmith
>  
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: What is Model Manager?

2013-04-17 Thread cha

Thank you 


On Wednesday, 17 April 2013 20:26:31 UTC-4, Shawn Milochik wrote:
>
> https://docs.djangoproject.com/en/1.5/topics/db/managers/
>
> This should explain everything.
>
>
> On Wed, Apr 17, 2013 at 8:10 PM, cha wrote:
>
>> Hello how are you
>> I want to explain to me what is **"*Model Managers*"**  in django ??? 
>> and What are the useful ?
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Guide for migrating to a custom user model?

2013-04-17 Thread Mike Dewhirst

On 18/04/2013 9:55am, Brian Neal wrote:

Hello -

I have a Django site that I've been maintaining for 4 years. It is
running Django 1.4 now and is using the usual Django User model plus the
get_profile() method to retrieve some extra information for each user.
Now that Django 1.5 has landed and we can substitute our own custom user
model [1], I'm weighing my options for going forward. The get_profile()
stuff is now deprecated and will go away in Django 1.7 [2]. I'm trying
to decide if I should just keep my profile model around and do the joins
[3], or substitute my own model.

I'm wondering if there is a guide somewhere on how to do a migration to
a custom user model? In a few places people recommend South, but I have
no experience with South. Is it time to learn, or is it overkill? Or can
I just write my own script to fix things up? Then I have to go through
all my apps and refactor the user.get_profile() calls, right? And all
those FK's to Django's User model will have to be changed?


+1 Yes please. I'd be delighted to see such a thing. But there are so 
many ways to make custom users!!


I tried a custom user and quickly decided it would be difficult for me 
to keep a common code-base. My conclusion was to stay with 1.4 and (when 
I get time) to figure out the absolute minimum change required to go to 
1.5.


If I was specifying such a guide it would be "How to migrate an existing 
1.4 app to 1.5 and achieve AUTH_PROFILE_MODULE functionality without a 
custom user and without using deprecated mechanisms"




I was hoping there was a guide or some blog posts about how to do this
but I haven't seen anything other than a few stackoverflow questions.

Thanks,
-BN


[1]:
https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#substituting-a-custom-user-model
[2]: https://docs.djangoproject.com/en/1.5/internals/deprecation/#id4
[3]:
https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#extending-the-existing-user-model


--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: What is Model Manager?

2013-04-17 Thread Shawn Milochik
https://docs.djangoproject.com/en/1.5/topics/db/managers/

This should explain everything.


On Wed, Apr 17, 2013 at 8:10 PM, cha  wrote:

> Hello how are you
> I want to explain to me what is **"*Model Managers*"**  in django ??? and
> What are the useful ?
>
> --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: What is Model Manager?

2013-04-17 Thread Lachlan Musicman
On 18 April 2013 10:10, cha  wrote:
> Hello how are you

Great, thanks for asking!

> I want to explain to me what is **"Model Managers"**  in django ??? and What
> are the useful ?

They are a different way of collecting querysets of objects. Have you
read the documentation to this end?

https://docs.djangoproject.com/en/1.5/topics/db/managers/
https://docs.djangoproject.com/en/dev/topics/db/managers/


For instance, on my last project I had "students, subjects, courses, grades"

I wanted to be able to call some aspects of those quickly without
writing out the whole filter every time. So I created some filters
like these:

Male students in Accounting under 25 years   as Student.men_account_25.all()
Male students in Accounting over 25 years as Student.men_account_26.all()
Female students in Accounting under 25 years as Student.women_account_25.all()
Female students in Accounting over 25 years as Student.women_account_25.all()

I could have gone very deep:

Male students in Accounting over 25 years that passed last semester
and are from province X.

I then added a .count() to the end of the call, and I had instant
enrollment statistics that were always up-to-date.

Does that clear it up for you?

cheers
L.



--
The new creativity is pointing, not making. Likewise, in the future,
the best writers will be the best information managers.

http://www.theawl.com/2013/02/an-interview-with-avant-garde-poet-kenneth-goldsmith

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




What is Model Manager?

2013-04-17 Thread cha
Hello how are you
I want to explain to me what is **"*Model Managers*"**  in django ??? and 
What are the useful ?

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Guide for migrating to a custom user model?

2013-04-17 Thread Brian Neal
Hello -

I have a Django site that I've been maintaining for 4 years. It is running 
Django 1.4 now and is using the usual Django User model plus the 
get_profile() method to retrieve some extra information for each user. Now 
that Django 1.5 has landed and we can substitute our own custom user model 
[1], I'm weighing my options for going forward. The get_profile() stuff is 
now deprecated and will go away in Django 1.7 [2]. I'm trying to decide if 
I should just keep my profile model around and do the joins [3], or 
substitute my own model. 

I'm wondering if there is a guide somewhere on how to do a migration to a 
custom user model? In a few places people recommend South, but I have no 
experience with South. Is it time to learn, or is it overkill? Or can I 
just write my own script to fix things up? Then I have to go through all my 
apps and refactor the user.get_profile() calls, right? And all those FK's 
to Django's User model will have to be changed?

I was hoping there was a guide or some blog posts about how to do this but 
I haven't seen anything other than a few stackoverflow questions.

Thanks,
-BN


[1]: 
https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#substituting-a-custom-user-model
[2]: https://docs.djangoproject.com/en/1.5/internals/deprecation/#id4
[3]: 
https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#extending-the-existing-user-model


-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Help interpreting profiler results (or: why is my app so slow?)

2013-04-17 Thread Shawn Milochik
When you print those out with pstats, sort by cumtime.

cumtime = cumulative time

That will tell you almost exactly (and maybe really exactly) which code is
slow.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Help interpreting profiler results (or: why is my app so slow?)

2013-04-17 Thread Matt Andrews
Hi all.

Having performance problems with my Django app. I've posted here before 
talking about this: one theory for my slowness woes was that I'm using raw 
SQL for everything after getting sick of Django doing things weirdly 
(duplicating queries, adding bizarre things like "LIMIT 3453453" to 
queries, not being able to JOIN things like I wanted etc). I'm not opposed 
to going back to the ORM but need to know if this is where my bottleneck is.

I've run a profiler against my code and the results are here: 
http://pastebin.com/raw.php?i=HQf9bqGp

On my local machine (a not very powerful laptop) I see Django Debug Toolbar 
load times of ~1900ms for my site homepage. This includes 168ms of db calls 
(11 queries, which I think are fairly well-tuned, indexed, etc). I cache 
pretty well on production but load times are still slow -- some of this may 
be down to my cheap webhost, though. In my settings I 
enabled django.template.loaders.cached.Loader but this doesn't seem to make 
much difference.

I'm having trouble seeing what the profiler results above are telling me: 
can anyone shed any light?

If it helps at all, this is the homepage of my app: 
http://www.scenepointblank.com -- there's lot of HTML processing (stripping 
tags or truncating strings and parsing HTML etc). I use a couple of 
template tags quite frequently to re-use partial views (a news post, for 
example) so I can just pass it an object to work with. I don't know if this 
means a huge template overhead. I've explored replacing Django's templates 
with Jinja2 but fell at the first hurdle when none of the aforementioned 
template tags worked and I couldn't figure out how to port them to Jinja.

Any tips would be hugely appreciated.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django-newsletter, cron job not working

2013-04-17 Thread frocco
Thank you

On Wednesday, April 17, 2013 2:42:09 PM UTC-4, Shawn Milochik wrote:
>
> It's almost certainly an environment issue, such as an issue with your 
> PATH or PYTHONPATH.
>
> Just add to the command so that it puts all standard output and standard 
> error to a file to read what the message is.
>
> your_command &> /tmp/broken_cron.log
>
> Then rig your cron job to run ASAP and read the log.
>
>
> On Wed, Apr 17, 2013 at 2:38 PM, frocco wrote:
>
>> Hello,
>>
>> Can someone give me an example of running a cronjob hourly?
>> I am on webfaction and cannot get this working.
>>
>> I tried
>>
>> @hourly /usr/local/bin/python2.7 ~/webapps/ntw/myproject/manage.py runjob 
>> submit
>>
>> I get no email
>>
>> If I SSH in and sunit manually, it works fine
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django-newsletter, cron job not working

2013-04-17 Thread Sam Walters
Hi
In addition to the previous advice i would also check /etc/init.d/cron to
see if the daemon is running.

make sure you have the correct date+time settings in your shell eg: 'date'
command.

also run some sort of primitive debug command like:
* * * * * touch "/tmp/$(date +\%d-\%m-\%Y-\%T)"
for a couple of minutes to see if it executes.

my money is on a path issue though ;)





On Wed, Apr 17, 2013 at 6:42 PM, Shawn Milochik  wrote:

> It's almost certainly an environment issue, such as an issue with your
> PATH or PYTHONPATH.
>
> Just add to the command so that it puts all standard output and standard
> error to a file to read what the message is.
>
> your_command &> /tmp/broken_cron.log
>
> Then rig your cron job to run ASAP and read the log.
>
>
> On Wed, Apr 17, 2013 at 2:38 PM, frocco  wrote:
>
>> Hello,
>>
>> Can someone give me an example of running a cronjob hourly?
>> I am on webfaction and cannot get this working.
>>
>> I tried
>>
>> @hourly /usr/local/bin/python2.7 ~/webapps/ntw/myproject/manage.py runjob
>> submit
>>
>> I get no email
>>
>> If I SSH in and sunit manually, it works fine
>>
>> --
>> 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?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django-newsletter, cron job not working

2013-04-17 Thread Shawn Milochik
It's almost certainly an environment issue, such as an issue with your PATH
or PYTHONPATH.

Just add to the command so that it puts all standard output and standard
error to a file to read what the message is.

your_command &> /tmp/broken_cron.log

Then rig your cron job to run ASAP and read the log.


On Wed, Apr 17, 2013 at 2:38 PM, frocco  wrote:

> Hello,
>
> Can someone give me an example of running a cronjob hourly?
> I am on webfaction and cannot get this working.
>
> I tried
>
> @hourly /usr/local/bin/python2.7 ~/webapps/ntw/myproject/manage.py runjob
> submit
>
> I get no email
>
> If I SSH in and sunit manually, it works fine
>
> --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




django-newsletter, cron job not working

2013-04-17 Thread frocco
Hello,

Can someone give me an example of running a cronjob hourly?
I am on webfaction and cannot get this working.

I tried

@hourly /usr/local/bin/python2.7 ~/webapps/ntw/myproject/manage.py runjob 
submit

I get no email

If I SSH in and sunit manually, it works fine

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Can I get away with creating login/logout.html ?

2013-04-17 Thread Vibhu Rishi
I tried this but when I click submit, the page goes to
http://127.0.0.1:8000/account/login/ . i suppose once the login part
finishes it is supposed to go to the LOGIN_REDIRECT_URL setting.

Vibhu


On Wed, Apr 17, 2013 at 9:38 PM, Gabriel [SGT]  wrote:

> > still trying to figure out the login part.
> >
>
>
> https://docs.djangoproject.com/en/dev/topics/auth/default/#module-django.contrib.auth.views
>
> See settings.LOGIN_REDIRECT_URL
>
> Regards.
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Can I get away with creating login/logout.html ?

2013-04-17 Thread Gabriel [SGT]
> still trying to figure out the login part.
>

https://docs.djangoproject.com/en/dev/topics/auth/default/#module-django.contrib.auth.views

See settings.LOGIN_REDIRECT_URL

Regards.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Can I get away with creating login/logout.html ?

2013-04-17 Thread Vibhu Rishi
update:

logout seems to be working if i change the logout url pattern to :
(r'^logout/$', 'logout', {'template_name':'homepage/index.html',
'next_page':'/'}),

still trying to figure out the login part.

Vibhu



On Wed, Apr 17, 2013 at 8:05 PM, Vibhu Rishi  wrote:

> Hi,
>
> I am trying to figure out if i can get away with creating the login.html
> and logout.html files ?
>
> The scenario is this:
> - I have a navigation bar which has the username/password field in it . I
> am using the example at :
> http://twitter.github.io/bootstrap/examples/hero.html
> - I want the user to login at this box and be redirected back to the
> current page.
>
> as per the documentation I created an app for account and in its url.py I
> have added
> from django.conf.urls import patterns,url
>
> from account import views
>
> urlpatterns = patterns('django.contrib.auth.views',
> (r'^login/$', 'login',
> {'template_name':'account/login.html'},'login'),
> (r'^logout/$', 'logout',
> {'template_name':'account/logout.html'},'logout'),
> )
>
> in my index.html file i did the following modifications :
>
> {% if user.is_authenticated %}
> 
>  Hello {{ user.username }} ! 
>  ( logout 
> 
> {% else %}
> {% csrf_token %}
>   
>   
>   Sign in
> 
> {% endif %}
>
> I checked with admin user (which was already logged in via /admin url )
> and the above reflects the username if admin is logged in otherwise it
> shows the login form boxes.
>
> Now, what i am trying to do is get a new user i created ( vibhu ) to
> login, but the app is expecting to find a URL for account/login . I get the
> following :
> TemplateDoesNotExist at /account/login/
>
> Is there a way to remove this requirement ? I dont want to really create
> an account/login.html or account/logout.html if possible as I think those
> are unnecessary here. I want the login/logout to be handled by the code in
> the navbar itself.
>
> Vibhu
>
> --
> Simplicity is the ultimate sophistication. - Leonardo da Vinci
> Life is really simple, but we insist on making it complicated. - Confucius
>



-- 
Simplicity is the ultimate sophistication. - Leonardo da Vinci
Life is really simple, but we insist on making it complicated. - Confucius

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Possible Basic kwargs question.

2013-04-17 Thread Rainy
When the definition is method(self, **kwargs), you ARE asking
variable named kwargs. If you want to accept one dict object,
it should be: method(self, mydict). If you want to accept variable
list of args, it should be method(self, *mylist)

-ak


On Wednesday, April 17, 2013 12:59:21 AM UTC-4, jayhalleaux wrote:
>
> but if I did that then i would have a variable named kwargs.
>
> and it would be print kwargs['param1'], etc
>
> Why even unpack the dictionary?  I could just pass the dictionary instead.
>
>
> On Tuesday, April 16, 2013 11:08:42 PM UTC-4, Brad Pitcher wrote:
>>
>> It should be:
>> model.method1(**params)
>> On Apr 16, 2013 7:49 PM, "jayhalleaux"  wrote:
>>
>>> Not really a Django question but I'm trying to create a model method 
>>> that does not have a fixed set of parameters.
>>>
>>> models.py
>>> Class Model_A(model.Model):
>>> ...
>>>
>>> def method1(self, **kwargs):
>>>
>>> print param1, param2, param3
>>>
>>>
>>>
>>> views.py
>>> params = dict(
>>>
>>> param1=something1,
>>> param2=something2,
>>> param3=something3,
>>> ...
>>>
>>> )
>>>
>>> model.method1(params)
>>>
>>> In this example when I try to do something like this it states that I 
>>> should have passed only 1 parameter instead of 2.
>>>
>>> I thought the whole point of using '**' to unpack dictionaries is so you 
>>> don't have to have a fixed number of parameters.
>>>
>>> Is there something I am missing or am I doing this incorrect? First time 
>>> I'm trying to create a method like this.  Normally I explicitly state all 
>>> parameters.
>>>
>>> Any help is appreciated.
>>>
>>> -- 
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>>
>>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django-social-auth problem with facebook

2013-04-17 Thread Rainy
When you get this error, you need to look at your database error log, e.g. 
for postgres 8.4 on linux:

tail -n100 /var/log/postgresql-8.4-main.log

It should tell you the exact sql command that caused the first error (you 
might need to scroll up).



On Monday, April 15, 2013 2:01:21 AM UTC-4, Jeff Hsu wrote:
>
> Hi, I just pip installed django-social-auth from omab today on 
> github(beginner here).  I think I can almost get it to work with facebook 
> login, but I always have this "InternalError: Exception Value: current 
> transaction is aborted, commands ignored until end of transaction block", 
> after I log in with my facebook account and before I redirect to the 
> profile page.  The request url shows 
>
> http://127.0.0.1:8000/complete/facebook/?redirect_state=xxx=xxx=xxx.
>  
>  I'm using Django 1.5.  Can anybody give me some directions to debug this?
>
> Thank you tons,
> Jeff
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Can I get away with creating login/logout.html ?

2013-04-17 Thread Vibhu Rishi
Hi,

I am trying to figure out if i can get away with creating the login.html
and logout.html files ?

The scenario is this:
- I have a navigation bar which has the username/password field in it . I
am using the example at :
http://twitter.github.io/bootstrap/examples/hero.html
- I want the user to login at this box and be redirected back to the
current page.

as per the documentation I created an app for account and in its url.py I
have added
from django.conf.urls import patterns,url

from account import views

urlpatterns = patterns('django.contrib.auth.views',
(r'^login/$', 'login',
{'template_name':'account/login.html'},'login'),
(r'^logout/$', 'logout',
{'template_name':'account/logout.html'},'logout'),
)

in my index.html file i did the following modifications :

{% if user.is_authenticated %}

 Hello {{ user.username }} ! 
 ( logout 

{% else %}
{% csrf_token %}
  
  
  Sign in

{% endif %}

I checked with admin user (which was already logged in via /admin url ) and
the above reflects the username if admin is logged in otherwise it shows
the login form boxes.

Now, what i am trying to do is get a new user i created ( vibhu ) to login,
but the app is expecting to find a URL for account/login . I get the
following :
TemplateDoesNotExist at /account/login/

Is there a way to remove this requirement ? I dont want to really create an
account/login.html or account/logout.html if possible as I think those are
unnecessary here. I want the login/logout to be handled by the code in the
navbar itself.

Vibhu

-- 
Simplicity is the ultimate sophistication. - Leonardo da Vinci
Life is really simple, but we insist on making it complicated. - Confucius

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django-Registration/Custom Authentication Issue

2013-04-17 Thread Scott Anderson
That's good to know. How stable is it?

-scott

Via mobile phone

On Apr 17, 2013, at 3:52 AM, James Bennett  wrote:

Current hg tip is actually 1.5-compatible, in the sense that if you want to
use your own User model, you just subclass the provided stuff and plug in
your model, either importing directly or using the helper function in
Django 1.5.

django-registration does not do this itself because

1. Using Django 1.5's helpers requires either extra complication of the
imports, or a break with Django 1.4 compatibility, and
2. If you're using a custom User model, you will by definition be wanting
to subclass and override the default fields, validation logic, etc., since
only a User model identical to django.contrib.auth.models.User works with
the defaults.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how to fatch data from mysql database using jQuery in my django project?

2013-04-17 Thread Gerald Klein
You have to call an action from jQuery and use the results passed back, you
can return it in json text etc, this will be returned to the jQuery ajax
get call.

$.get(url,function(data) {
 //use data here to inject html
});


On Wed, Apr 17, 2013 at 8:57 AM, Avnesh Shakya wrote:

> hi,
> please tell me someone, I want to fetch data dynamically using jquery
> from database.. how it is possible, give me a example... please help me, i
> need it in my project.
>Thanks
>
> --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 

Gerald Klein DBA

contac...@geraldklein.com

www.geraldklein.com 

geraldklein.wordpress.com

j...@zognet.com

708-599-0352


Arch Awesome, Ranger & Vim the coding triple threat.

Linux registered user #548580

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




how to fatch data from mysql database using jQuery in my django project?

2013-04-17 Thread Avnesh Shakya
hi,
please tell me someone, I want to fetch data dynamically using jquery 
from database.. how it is possible, give me a example... please help me, i 
need it in my project.
   Thanks

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: models.ManyToManyField

2013-04-17 Thread Gabriel
 Hey,
I didn't quite understand what you're trying to do, so I'm covering both
interpretations.

1- If you're trying to, for instance, get all the films an actor was in you
can, as explained here
https://docs.djangoproject.com/en/1.5/topics/db/queries/#many-to-many-relationships(the
link is for Django 1.5, but don't worry if you're using an older
version), use something like:

attore = Attore.objects.get(pk=1)  # Get an actor from the database
attore.film_set.all()  # Get the list of all the films the actor been in

2- If you're trying to filter Films based on actor information, you can do
something like this:

Film.objects.filter(attori__cognome='Travolta')  # Get all films that have
at least one actor with the last name Travolta


Now for something completely different, I don't know what are your
requisites, but do you really need classes (and then database tables) for
stuff like movie duration and release year? Seems like overkill and can end
up hurting performance.
Usually (not always) if you have a class with just one attribute, you don't
actually need a class.

I hope one of these was what you're looking for.

- Gabe

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django auth user - difference between last login and now

2013-04-17 Thread Bill Freeman
One way is to replace/wrap/monkey-patch the login view to save a copy of
the last login element for the looked up user in a local variable, and
then, if login is successful, and the last login was long enough ago,
modify the successful login redirect to your "instructions" page.


On Tue, Apr 16, 2013 at 1:06 PM, Jaimin Patel  wrote:

> Any suggestion on this question?
>
> On Friday, April 12, 2013 10:35:54 AM UTC-4, Jaimin Patel wrote:
>>
>> Hello,
>>
>> I would like to provide some instructions if user come after gap of 1
>> week or so. I was hoping that I can do that by -
>>
>> (datetime.now()-user.last_**login) > timedelta(days=7)
>>
>> Though by the time it comes to my view last login is already updated by
>> auth user model of django, so in my application code when I try to find
>> this difference it always comes 0 day because last_login time is already
>> updated with now datetime.
>>
>> Is there any other way to get this information?
>>
>>
>>  --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




models.ManyToManyField

2013-04-17 Thread Federico Erbea
Hello everyone, I am a neophyte and maybe it's a stupid question so thank 
you in advance aid.
My question is: can I go back and retrieve all the movies assigned to a 
specific actor, director, or other through the class film? Or do I have to 
create a specific class for each item to which I want to connect the Film? 
(as I have done precisely with the Film, the fact is that I looked very 
hard-working and maybe there's a better solution)
Here's the models.py:

from django.db import models

class Umore( models.Model ):
umore = models.CharField( max_length=25 )
def __unicode__(self):
return self.umore
class Meta:
verbose_name_plural = "Umori"

class Genere_Film( models.Model ):
genere = models.CharField( max_length=25 )
def __unicode__(self):
return self.genere
class Meta:
verbose_name_plural = "Generi_Film"

class Anno( models.Model ):
anno = models.CharField( max_length=4 )
def __unicode__(self):
return self.anno
class Meta:
verbose_name_plural = "Anno"

class Durata( models.Model ):
durata = models.CharField( max_length=5 )
def __unicode__(self):
return  self.durata
class Meta:
verbose_name_plural = "Durata"

class Attore( models.Model ):
nome = models.CharField( max_length=30 )
cognome = models.CharField( max_length=30 )
foto = models.CharField( max_length=100 )
data_inserimento = models.DateField( null=True, verbose_name="data 
d'inserimento" )
def __unicode__(self):
return self.nome + " " + self.cognome + " " + self.foto
class Meta:
verbose_name_plural = "Attori"

class Regista( models.Model ):
nome = models.CharField( max_length=30 )
cognome = models.CharField( max_length=30 )
foto = models.CharField( max_length=100 )
data_inserimento = models.DateField( null=True, verbose_name="data 
d'inserimento" )
def __unicode__(self):
return self.nome + " " + self.cognome + " " + self.foto
class Meta:
verbose_name_plural = "Registi"

class Studio( models.Model ):
nome = models.CharField( max_length=30 )
foto = models.CharField( max_length=100 )
data_inserimento = models.DateField( null=True, verbose_name="data 
d'inserimento" )
def __unicode__(self):
return self.nome #+ " " + self.foto
class Meta:
verbose_name_plural = "Studi"

class Trailer( models.Model ):
   trailer = models.CharField( max_length=100 )
   data_inserimento = models.DateField( null=True, verbose_name="data 
d'inserimento" )
   def __unicode__(self):
return self.trailer
class Meta:
verbose_name_plural = "Trailers"

class Film( models.Model ):
titolo = models.CharField( max_length=39 )
trama = models.CharField( max_length=1000 )
locandina = models.CharField( max_length=100 )
copertina = models.CharField( max_length=100 )
trailer = models.ForeignKey( Trailer )
data_inserimento = models.DateField( null=True, verbose_name="data 
d'inserimento" )
anno = models.ForeignKey( Anno )
durata = models.ForeignKey( Durata )
attori = models.ManyToManyField( Attore )
registi = models.ManyToManyField( Regista )
studi = models.ManyToManyField( Studio )
umori = models.ManyToManyField( Umore )
generi = models.ManyToManyField( Genere_Film )
def __unicode__(self):
return self.titolo + " " + self.trama + " " + self.locandina + " " 
+ self.copertina
class Meta:
verbose_name_plural = "Film"

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Using postgres Users as django users

2013-04-17 Thread Alex Mandel
It's possible but you may need to split out django and non-django into a 
front and back end. This sounds similar to phpmyadmin or phppgadmin


I think the key to this is that django only be used to store the user 
and connection information for each database (And provide a web 
interface). When a user goes to execute SQL, it should be sent via 
psycopg to pg and the data returned and parsed into an object you can 
then pass into a django page.


So basically you can use the django ORM for the arbitrary sql you want 
to execute on an given database since that needs to occur with a 
specific user/connection information.


This is similar to how pgAdmin works, the big difference here is that 
you're abstracting so that people work over port 80 instead of having 
them direct connect to the db.


Enjoy,
Alex

On 04/17/2013 12:16 AM, Maximilian Tyrtania wrote:



Am Dienstag, 16. April 2013 17:52:11 UTC+2 schrieb אברהם סרור:


So you are saying that each user models will be using the same database
but with different connection settings?



Yes, exactly. Each user has his own username. That's what the SQL command
"create user xy" is for exactly. I don't think my approach is overly
exotic, if I may say so. It enables the db admin to use the finely grained
permissions model of the database and grant or revoke permissions
individually. I realize django can do the same thing, but I don't want to
"copy" my database permissions setup over to django and make sure it's in
sync.



I believe you can create each and every connection setting on your
databases inside settings.py, each one would use the same database but a
different user.
When creating an object specify it to use the corresponding database



Yeah, I realize that this is possible, but this approach, as far as I can
see, comes down to being quite a maintenance burden as I need to have each
and every user (and I got many, >500) be represented in my settings file.
So, am I out of luck?
Thanks,

Max




On Tue, Apr 16, 2013 at 5:27 PM, Maximilian Tyrtania <
maximilia...@googlemail.com > wrote:


I looked at that a bit, thanks, the problem is that I can well use my pg
server to do the authentication, but I still can't talk django into using
the database connection for this particurlar user (hopefully I'm just not
aware of the solution).
You see, lots of my models in models.py are based on database views in
postgres, which in turn make use of the current_user() function. This is
why I need django to use the correct connection settings.

Am Dienstag, 16. April 2013 14:51:18 UTC+2 schrieb אברהם סרור:


I believe you could create a custom auth that relies on the postgres
auth system


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










--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django-Registration/Custom Authentication Issue

2013-04-17 Thread James Bennett
Current hg tip is actually 1.5-compatible, in the sense that if you want to
use your own User model, you just subclass the provided stuff and plug in
your model, either importing directly or using the helper function in
Django 1.5.

django-registration does not do this itself because

1. Using Django 1.5's helpers requires either extra complication of the
imports, or a break with Django 1.4 compatibility, and
2. If you're using a custom User model, you will by definition be wanting
to subclass and override the default fields, validation logic, etc., since
only a User model identical to django.contrib.auth.models.User works with
the defaults.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: djano user registration form and login(full example)

2013-04-17 Thread isachin
Thanx,

Btw, I solved it by creating an instance of get_profile() and then saving
user and profile separately.

here is the code snippet of *forms.py*

if commit:
profile = user.get_profile()
profile.serial_num = self.cleaned_data['serial_num']
profile.save()
user.save()
 return user, profile





On Wed, Apr 17, 2013 at 11:09 AM, Avnesh Shakya wrote:

> This error is occur when you're saving the member, not the user. When
> creating the member, you are not assigning the user.
>
>
> On Wed, Apr 17, 2013 at 10:45 AM, sachin  wrote:
>
>> I m still stuck with
>>
>> Exception Type: IntegrityError
>> Exception Value: column user_id is not unique
>>
>> Whenever I try to save, it throws the above error.
>>
>> I have attached files for reference, can someone help ??
>>
>>
>>
>> On Saturday, April 6, 2013 7:07:32 PM UTC+5:30, sachin wrote:
>>>
>>> Thanx Shawn,
>>> *
>>> *
>>> UserCreationForm really helped.
>>>
>>> Now I have a different problem, I'm trying to add custom feilds to *auth
>>> user *using 
>>> storing-additional-**information-about-users
>>> .
>>> But now I m getting this error.
>>>
>>> Exception Type:IntegrityError Exception Value:
>>>
>>> column user_id is not unique
>>>
>>>
>>>
>>> This is my *models.py *file:
>>> *
>>> *
>>> from django.db import models
>>> from django.contrib.auth.models import User
>>> from django.db.models.signals import post_save
>>>
>>> class UserProfile(models.Model):
>>> user = models.OneToOneField(User)
>>> sr_no = models.CharField(max_length=**10)
>>>
>>> def __unicode__(self):
>>> return self.sr_no
>>>
>>> def create_user_profile(sender, instance, created, **kwargs):
>>> if created:
>>> UserProfile.objects.create(**user=instance)
>>>
>>> post_save.connect(create_user_**profile, sender=User)
>>>
>>> I have added *unique *field, but it does not make any difference. So
>>> far I haven't got
>>> any convincing answer.
>>>
>>> Any Idea ??
>>> On Tuesday, April 2, 2013 12:49:52 AM UTC+5:30, Shawn Milochik wrote:

 Don't even worry about factories. They're for when you want a bunch of
 forms for the same model on the page at once.

 Use the UserCreationForm in django.contrib.auth.forms. It only accepts
 a username and password, so you can either subclass it to add the
 fields or make your own form and add it to your view so that they both
 appear in the same HTML form. You can validate both and do what you
 need to do.

 You definitely shouldn't be writing validation logic for the password
 and username and such -- that's what ModelForms are for.

 If you have more specific questions just ask.

>>>  --
>> 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?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/8PHPgI4i4sQ/unsubscribe?hl=en
> .
> To unsubscribe from this group and all its topics, 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Sachin

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Using postgres Users as django users

2013-04-17 Thread Maximilian Tyrtania


Am Dienstag, 16. April 2013 17:52:11 UTC+2 schrieb אברהם סרור:
>
> So you are saying that each user models will be using the same database 
> but with different connection settings?
>

Yes, exactly. Each user has his own username. That's what the SQL command 
"create user xy" is for exactly. I don't think my approach is overly 
exotic, if I may say so. It enables the db admin to use the finely grained 
permissions model of the database and grant or revoke permissions 
individually. I realize django can do the same thing, but I don't want to 
"copy" my database permissions setup over to django and make sure it's in 
sync.
 

> I believe you can create each and every connection setting on your 
> databases inside settings.py, each one would use the same database but a 
> different user.
> When creating an object specify it to use the corresponding database
>

Yeah, I realize that this is possible, but this approach, as far as I can 
see, comes down to being quite a maintenance burden as I need to have each 
and every user (and I got many, >500) be represented in my settings file. 
So, am I out of luck?
Thanks,

Max
 

>
> On Tue, Apr 16, 2013 at 5:27 PM, Maximilian Tyrtania <
> maximilia...@googlemail.com > wrote:
>
>> I looked at that a bit, thanks, the problem is that I can well use my pg 
>> server to do the authentication, but I still can't talk django into using 
>> the database connection for this particurlar user (hopefully I'm just not 
>> aware of the solution).  
>> You see, lots of my models in models.py are based on database views in 
>> postgres, which in turn make use of the current_user() function. This is 
>> why I need django to use the correct connection settings.
>>
>> Am Dienstag, 16. April 2013 14:51:18 UTC+2 schrieb אברהם סרור:
>>
>>> I believe you could create a custom auth that relies on the postgres 
>>> auth system
>>>
>>  -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Possible Basic kwargs question.

2013-04-17 Thread Mario Gudelj
I think this might be a useful article for you
http://agiliq.com/blog/2012/06/understanding-args-and-kwargs/


On 17 April 2013 15:45, Brad Pitcher  wrote:

> I see what you're saying. Maybe you're looking for something more like
> this?
>
> def method1(self, param1=sensible_default, param2=sensible_default,
> param3=sensible_default):
> print param1, param2, param3
>
> The variable names must be specified in the method arguments like above if
> you wish to reference them by name inside the method itself. With this
> method, you will also need to call it with: model.method1(**params)
>
>
> On Tue, Apr 16, 2013 at 9:59 PM, jayhalleaux wrote:
>
>> but if I did that then i would have a variable named kwargs.
>>
>> and it would be print kwargs['param1'], etc
>>
>> Why even unpack the dictionary?  I could just pass the dictionary instead.
>>
>>
>> On Tuesday, April 16, 2013 11:08:42 PM UTC-4, Brad Pitcher wrote:
>>
>>> It should be:
>>> model.method1(**params)
>>> On Apr 16, 2013 7:49 PM, "jayhalleaux"  wrote:
>>>
  Not really a Django question but I'm trying to create a model method
 that does not have a fixed set of parameters.

 models.py
 Class Model_A(model.Model):
 ...

 def method1(self, **kwargs):

 print param1, param2, param3



 views.py
 params = dict(

 param1=something1,
 param2=something2,
  param3=something3,
 ...

 )

 model.method1(params)

 In this example when I try to do something like this it states that I
 should have passed only 1 parameter instead of 2.

 I thought the whole point of using '**' to unpack dictionaries is so
 you don't have to have a fixed number of parameters.

 Is there something I am missing or am I doing this incorrect? First
 time I'm trying to create a method like this.  Normally I explicitly state
 all parameters.

 Any help is appreciated.

 --
 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...@**googlegroups.com.
 To post to this group, send email to django...@googlegroups.com.

 Visit this group at 
 http://groups.google.com/**group/django-users?hl=en
 .
 For more options, visit 
 https://groups.google.com/**groups/opt_out
 .



>>>  --
>> 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?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.