Re: django-allauth facebook doesn't collect more information other than "name" and "id"

2017-11-27 Thread Shahab Emami
hello 

i have the same problem but for the google.

this is my settings:
SOCIALACCOUNT_PROVIDERS = { 'google':
 { 'SCOPE': ['email',

 'https://www.googleapis.com/auth/user.birthday.read',

 'https://www.googleapis.com/auth/user.phonenumbers.read',
 'https://www.googleapis.com/auth/contacts',
 'https://www.googleapis.com/auth/plus.me',
 ],
   'AUTH_PARAMS': { 'access_type': 'online' },
   'FIELDS': [
'birthday',
'phonenumbers'
],
 },


  }

but i don't get phone number  and birthday in extra_data
i'm am sure google is sending them because he asked about sending phone 
number and birthday 
can you heop me in this?plz

my environment is
ubunto 16
python 3.5
django 1.11
django-allauth 0.34.0

On Monday, November 2, 2015 at 3:57:32 PM UTC+3:30, Saleem Jaffer wrote:
>
> I tried adding facebook login to my application using django-allauth. 
> Unfortunately the only fields that get captured are "name" and "id". All 
> the other information is not captured.
>
> This issue has already been addressed here: 
> https://github.com/pennersr/django-allauth/issues/1061.
>
> Supposedly, using django-allauth version 0.22 and higher should solve 
> this. But I am using 0.23 and still the issue persists. 
>
> Any help will be 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7a4202b7-17c8-439e-9234-0b1e61dce632%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django-allauth facebook doesn't collect more information other than "name" and "id"

2017-11-28 Thread Shahab Emami
no one is here to answer my question?

On Monday, November 2, 2015 at 3:57:32 PM UTC+3:30, Saleem Jaffer wrote:
>
> I tried adding facebook login to my application using django-allauth. 
> Unfortunately the only fields that get captured are "name" and "id". All 
> the other information is not captured.
>
> This issue has already been addressed here: 
> https://github.com/pennersr/django-allauth/issues/1061.
>
> Supposedly, using django-allauth version 0.22 and higher should solve 
> this. But I am using 0.23 and still the issue persists. 
>
> Any help will be 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1db52625-efcf-4758-9621-ef93a9d84bc0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django sample projects

2017-03-27 Thread Shahab Emami
hello 

i have question:
where can i find a few django sample projects?
i have seen a few tutorials and courses but i don't now how 
a real project should be.
then i need to see a few sample django codes . 

i now there are a lot of project in github but i can't use them.
there are not the thing that i want they are reusable apps
that i have to use them beside my own project but i want a whole 
project.
i want such project that i can run it in my computer by it's own.

can you please help me .
i am learning django for a year but i cant steel write program.
i only can create some simple apps.

i can create model , work with forms, templates, angular but still 
nothing.

i cant do a real project then i all of my trying are nothing.

thank for your help


-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f45bd08f-57fc-46b2-9c7e-9cff869fe7b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Channels - get online users

2017-03-27 Thread Shahab Emami
don't you have any sample project?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/28817c8d-767a-48e2-bd29-01a9b3f590ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django sample projects

2017-03-27 Thread Shahab Emami
i can set up a project.

i want to see a real source code of a project.
i can create a simple project .
i need an example project.
for example a source of an online market or anything else

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fae0ae7c-0d74-42e8-bef2-2d72d6f8964f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django sample projects

2017-03-27 Thread Shahab Emami
i think if i study the code of other programmers it can help me a lot.
i think one of the best way for me to be a real programmer is watching code 
of others.

an integrated project that do something, i need that.
ready source is big step for me that takes me a few years next. 

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e552b404-36e7-40cb-b205-41ac07a5afb6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


why i cant always

2017-04-04 Thread shahab emami
hello
i could never install an app from github
i get errors all the time

i do all of the installation process step by step but i cant at the end

can anybody help me in this?

for example i wanted to use this app in my project:
https://github.com/praekelt/django-likes
after 4 hours i got nothing except of this:

"INSTALLED_APPS." % (module, name)
RuntimeError: Model class secretballot.models.Vote doesn't declare an 
explicit a
pp_label and isn't in an application in INSTALLED_APPS.
 
i know this is gonna sound really stupid but i feel that if I can do this 
there isn't anything i can't do in django

will you help me ? please?

python 3.6
django 1.10
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/10127483-4c42-4591-938d-04dcbb89a221%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: why i cant always

2017-04-05 Thread shahab emami


yes i installed it .
with this command:

python -m pip install django-secretballot

I have a question can you install this app on for yours?
because I believe if someone else can install this app for his project i 
can do it too.
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7c11617f-f7fd-46b2-a535-f4e0cc4e5ee6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-07 Thread shahab emami
hello 
i have a simple question
please help me if you can


