How to build a app with a custom User model that supports email activation?

2014-01-04 Thread 项楠
I use django 1.6.1 and python 3.3.3 in windows8. I want to build a app 
named 'customauth' that supports email activation. I choose to create my 
own user model from the django.contrib.auth.models.AbstractBaseUser , not a 
profile model that holds a OneToOneField to django build-in User model.

This model class is called 'MyUser'.
Its features:

1. Only three fields : email, username and password are required when 
creating an MyUser instance.

2. User logins my site via email and password.

3. When creating a user (not superuser), field 'is_active' is False, 
'activation_key' is set to a random key with username, then, djanog sends 
an email with a activation_key link to him. If user clicks it in some days 
(like 3), his 'is_active' turns True,  'activation_key' turns a 
constantsettings.ALREADY_ACTIVATED which is defined in settings.py, so he 
can login.

4.When creating a superuser, its 'is_active' is True, 'activation_key' is 
settings.ALREADY_ACTIVATED directly and not invoking the process of sending 
activation email.

Up to now, what I have done looks like a weird combination of a custom User 
model from Substituting a custom User model 
and
 
the theory from 
django-registration
.
Note, I donot want to create .

Now my situation is weird:

1.Only when 'python manage.py syncdb' in cmd.exe, creating the superuser, 
the whole process can work fine (i.e.,send a mail, then click it to 
activate). However, this superuser can not login admin site despite its 
'is_admin' is True. It can only login user site.


2.When you register a user in the normal way (you enter some required 
infomation in the form), the user can be created, but django will not send 
a email to this user.

Now I donot know the reason, but as the email activation system works fine 
when first creating the superuser, there must be a way to make it works in 
user register.

So, what should I do, Thanks.

This is the project file 
myauth.zip, 
if needed.'customauth' is the app.


-- 
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/0c505578-77af-46d7-95ab-ecd15a23fc0e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


How to send a activation email when creating accounts in site?

2014-01-04 Thread 项楠
I use django 1.6.1 and python 3.3.3 in windows8. I want to build a app 
named 'customauth' that supports email activation. I choose to create my 
own user model from the django.contrib.auth.models.AbstractBaseUser , not a 
profile model that holds a OneToOneField to django build-in User model.

This model class is called 'MyUser'.Its features:

1. Only three fields : email, username and password are required when 
creating an MyUser instance.

2. User logins my site via email and password.

3. When creating a user (not superuser), field 'is_active' is False, 
'activation_key' is set to a random key with username, then, djanog sends 
an email with a activation_key link to him. If user clicks it in some days 
(like 3), his 'is_active' turns True,  'activation_key' turns to be a 
constant , so he can login.

4.When creating a superuser, its 'is_active' is True, 'activation_key' is a 
constant directly and not invoking the process of sending activation email.

Up to now, what I have done looks like a weird combination of a custom User 
model from Substituting a custom User model 
and
 
the theory from 
django-registration
.

Now my situation is weird:

1.Only when 'python manage.py syncdb' in cmd.exe, creating the superuser, 
the whole process can work fine (i.e.,send a mail, then click it to 
activate). However, this superuser can not login admin site despite its 
'is_admin' is True. It can only login user site.
https://www.dropbox.com/s/1l8f78fgfj4696a/super.jpg

2.When you register a user in the normal way (you enter some required 
infomation in the form), the user can be created, but django will not send 
a email to this user.

Now I donot know the reason, but as the email activation system works fine 
when first creating the superuser, there must be a way to make it works in 
user register.

So, what should I do, Thanks.

This is the project file 
myauth.zip,
 
if needed.'customauth' is the app.

-- 
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/ed7f7396-ac88-476a-a745-c74a7e612dcd%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: ForeignKey pointing to "nothing"

2014-01-04 Thread Russell Keith-Magee
On Sat, Jan 4, 2014 at 9:57 AM, Phil Hughes  wrote:

> I have a model where a foreign key reference may be undefined when a
> record is first created. In particular, I have the following in my model
>  seller = models.ForeignKey(User, related_name='+', blank=True,
>  null=True)
>
> The form accepts not setting the seller field but I get an Integrity
> Error exception when I attempt to save it that says
> escrow_escrow.seller_id may not be NULL
>
> I am using SQLite. What did I miss?
>
>  Was the null=True restriction in place when you created the table? If
you ran syncdb and *then* added the null=True definition, the null=True
definition won't be picked up by the  database - you'll need to do a table
migration. However, it *will* be picked up by forms, as they read the model
definition as-is.

Migrating tables is a bit painful on SQLite; it will probably be easier to
just drop the table and recreate it. If you need to preserve data in the
table, you can use the dumpdata/loaddata management commands.

Yours,
Russ Magee %-)

-- 
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/CAJxq84_fp76gVDgxJoq_KTj8%3DUkZu0-ngex-Pvm36KiOu3A5gw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: ForeignKey pointing to "nothing"

2014-01-04 Thread Phil Hughes
That was it -- thanks. I usually create a MySQL database to use in 
development but decided to just use sqlite. So much for my "shortcut".

On Saturday, January 4, 2014 4:26:59 AM UTC-6, Russell Keith-Magee wrote:
>
>
> On Sat, Jan 4, 2014 at 9:57 AM, Phil Hughes 
> > wrote:
>
>> I have a model where a foreign key reference may be undefined when a
>> record is first created. In particular, I have the following in my model
>>  seller = models.ForeignKey(User, related_name='+', blank=True,
>>  null=True)
>>
>> The form accepts not setting the seller field but I get an Integrity
>> Error exception when I attempt to save it that says
>> escrow_escrow.seller_id may not be NULL
>>
>> I am using SQLite. What did I miss?
>>
>>  Was the null=True restriction in place when you created the table? If 
> you ran syncdb and *then* added the null=True definition, the null=True 
> definition won't be picked up by the  database - you'll need to do a table 
> migration. However, it *will* be picked up by forms, as they read the model 
> definition as-is.
>
> Migrating tables is a bit painful on SQLite; it will probably be easier to 
> just drop the table and recreate it. If you need to preserve data in the 
> table, you can use the dumpdata/loaddata management commands.
>
> Yours,
> Russ Magee %-)
>
>

-- 
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/41c25ceb-0266-4b32-986a-552fa0f95ee3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to send a activation email when creating accounts in site?

2014-01-04 Thread Sergiy Khohlov
looks like signal is not sent. i will check this on Monday
Many thanks,

Serge


+380 636150445
skype: skhohlov


On Sat, Jan 4, 2014 at 10:47 AM, 项楠  wrote:
> I use django 1.6.1 and python 3.3.3 in windows8. I want to build a app named
> 'customauth' that supports email activation. I choose to create my own user
> model from the django.contrib.auth.models.AbstractBaseUser , not a profile
> model that holds a OneToOneField to django build-in User model.
>
> This model class is called 'MyUser'.Its features:
>
> 1. Only three fields : email, username and password are required when
> creating an MyUser instance.
>
> 2. User logins my site via email and password.
>
> 3. When creating a user (not superuser), field 'is_active' is False,
> 'activation_key' is set to a random key with username, then, djanog sends an
> email with a activation_key link to him. If user clicks it in some days
> (like 3), his 'is_active' turns True,  'activation_key' turns to be a
> constant , so he can login.
>
> 4.When creating a superuser, its 'is_active' is True, 'activation_key' is a
> constant directly and not invoking the process of sending activation email.
>
> Up to now, what I have done looks like a weird combination of a custom User
> model from Substituting a custom User model and the theory from
> django-registration.
>
> Now my situation is weird:
>
> 1.Only when 'python manage.py syncdb' in cmd.exe, creating the superuser,
> the whole process can work fine (i.e.,send a mail, then click it to
> activate). However, this superuser can not login admin site despite its
> 'is_admin' is True. It can only login user site.
> https://www.dropbox.com/s/1l8f78fgfj4696a/super.jpg
>
> 2.When you register a user in the normal way (you enter some required
> infomation in the form), the user can be created, but django will not send a
> email to this user.
>
> Now I donot know the reason, but as the email activation system works fine
> when first creating the superuser, there must be a way to make it works in
> user register.
>
> So, what should I do, Thanks.
>
> This is the project file myauth.zip, if needed.'customauth' is the app.
>
> --
> 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/ed7f7396-ac88-476a-a745-c74a7e612dcd%40googlegroups.com.
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADTRxJPyW%2BmOQSNd6MVn5zhW4Vu9QMHxbuXezv%3DOsoczvf-TwA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to send a activation email when creating accounts in site?