i want to install this package on my project:

https://pypi.python.org/pypi/django-secretballot/

I am doing the installation step by step but after adding 'secretballot', 
to my installed_apps It says:

* add a secretballot middleware to MIDDLEWARE_CLASSES (see middleware 
section for details)


I now where MIDDLEWARE_CLASSES is. it's in setteings.py right after 
installed_apps but i don't
what I have to add to it. 
can you tell me what's the point when it says "add a secretballot 
middleware" ?
i mean how many secretballot middleware we have that i have to add one of 
them to my installed_apps?

thank you again

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f10101b2-0991-4ac0-af23-59ec14870149%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-07 Thread shahab emami
tanks
but my problem is:
I don't know where middleware section  is.
i looked for middleware section  in the app but i couldn't find anything.
that's why i asked that question here

On Friday, April 7, 2017 at 9:10:05 PM UTC+4:30, Daniel Roseman wrote:
>
>
>
> On Friday, 7 April 2017 15:46:36 UTC+1, shahab emami wrote:
>>
>> hello 
>> i have a simple question
>> please help me if you can
>>
>>
>> i want to install this package on my project:
>>
>> https://pypi.python.org/pypi/django-secretballot/
>>
>> I am doing the installation step by step but after adding 'secretballot', 
>> to my installed_apps It says:
>>
>> * add a secretballot middleware to MIDDLEWARE_CLASSES (see middleware 
>> section for details)
>>
>>
>> I now where MIDDLEWARE_CLASSES is. it's in setteings.py right after 
>> installed_apps but i don't
>> what I have to add to it. 
>> can you tell me what's the point when it says "add a secretballot 
>> middleware" ?
>> i mean how many secretballot middleware we have that i have to add one of 
>> them to my installed_apps?
>>
>> thank you again
>>
>
>
> Well, as you quoted, the instruction goes on to say "see middleware 
> section for details". That section does indeed show you what to put in the 
> setting.
> --
> DR.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a51dbbf7-c195-4563-a1e2-0f2526447ce7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-07 Thread shahab emami
nobody can help me in this?
what i have to add to middleware class?

On Friday, April 7, 2017 at 7:16:36 PM UTC+4:30, shahab emami wrote:
>
> hello 
> i have a simple question
> please help me if you can
>
>
> i want to install this package on my project:
>
> https://pypi.python.org/pypi/django-secretballot/
>
> I am doing the installation step by step but after adding 'secretballot', 
> to my installed_apps It says:
>
> * add a secretballot middleware to MIDDLEWARE_CLASSES (see middleware 
> section for details)
>
>
> I now where MIDDLEWARE_CLASSES is. it's in setteings.py right after 
> installed_apps but i don't
> what I have to add to it. 
> can you tell me what's the point when it says "add a secretballot 
> middleware" ?
> i mean how many secretballot middleware we have that i have to add one of 
> them to my installed_apps?
>
> thank you again
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/afa668e0-7464-4045-bd9c-7ec95d429975%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-07 Thread shahab emami


On Saturday, April 8, 2017 at 1:59:20 AM UTC+4:30, shahab emami wrote:
>
> tanks
> but my problem is:
> I don't know where middleware section  is.
> i looked for middleware section  in the app but i couldn't find anything.
> that's why i asked that question here
>
> On Friday, April 7, 2017 at 9:10:05 PM UTC+4:30, Daniel Roseman wrote:
>>
>>
>>
>> On Friday, 7 April 2017 15:46:36 UTC+1, shahab emami wrote:
>>>
>>> hello 
>>> i have a simple question
>>> please help me if you can
>>>
>>>
>>> i want to install this package on my project:
>>>
>>> https://pypi.python.org/pypi/django-secretballot/
>>>
>>> I am doing the installation step by step but after adding 
>>> 'secretballot', to my installed_apps It says:
>>>
>>> * add a secretballot middleware to MIDDLEWARE_CLASSES (see middleware 
>>> section for details)
>>>
>>>
>>> I now where MIDDLEWARE_CLASSES is. it's in setteings.py right after 
>>> installed_apps but i don't
>>> what I have to add to it. 
>>> can you tell me what's the point when it says "add a secretballot 
>>> middleware" ?
>>> i mean how many secretballot middleware we have that i have to add one 
>>> of them to my installed_apps?
>>>
>>> thank you again
>>>
>>
>>
>> Well, as you quoted, the instruction goes on to say "see middleware 
>> section for details". That section does indeed show you what to put in the 
>> setting.
>> --
>> DR.
>>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/38dde28b-4e86-4e33-a88c-0a302ceca3c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-07 Thread shahab emami
I knew where middleware is myself.
if you read my first post you will see that .
my question is:
what i have to add to middleware?