2014-01-04 Thread 项楠
After a day's trying, I finally solved the both problem, at least seems 
like.

Now, I can create a superuser normally without invoking the activation 
process, 
and my system will send an activation email when a user submits valid data.

I am not sure my custom system is OK, because you mentioned 'signal' ,
and the author of  
django-registration
 also 
shows some 'signal' related magic in his source code.

I cannot understand anything about 'signal'. In my system there is no 
'signal' concept .

I am afraid nothing related to 'signal' will cause a potential problem, 
so would you please take a look at my file or give a rough answer, thanks!

This is the updated project file.
myauth2.zip 

在 2014年1月4日星期六UTC+8下午10时26分24秒,Sergiy Khohlov写道:
>
> looks like signal is not sent. i will check this on Monday 
> Many thanks, 
>
> Serge 
>
>
> +380 636150445 
> skype: skhohlov 
>
>
> On Sat, Jan 4, 2014 at 10:47 AM, 项楠 > 
> wrote: 
> > I use django 1.6.1 and python 3.3.3 in windows8. I want to build a app 
> named 
> > 'customauth' that supports email activation. I choose to create my own 
> user 
> > model from the django.contrib.auth.models.AbstractBaseUser , not a 
> profile 
> > model that holds a OneToOneField to django build-in User model. 
> > 
> > This model class is called 'MyUser'.Its features: 
> > 
> > 1. Only three fields : email, username and password are required when 
> > creating an MyUser instance. 
> > 
> > 2. User logins my site via email and password. 
> > 
> > 3. When creating a user (not superuser), field 'is_active' is False, 
> > 'activation_key' is set to a random key with username, then, djanog 
> sends an 
> > email with a activation_key link to him. If user clicks it in some days 
> > (like 3), his 'is_active' turns True,  'activation_key' turns to be a 
> > constant , so he can login. 
> > 
> > 4.When creating a superuser, its 'is_active' is True, 'activation_key' 
> is a 
> > constant directly and not invoking the process of sending activation 
> email. 
> > 
> > Up to now, what I have done looks like a weird combination of a custom 
> User 
> > model from Substituting a custom User model and the theory from 
> > django-registration. 
> > 
> > Now my situation is weird: 
> > 
> > 1.Only when 'python manage.py syncdb' in cmd.exe, creating the 
> superuser, 
> > the whole process can work fine (i.e.,send a mail, then click it to 
> > activate). However, this superuser can not login admin site despite its 
> > 'is_admin' is True. It can only login user site. 
> > https://www.dropbox.com/s/1l8f78fgfj4696a/super.jpg 
> > 
> > 2.When you register a user in the normal way (you enter some required 
> > infomation in the form), the user can be created, but django will not 
> send a 
> > email to this user. 
> > 
> > Now I donot know the reason, but as the email activation system works 
> fine 
> > when first creating the superuser, there must be a way to make it works 
> in 
> > user register. 
> > 
> > So, what should I do, Thanks. 
> > 
> > This is the project file myauth.zip, if needed.'customauth' is the app. 
> > 
> > -- 
> > 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. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/ed7f7396-ac88-476a-a745-c74a7e612dcd%40googlegroups.com.
>  
>
> > 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2fc70b9c-1ed0-4264-b957-5901f3cc66da%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


How to set form count to 1 in jquery formset?

2014-01-04 Thread Mrinmoy Das
hi,

I am using jqury formset for django formset factory. Problem is the form
count depends on TOTAL_FORMS. That means if I add 3forms, in the next GET
request the page loads with 3 forms and when i click on add-row, again
3forms are added at once, but I want to add only one form. Any help?

Mrinmoy Das
http://goromlagche.in/

-- 
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/CAFWA-MMy6r_RAe5bihBOw5Y6igY%3DTcdasmSjF%3DEXpoSw%2BRKhgQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.