On Friday, April 7, 2017 at 7:16:36 PM UTC+4:30, shahab emami wrote:
>
> hello 
> i have a simple question
> please help me if you can
>
>
> i want to install this package on my project:
>
> https://pypi.python.org/pypi/django-secretballot/
>
> I am doing the installation step by step but after adding 'secretballot', 
> to my installed_apps It says:
>
> * add a secretballot middleware to MIDDLEWARE_CLASSES (see middleware 
> section for details)
>
>
> I now where MIDDLEWARE_CLASSES is. it's in setteings.py right after 
> installed_apps but i don't
> what I have to add to it. 
> can you tell me what's the point when it says "add a secretballot 
> middleware" ?
> i mean how many secretballot middleware we have that i have to add one of 
> them to my installed_apps?
>
> thank you again
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/63d353bb-8ef6-4c15-ba79-eb6ce9b80023%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-08 Thread shahab emami
thank you fabio
I needed this line:
'secretballot.middleware.SecretBallotIpUseragentMiddleware',

my problem solved
thanks again

On Saturday, April 8, 2017 at 3:52:51 PM UTC+4:30, Fabio Caritas 
Barrionuevo da Luz wrote:
>
> Hello Shahab. 
>
> Perhaps the real problem is that you apparently have not completed a good 
> tutorial to learn how django works and how to use it.
>
> I would recommend these two tutorials: https://tutorial.djangogirls.org/ 
> and http://www.marinamele.com/taskbuster-django-tutorial
>
> said that, this is the relevant documentation about django Middleware: 
> https://docs.djangoproject.com/en/1.11/topics/http/middleware/
>
> Note: The django Middleware configuration on settings.py was renamed in 
> Django 1.10, from MIDDLEWARE_CLASSES to MIDDLEWARE .
>
> Learn more about why this change in: 
> https://github.com/django/deps/blob/master/final/0005-improved-middleware.rst
>
> About django-secretballot specifically, the available 
>
>
> https://github.com/jamesturk/django-secretballot/blob/master/secretballot/middleware.py#L13-L18
>
>
> MIDDLEWARE = [
> # other previous middleware configurations
> 
> # Add the below line, on final of MIDDLEWARE variable in your 
> settings.py
> 'secretballot.middleware.SecretBallotIpUseragentMiddleware',
> ]
>
>
> I hope this has helped. Good studies :-)
>
> On Sat, Apr 8, 2017 at 3:23 AM, shahab emami  > wrote:
>
>> I knew where middleware is myself.
>> if you read my first post you will see that .
>> my question is:
>> what i have to add to middleware?
>>
>> On Friday, April 7, 2017 at 7:16:36 PM UTC+4:30, shahab emami wrote:
>>>
>>> hello 
>>> i have a simple question
>>> please help me if you can
>>>
>>>
>>> i want to install this package on my project:
>>>
>>> https://pypi.python.org/pypi/django-secretballot/
>>>
>>> I am doing the installation step by step but after adding 
>>> 'secretballot', to my installed_apps It says:
>>>
>>> * add a secretballot middleware to MIDDLEWARE_CLASSES (see middleware 
>>> section for details)
>>>
>>>
>>> I now where MIDDLEWARE_CLASSES is. it's in setteings.py right after 
>>> installed_apps but i don't
>>> what I have to add to it. 
>>> can you tell me what's the point when it says "add a secretballot 
>>> middleware" ?
>>> i mean how many secretballot middleware we have that i have to add one 
>>> of them to my installed_apps?
>>>
>>> thank you again
>>>
>>> -- 
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/63d353bb-8ef6-4c15-ba79-eb6ce9b80023%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/63d353bb-8ef6-4c15-ba79-eb6ce9b80023%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Fábio C. Barrionuevo da Luz
> Palmas - Tocantins - Brasil - América do Sul
>
> http://pythonclub.com.br/
>
> Blog colaborativo sobre Python e tecnologias Relacionadas, mantido 
> totalmente no https://github.com/pythonclub/pythonclub.github.io .
>
> Todos são livres para publicar. É só fazer fork, escrever sua postagem e 
> mandar o pull-request. Leia mais sobre como publicar em README.md e 
> contributing.md.
> Regra básica de postagem:
> "Você" acha interessante? É útil para "você"? Pode ser utilizado com 
> Python ou é útil para quem usa Python? Está esperando o que? Publica logo, 
> que estou louco para ler...
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/911b1e61-6cd8-491d-afce-cfdfb7c1a5d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


safe perfect and reliable app for verification email

2017-04-15 Thread shahab emami
hello
I want to verify user's email while user is registering  .

can you introduce me a few safe perfect  and reliable app for verification 
email?

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bc27f572-7c38-403a-a986-a400306ca951%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


method's name in MIDDLEWARE

2017-04-15 Thread shahab emami
hello 

i want to learn MIDDLEWARE in django  . 

i created this:

class SimpleMiddleware(object):

def process_request(self, request):
print("")

and i added in settings.py. then as you probably know i see "%%" in 
console with every click.
that is the exact thing that i except.

but when i change name of method:

def hello(self, request):
print("")
  it doesn't work anymore  .

is process_request a keyword? where can i find list of this names ?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/504db6b6-c18f-4c2b-8453-9d6db429b966%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


send email with django

2017-04-18 Thread shahab emami
hello

i want to send email using django. i used to send email with pour python 
before but now i can't do that in django.

i have search about this and i have seen some tutorials on youtube  in last 
two days but i cant do this .

this is in my settings.py :

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'my_gm...@gmail.com'
EMAIL_HOST_PASSWORD= 'my_password'
EMAIL_PORT = 587

and this is my send email:

from django.core.mail import send_mail
def click(request):
send_mail(
'shahab',
'Here is the message.',
'my_gm...@gmail.com',
['shahabem...@yahoo.com'],
fail_silently=True
)
return HttpResponseRedirect('index')

but it doesn't work.

I am running this code on localhost. but i doesn't work on heroku too.
i changed allow less secure app to on in my gmail account and 
i went to this page too and  i clicked on continue :
https://accounts.google.com/DisplayUnlockCaptcha

can anybody tell me:
what am i missing ?



-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/65e0ab09-ff5a-4ed5-89d6-e5e0991b9ea0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: send email with django

2017-04-19 Thread shahab emami
i have seen a few tutorial that use Gmail account for sending email. 
like this:

http://stackoverflow.com/questions/31324005/django-1-8-sending-mail-using-gmail-smtp

https://www.youtube.com/watch?v=51mmqf5a0Ss
and more.
but tried with yahoo email too . then i changed my settings.py to this:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.mail.yahoo.com'
EMAIL_HOST_USER = 'my_yahoo_account'
EMAIL_HOST_PASSWORD = 'my_password'
EMAIL_PORT = 587

but it steel doesn't work.

On Wednesday, April 19, 2017 at 11:02:12 AM UTC+4:30, Antonis Christofides 
wrote:
>
> Hi,
>
> I may be mistaken, but I think it's not possible to use Gmail as a 
> smarthost if all you have is a free account, and even if it is possible, it 
> is hard to setup. Better try another email provider or with a paid account.
>
> Regards,
>
> A.
>
> Antonis Christofideshttp://djangodeployment.com
>
> On 2017-04-19 00:25, shahab emami wrote:
>
> hello
>
> i want to send email using django. i used to send email with pour python 
> before but now i can't do that in django.
>
> i have search about this and i have seen some tutorials on youtube  in 
> last two days but i cant do this .
>
> this is in my settings.py :
>
> EMAIL_USE_TLS = True
> EMAIL_HOST = 'smtp.gmail.com'
> EMAIL_HOST_USER = 'my_g...@gmail.com '
> EMAIL_HOST_PASSWORD= 'my_password'
> EMAIL_PORT = 587
>
> and this is my send email:
>
> from django.core.mail import send_mail
> def click(request):
> send_mail(
> 'shahab',
> 'Here is the message.',
> 'my_g...@gmail.com ',
> ['shaha...@yahoo.com '],
> fail_silently=True
> )
> return HttpResponseRedirect('index')
>
> but it doesn't work.
>
> I am running this code on localhost. but i doesn't work on heroku too.
> i changed allow less secure app to on in my gmail account and 
> i went to this page too and  i clicked on continue :
> https://accounts.google.com/DisplayUnlockCaptcha
>
> can anybody tell me:
> what am i missing ?
>
>
>
> -- 
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/65e0ab09-ff5a-4ed5-89d6-e5e0991b9ea0%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/65e0ab09-ff5a-4ed5-89d6-e5e0991b9ea0%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

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


Re: send email with django

2017-04-19 Thread shahab emami
but it's free for 30 days. what i have to do after 30 days?

On Wednesday, April 19, 2017 at 6:18:38 PM UTC+4:30, Thiago Luiz Parolin 
wrote:
>
> i am using sendgrid for send emails...the free service works very well for 
> me...there is a paid version too..
> sendgrid can be integrated into django
>
> https://sendgrid.com/docs/Integrate/Frameworks/django.html
>
>
>
>
> 2017-04-19 8:46 GMT-03:00 Carl >:
>
>> As a counter-perspective, we have this working with a paid G Suite 
>> (formerly Google Apps) account. *Important* We had to register the IP 
>> address of our server with G Suite. This Google support document outlines 
>> the process:
>>   SMTP relay: Route outgoing non-Gmail messages through Google
>>   https://support.google.com/a/answer/2956491?hl=en
>>
>> In terms of Django, our settings.py file has the following relevant 
>> settings:
>>
>> # To have error messages auto-sent via email:
>> SERVER_EMAIL = 'myn...@mypaid-gmail.com '
>> ADMINS = [('MyWebServer', 'myn...@mypaid-gmail.com '),]
>>
>> EMAIL_USE_TLS = True
>> EMAIL_HOST = 'smtp-relay.gmail.com'
>> EMAIL_PORT = 587
>> EMAIL_HOST_USER = ''
>> EMAIL_HOST_PASSWORD = ''
>> DEFAULT_FROM_EMAIL = 'myn...@mypaid-gmail.com '
>> DEFAULT_TO_EMAIL = 'myn...@mypaid-gmail.com '
>>
>> Hope this helps!
>>
>>  Original Message 
>> Subject: Re: send email with django
>> Local Time: April 19, 2017 7:00 AM
>> UTC Time: April 19, 2017 11:00 AM
>> From: red...@gmail.com 
>> To: django...@googlegroups.com 
>>
>>
>> Also, don't fail silently it would be helpful to see actual error that 
>> happens...
>>
>> On 19.04.2017 00:25, shahab emami wrote:
>>
>> hello
>>
>> i want to send email using django. i used to send email with pour python 
>> before but now i can't do that in django.
>>
>> i have search about this and i have seen some tutorials on youtube  in 
>> last two days but i cant do this .
>>
>> this is in my settings.py :
>>
>> EMAIL_USE_TLS = True
>> EMAIL_HOST = 'smtp.gmail.com'
>> EMAIL_HOST_USER = 'my_g...@gmail.com '
>> EMAIL_HOST_PASSWORD= 'my_password'
>> EMAIL_PORT = 587
>>
>> and this is my send email:
>>
>> from django.core.mail import send_mail
>> def click(request):
>> send_mail(
>> 'shahab',
>> 'Here is the message.',
>> 'my_g...@gmail.com ',
>> ['shaha...@yahoo.com '],
>> fail_silently=True
>> )
>> return HttpResponseRedirect('index')
>>
>> but it doesn't work.
>>
>> I am running this code on localhost. but i doesn't work on heroku too.
>> i changed allow less secure app to on in my gmail account and 
>> i went to this page too and  i clicked on continue :
>> https://accounts.google.com/DisplayUnlockCaptcha
>>
>> can anybody tell me:
>> what am i missing ?
>>
>>
>>
>> --
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/65e0ab09-ff5a-4ed5-89d6-e5e0991b9ea0%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/65e0ab09-ff5a-4ed5-89d6-e5e0991b9ea0%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> -- 
>> Jani Tiainen
>>
>>
>> --
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/6a7f0307-4144-b649-cdc8-8e679e89ceca%40gmail.com
>>  
>> <https://groups.google

Re: send email with django

2017-04-19 Thread shahab emami
but that doesn't work for me too.

i sign up in sendgrid and this is my new settings.py

EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_HOST_USER = 'my_account'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_PORT = 587
EMAIL_USE_TLS = True

not on localhost and not on heroku


On Thursday, April 20, 2017 at 1:38:53 AM UTC+4:30, suabiut wrote:
>
> I am also using sendgrid it works very well. 
>
> On Thu, Apr 20, 2017 at 6:56 AM, shahab emami  > wrote:
>
>> but it's free for 30 days. what i have to do after 30 days?
>>
>> On Wednesday, April 19, 2017 at 6:18:38 PM UTC+4:30, Thiago Luiz Parolin 
>> wrote:
>>>
>>> i am using sendgrid for send emails...the free service works very well 
>>> for me...there is a paid version too..
>>> sendgrid can be integrated into django
>>>
>>> https://sendgrid.com/docs/Integrate/Frameworks/django.html
>>>
>>>
>>>
>>>
>>> 2017-04-19 8:46 GMT-03:00 Carl :
>>>
>>>> As a counter-perspective, we have this working with a paid G Suite 
>>>> (formerly Google Apps) account. *Important* We had to register the IP 
>>>> address of our server with G Suite. This Google support document outlines 
>>>> the process:
>>>>   SMTP relay: Route outgoing non-Gmail messages through Google
>>>>   https://support.google.com/a/answer/2956491?hl=en
>>>>
>>>> In terms of Django, our settings.py file has the following relevant 
>>>> settings:
>>>>
>>>> # To have error messages auto-sent via email:
>>>> SERVER_EMAIL = 'myn...@mypaid-gmail.com'
>>>> ADMINS = [('MyWebServer', 'myn...@mypaid-gmail.com'),]
>>>>
>>>> EMAIL_USE_TLS = True
>>>> EMAIL_HOST = 'smtp-relay.gmail.com'
>>>> EMAIL_PORT = 587
>>>> EMAIL_HOST_USER = ''
>>>> EMAIL_HOST_PASSWORD = ''
>>>> DEFAULT_FROM_EMAIL = 'myn...@mypaid-gmail.com'
>>>> DEFAULT_TO_EMAIL = 'myn...@mypaid-gmail.com'
>>>>
>>>> Hope this helps!
>>>>
>>>>  Original Message 
>>>> Subject: Re: send email with django
>>>> Local Time: April 19, 2017 7:00 AM
>>>> UTC Time: April 19, 2017 11:00 AM
>>>> From: red...@gmail.com
>>>> To: django...@googlegroups.com
>>>>
>>>>
>>>> Also, don't fail silently it would be helpful to see actual error that 
>>>> happens...
>>>>
>>>> On 19.04.2017 00:25, shahab emami wrote:
>>>>
>>>> hello
>>>>
>>>> i want to send email using django. i used to send email with pour 
>>>> python before but now i can't do that in django.
>>>>
>>>> i have search about this and i have seen some tutorials on youtube  in 
>>>> last two days but i cant do this .
>>>>
>>>> this is in my settings.py :
>>>>
>>>> EMAIL_USE_TLS = True
>>>> EMAIL_HOST = 'smtp.gmail.com'
>>>> EMAIL_HOST_USER = 'my_g...@gmail.com'
>>>> EMAIL_HOST_PASSWORD= 'my_password'
>>>> EMAIL_PORT = 587
>>>>
>>>> and this is my send email:
>>>>
>>>> from django.core.mail import send_mail
>>>> def click(request):
>>>> send_mail(
>>>> 'shahab',
>>>> 'Here is the message.',
>>>> 'my_g...@gmail.com',
>>>> ['shaha...@yahoo.com'],
>>>> fail_silently=True
>>>> )
>>>> return HttpResponseRedirect('index')
>>>>
>>>> but it doesn't work.
>>>>
>>>> I am running this code on localhost. but i doesn't work on heroku too.
>>>> i changed allow less secure app to on in my gmail account and 
>>>> i went to this page too and  i clicked on continue :
>>>> https://accounts.google.com/DisplayUnlockCaptcha
>>>>
>>>> can anybody tell me:
>>>> what am i missing ?
>>>>
>>>>
>>>>
>>>> --
>>>> 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.
>&

SelectDateWidget dosent work

2017-04-24 Thread shahab emami
hello 
i have a birth date filed in my  model this:


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

my forms.py i have this:


class ProfileForm(ModelForm):
birth_date= forms.DateField(widget=forms.SelectDateWidget)
class Meta:
model = Member
exclude = ()


then i expect a dropdownlist for birth_date in template but it is only a 
regular input


i always work with function base view but now I am working with class base 
view for first time. 


then i have to say i think this is the problem . i mean i can see result of 
SelectDateWidget  in function base view but in class base view NO.


I want to create inline formset according to this tutorial:


https://medium.com/@adandan01/django-inline-formsets-example-mybook-420cc4b6225d


I only add one filed to parent field because i want to save birth_date of 
user. then i user SelectDateWidget in

forms.py but it dosent work anymore .

 It seems nobody had this problem before because i couldn't find my answer 
from the internet ond Stack Overflow.


can you help me please?







-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1657d161-e076-4984-9fe6-07a2215250ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django formset

2017-04-28 Thread shahab emami
hello
i search for my question on google and this group by i couldn't find the 
answer.
maybe I am not a good searcher.D

i have a formset.
there is a field for birth date in my form then as you know there are a few 
birth date field in my formset. I use this jquery plugin to add form 
dynamically:

https://github.com/elo80ka/django-dynamic-formset

every thing is good until now.  but because I have a date field in my form 
i want to

use this jquery plugin :

Datepicker | jQuery UI



then user can select date from this calendar . 
but i don't now the id of date field in the form. 
how can i select it with jquery  when i don't now the id of it?
I tried to find it with inspect element but i understood the id is 
different in every form.  
if you can tell me the idea to solving this problem or
introduce somewhere that i can read about this i will be thankful.


-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/26a172d0-cd75-45e3-aa0c-f795dd40d754%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where is django-admin?

2017-04-28 Thread shahab emami
then you have to open your command line in the same path that 
django-admin.py is.


On Friday, April 28, 2017 at 3:39:04 PM UTC+4:30, Pelle Pälsänger wrote:
>
> Yes I know where django-admin.py is. I 
> put C:\Users\stig\djangogirls\myvenv\Scripts in my path. 
> BR,
> Stig
>
>
>
> Den torsdag 27 april 2017 kl. 15:22:13 UTC+2 skrev Pelle Pälsänger:
>>
>> Hi!
>>
>> I try to learn how to create web apps with django on windows10. 
>> I have downloaded django1.11 ($git clone 
>> https://github.com/django/django.git) and installed it ($py -m pip 
>> install Django==1.11).
>> I follow 
>> https://pythonprogramming.net/django-web-development-with-python-intro/
>>
>> Then I try to start a project with django-admin startproject mySite, but 
>> django-admin is not recognized as a command. I search for django-admin but 
>> I cannot find it. Tell me why? Where should I find it, to add it to path!?
>>
>> BR. Pelle
>>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/82be890b-f699-4e77-a6d5-f647df03f761%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch

2017-04-28 Thread shahab emami
hi
this is for the id.
your url must be like this:

url(r'^events/((?P\d+))/delete/$', views.delete_event, name=
'delete_event'),



you also need to give an amount in your template to the id:




action="{% url 'cal:delete_event' id=an_event_id %}">



On Saturday, April 29, 2017 at 1:08:46 AM UTC+4:30, Will Holmes wrote:
>
> Hey all,
>
> Can anyone tell me the (probably quite obvious) reason my reverse match 
> isn't working?
>
> Template:
> 
>value="Delete">
> 
>
> Url:
> url(r'^events/(\d+)/delete_event$', views.delete_event, 
> name='delete_event'),
>
> View:
> def delete_event(request, id):
> Events.objects.filter(id=id).delete()
> return redirect("cal:home")
>
> Also, if anyone can tell me a good way to get my delete button I'd be very 
> grateful. 
>
> Cheers,
>
> Will
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/336a6a05-f6d0-4029-879c-b5d65f396210%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django formset

2017-04-29 Thread shahab emami
somebody had my problem before:

https://github.com/elo80ka/django-dynamic-formset/issues/108

please tell me something about this problem i cant solve if yet

On Friday, April 28, 2017 at 3:45:10 PM UTC+4:30, shahab emami wrote:
>
> hello
> i search for my question on google and this group by i couldn't find the 
> answer.
> maybe I am not a good searcher.D
>
> i have a formset.
> there is a field for birth date in my form then as you know there are a 
> few birth date field in my formset. I use this jquery plugin to add form 
> dynamically:
>
> https://github.com/elo80ka/django-dynamic-formset
>
> every thing is good until now.  but because I have a date field in my form 
> i want to
>
> use this jquery plugin :
>
> Datepicker | jQuery UI
>
>
>
> then user can select date from this calendar . 
> but i don't now the id of date field in the form. 
> how can i select it with jquery  when i don't now the id of it?
> I tried to find it with inspect element but i understood the id is 
> different in every form.  
> if you can tell me the idea to solving this problem or
> introduce somewhere that i can read about this i will be thankful.
>
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7731176e-4be8-4f41-88ae-52fded5b1a22%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django-select2-forms

2017-05-02 Thread shahab emami
hello

I want to use django-select2-forms in my project . this package is here:
https://pypi.python.org/pypi/django-select2-forms/2.0.1

I followed the exact instructions but It does not install
here is things I did:

1:   
pip install django-select2-forms


  I can see select2 has been installed in my site package
2:   I added this line to my_installed_packages in settings.py:
 
   'select2',


3:  I added this line to main urls.py:
 
   url(r'^select2/', include('select2.urls')),



after that i put this models in my models.py they are from it's example:



class Author(models.Model):
name = models.CharField(max_length=100)

def __str__(self):
return self.name

class Entry(models.Model):
author = select2.fields.ForeignKey(Author,
overlay="Choose an author...",
on_delete=models.CASCADE)

but when i run :
python manage.py makemigrations

I get this error:
author = select2.fields.ForeignKey(Author,
NameError: name 'select2' is not defined

I searched for this but i could not find anything.
would you help me please?
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b1d0b422-01e6-43e3-88af-1600af503c06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


what kind of question i can ask here?

2017-05-13 Thread shahab emami
hello

when i get a problem in my code i search for it in google for an hour if i 
couldn't find the answer then i ask my question here.
is this good?
I mean can i ask my programming questions here?
or this group is just for bugs and stuff like that?

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7a438e5a-4625-4efd-97ea-65a754bd2e1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: what kind of question i can ask here?

2017-05-13 Thread shahab emami
thanks
every time that i wanted to ask question i was worried .
i thought  maybe this is simple question and i don't have to ask this in 
this professional group 

On Saturday, May 13, 2017 at 5:19:14 PM UTC+4:30, shahab emami wrote:
>
> hello
>
> when i get a problem in my code i search for it in google for an hour if i 
> couldn't find the answer then i ask my question here.
> is this good?
> I mean can i ask my programming questions here?
> or this group is just for bugs and stuff like that?
>
> 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f947a0bd-94fe-4b90-9300-0a017f723a1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


model choice field

2017-06-22 Thread shahab emami
hello

i have a model choice field like this:

LEVEL_CHOICES = [
> ('1', 'one'),
> ('2', 'two'),
> ('3', 'three'),
> ]
>
> but when i select from database and say:


{{object.level}}

 it shows me 1 or 2 or 3 but i wanted to be one or two or three

how can i do that?

i did some search but i got nothing , actually i dont now what i have to 
search for this problem

thank you

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/52c1fb1b-9e70-42dd-9d7f-4f608f190d97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django JsonResponse

2017-06-28 Thread shahab emami
hello 

i want to use ajax in my django project.

i have no problem with writing ajax method or url. my problem is in my 
django view.

i send a pk from template with ajax and in my view:

def edit(request):
pk = request.GET.get('pk' or None)

instance = models.MyModel.objects.get(pk=pk)

return JsonResponse(instance)


can anybody tell me if this is a good way to work with JsonResponse?

when i write this i get this error:
MyModel object is not iterable

what i have to do to solve this error.

every search that i make is about SimpleJson but i now SimpleJson is before 
django 1.7

i am working with django 1.11

can anybody save me from this 

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4efc338d-7326-4c98-9e03-c88ba0834ff3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


save cropped image with PIL to database

2017-07-03 Thread shahab emami
hello

i have a question and i cant find answer with search.

i want to save cropped image in database then :
this is my model:

class Photo(models.Model):
file= models.ImageField(upload_to='%Y/%m/%d', blank=True,null=True)


i have a form then user can select image and send to view like this:


{% csrf_token %}

  



  


and in the view i have this :

from PIL import Image


def save_photo(request):

_photo, created = models.Photo.objects.get_or_create(pk=1)

if request.method == 'POST':
photo = request.FILES.get('file')

image = Image.open(photo)

cropped_image = image.crop((100, 100, 200, 200))
resized_image = cropped_image.resize((200, 200), Image.ANTIALIAS)
_photo.file = resized_image
_photo.save()


return HttpResponse("your image has been saved")





but i get this error:

'Image' object has no attribute '_committed'



i'm sure my mistake is in views.py but i dont now how to fix it. how can 
put resized_image that is an object of Image class to 
a model.
can you help me please?


-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/362887c4-6b41-47e2-a9f5-f4a129b2538d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: save cropped image with PIL to database

2017-07-04 Thread shahab emami
but i want to do it myself.

when i write code i can improve it as much as i can. 
can anybody please tell me about my mistake please

On Monday, July 3, 2017 at 9:12:55 PM UTC+4:30, Andréas Kühne wrote:
>
> I would have a look at the easy-thumbnails plugin (
> http://easy-thumbnails.readthedocs.io/en/2.1/). It uses pillow behind the 
> scenes and it is very easy to do the cropping and everything that you need 
> and you don't need to write it yourself :-)
>
> Regards,
>
> Andréas
>
> 2017-07-03 12:09 GMT+02:00 shahab emami >
> :
>
>> hello
>>
>> i have a question and i cant find answer with search.
>>
>> i want to save cropped image in database then :
>> this is my model:
>>
>> class Photo(models.Model):
>> file= models.ImageField(upload_to='%Y/%m/%d', 
>> blank=True,null=True)
>>
>>
>> i have a form then user can select image and send to view like this:
>>
>> 
>> {% csrf_token %}
>>
>>   
>>
>> 
>>
>>   
>>
>>
>> and in the view i have this :
>>
>> from PIL import Image
>>
>>
>> def save_photo(request):
>>
>> _photo, created = models.Photo.objects.get_or_create(pk=1)
>>
>> if request.method == 'POST':
>> photo = request.FILES.get('file')
>>
>> image = Image.open(photo)
>>
>> cropped_image = image.crop((100, 100, 200, 200))
>> resized_image = cropped_image.resize((200, 200), Image.ANTIALIAS)
>> _photo.file = resized_image
>> _photo.save()
>>
>>
>> return HttpResponse("your image has been saved")
>>
>>
>>
>>
>>
>> but i get this error:
>>
>> 'Image' object has no attribute '_committed'
>>
>>
>>
>> i'm sure my mistake is in views.py but i dont now how to fix it. how can 
>> put resized_image that is an object of Image class to 
>> a model.
>> can you help me please?
>>
>>
>> -- 
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/362887c4-6b41-47e2-a9f5-f4a129b2538d%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/362887c4-6b41-47e2-a9f5-f4a129b2538d%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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