Re: HELP WITH THIS CODE!!

2017-10-19 Thread Lachlan Musicman
No that code wont work - it looks more like Java.

Pro tip: if you want answers in this email list, you will definitely get a
response if you paste your code rather than a screen shot, and if you show
that you have completed the Django Tutorial as written by the developers.

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

It is the single best tutorial I've seen with regards to learning a new
technology.

Cheers
L.

--
"The antidote to apocalypticism is *apocalyptic civics*. Apocalyptic civics
is the insistence that we cannot ignore the truth, nor should we panic
about it. It is a shared consciousness that our institutions have failed
and our ecosystem is collapsing, yet we are still here — and we are
creative agents who can shape our destinies. Apocalyptic civics is the
conviction that the only way out is through, and the only way through is
together. "

*Greg Bloom* @greggish
https://twitter.com/greggish/status/873177525903609857

On 20 October 2017 at 06:06, Giovanny ordoñez 
wrote:

>
> 
>
>
> Hi guys!. i am new in this community. i need help with this code . is
> python using framework django.
>
> yo can say me, than do this code.
>
> --
> 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/dc80d304-5170-4a0b-b497-9f6920268dd2%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


how to run popen in django with apache? help~

2017-10-19 Thread Wu, Pei
Hi Django

I googled web two days, not find a solution yet, so I mail to group.

Here is my post, I want to use popen to run a simple command to copy file to s3.
https://stackoverflow.com/questions/46814197/how-to-run-popen-in-django-with-apache-help

The problem is apache, if Django use apache, the code seems doesn't run(without 
apache, it works fine), anyone has idea? Thank you!



Pei

-- 
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/BLUPR10MB0769EA0A9441D6C3A0FF4166E2420%40BLUPR10MB0769.namprd10.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.


HELP WITH THIS CODE!!

2017-10-19 Thread Giovanny ordoñez





Hi guys!. i am new in this community. i need help with this code . is 
python using framework django. 

yo can say me, than do this code.

-- 
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/dc80d304-5170-4a0b-b497-9f6920268dd2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Deployment showing list of directory

2017-10-19 Thread sarfaraz ahmed
This is been fixed

On Monday, 8 May 2017 15:39:25 UTC+5:30, sarfaraz ahmed wrote:
>
> Hello Guys,
>
> After lot of struggle I understood there is no MOD_WSGI file available for 
> latest version of XAMP which is compiled in VC14. I am not sure how to 
> compile MOD_WSGI with VC 14 so I gave up
>
> Now I downloaded Apache 2.4 compiled in VC9 + Python 2.7.13 on my windows 
> server 2016(AWS instance) I moved my website to this server. Changed 
> firewall setting to accepting incoming traffic and also networking 
> configuration. 
>
> Now I am seeing the list of directory and files instead of website. 
>
> Here is my wsgi.py file
>
> --
> import os
> import sys
> from django.core.wsgi import get_wsgi_application
> sys.path.append('C:\Apache24\htdocs\testarhamcollections\')
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project1.settings")
> application = get_wsgi_application()
>
> -
>
>
> This is conf file for Apache
>
> --
> 
> ServerAdmin ad...@testarhamcollections.com
> DocumentRoot "C:/Apache24/htdocs/testarhamcollections"
> ServerName www.testarhamcollections.com
> ServerAlias testarhamcollections.com
> ErrorLog 
> "C:/Apache24/htdocs/testarhamcollections/logs/testarhamcollections.com-error.log"
> CustomLog 
> "C:/Apache24/htdocs/testarhamcollections/logs/testarhamcollections.com-access.log"
>  
> common
> 
> WSGIScriptAlias / 
> "c:/Apache24/htdocs/testarhamcollections/project1/wsgi.py"
>
> Alias / "c:/Apache24/htdocs/testarhamcollections"
> Alias /static/ "c:/Apache24/htdocs/testarhamcollections/static/"
> Alias /media/ "c:/Apache24/htdocs/testarhamcollections/static/media/"
> 
> 
> Require all granted
> 
> 
> 
>
> ---
> I checked the error log of website it shows nothing. 
>
>
> -- 
> Thanks with regards,
> Sarfaraz Ahmed
>
>
>

-- 
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/319ea95f-1b36-4191-b94e-1dfff946543a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django deployement Apache

2017-10-19 Thread sarfaraz ahmed
Thanks you all you friends.. this is been fixed.


On Thursday, 31 August 2017 14:47:05 UTC+5:30, Antonis Christofides wrote:
>
> Did you run collectstatic? After you do so, the files will be copied to 
> /var/www/static_root or whatever your STATIC_ROOT points to.
>
> Some other notes:
>
>- You normally don't need to touch STATICFILES_DIRS at all. 
>- The value os.path.join(os.path.dirname(BASE_DIR), 'static_root') is 
>a bad idea for production. On development it may be OK, but in production 
>you'd better specify the full path, such as '/var/www/static_root'. 
>- You don't need to specify both "Alias /static/admin" and "Alias 
>/static". Just the second one will do. "Alias /static 
> /var/www/static_root" 
>and that's it. 
>
> Regards,
>
> Antonis
>
> Antonis Christofideshttp://djangodeployment.com
>
> On 2017-08-30 21:58, sarfaraz ahmed wrote:
>
> Thanks Antonis,
>
> I reached your website googling undoubtedly this is well explained. I have 
> been able to deploy but here is my problem
>
> STATIC_URL = '/static/'
> MEDIA_URL = '/media/'
>
>
> STATICFILES_DIRS = [os.path.join(BASE_DIR, 
> "static"),os.path.join(BASE_DIR,"static","admin")]
> STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR),'static_root')
> MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR),'media_root')
>
> This is my settings in settingss.py 
>
> Here is my vhost.conf files
>
> WSGIPythonHome /usr/local/lib/python2.7/dist-packages
>
>
> WSGIPythonPath /var/www/firsttest
>
> 
> ServerName firsttest.com
> ServerAlias www.firsttest.com
> ServerAdmin webmaster@localhost
>
> WSGIScriptAlias / /var/www/firsttest/firsttest/wsgi.py
>
> ErrorLog   /var/log/apache2/firsttest/first_error.log
> CustomLog   /var/log/apache2/firsttest/first_access.log combined
> Alias */static/admin /var/www/firsttest/static/admin*
> 
> Require all granted
> 
>
> Alias /static  */var/www/firsttest/static*
> 
> Require all granted
> 
>
> 
> 
> Require all granted
> 
> 
> 
>
> Now with this conf file everything works fine. CSS, js all works fine. 
> However, you notice the conf file marked in red. its not actually pointing 
> to my static_root folder which in settings defined as 
> /var/www/static_root
>
> static root is one which gathers all my static files when I run collect 
> static
>
> if I understand correctly from documentation. Web server should point to 
> static root folder to access css files in production. 
>
> Regards,
> Sarfaraz Ahmed
>
>
>  
>
> On Wednesday, 30 August 2017 13:44:35 UTC+5:30, Antonis Christofides 
> wrote: 
>>
>> Hello Sarfaraz,
>>
>> You could try "How Django static files work in production 
>> "
>>  
>> to get some understanding of the correct way to do it.
>>
>> Regards,
>>
>> Antonis
>>
>> Antonis Christofideshttp://djangodeployment.com
>>
>> On 2017-08-28 06:17, sarfaraz ahmed wrote:
>>
>> Thanks for your help. Yes it was permission issue. However I am not able 
>> to find anything under my site-packages. when I point the same to 
>> dist-packages it works. 
>>
>> WSGIPythonHome /usr/local/lib/python2.7/dist-packages
>> WSGIPythonPath /var/www/firsttest
>>
>> 
>> ServerName firsttest.com
>> ServerAlias www.firsttest.com
>> ServerAdmin webmaster@localhost
>>
>> WSGIScriptAlias / /var/www/firsttest/firsttest/wsgi.py
>>
>> ErrorLog   /var/log/apache2/firsttest/first_error.log
>> CustomLog   /var/log/apache2/firsttest/first_access.log combined
>> Alias /static/admin/ 
>> /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/
>> Alias /static/ /var/www/firsttest/static
>> 
>> 
>> Require all granted
>> 
>> 
>> 
>>
>> -
>>
>>
>> This is my new conf file and it works. However I am still not able to see 
>> my static files in admin. Any help would be appreciated.
>>
>>
>> Regards
>> Sarfaraz
>>
>> On Sunday, 27 August 2017 10:57:12 UTC+5:30, Vernon Swanepoel wrote: 
>>>
>>> Hello Sarfaraz, 
>>>
>>> A couple things you could look at:
>>>
>>>1. Are you including both your site-packages (eg 
>>>python3.6/lib/site-packages) and your django project root (where you 
>>>actually built the project) in your WSGIPythonPath?  String them 
>>> together 
>>>with a clone 
>>>(/path/to/python3.6/lib/site-packages:/path/to/django/project/myproject) 
>>>2. Your wsgi is within your django app 
>>>(/path/to/django/project/myproject/myproject/wsgi...).  It sits in the 
>>> same 
>>>file as your settings.py.  Make sure it's pointing to the right place, 
>>>because in your examples above your directory for django and your 

Re: hello everyone! I'm working on Django Framework. but

2017-10-19 Thread Erik Rull
Hi Andréas,

Andréas Kühne wrote:

> The main thing is that when you start runserver it continuesly checks for
> changes in your .py files. So if you change a file, you get a reload. This
> shouldn't be running on a production environment. 
> Another thing is that runserver also serves static files - something that
> you don't want your application server to do in production - that is better
> handled by a webserver.

Okay, that's fine for me and my private / local application.

> If only you are looking at the application that isn't a problem, but I
> wouldn't allow it to be accessible to the Internet

That's clear. No forwarding from/to any public IP is existing.

> 
> Regards,
> 
> Andréas
> 

Best regards,

Erik

-- 
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/1416b1a8-5e52-428f-c258-096ffe12094b%40rdsoftware.de.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.11 and PostgreSQL 10 compatibility

2017-10-19 Thread Carlos Augusto Machado
Hi,
You can use 9.4, 9.5 and 10.

Em qui, 19 de out de 2017 07:27, Edandweb 
escreveu:

> Hi,
>
> I am developing a new application in Python and Django, for the database
> we want to use the last version of PostgreSQL v10.
> The django Documentation says in
> https://docs.djangoproject.com/en/1.11/ref/databases/#postgresql-notes:
>
>
>
>
> *Django supports PostgreSQL 9.3 and higher. psycopg2
>  2.5.4 or higher is required, though the latest
> release is recommended.*
> I am not sure to understand, it's just 9.3 and higher like 9.3.1 or 9.3.2
> or 9.3.4 ... or can we use 9.4 and 9.5 ... ?
>
> 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/99f8fa1b-e892-4d72-93e6-afac2f54736b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: hello everyone! I'm working on Django Framework. but when I run the script $ ./manage.py runserver or $./manage.py runserver 0.0.0.0:8000 it only work on my system. how to make it public? so that

2017-10-19 Thread Andréas Kühne
2017-10-19 9:37 GMT+02:00 Erik Rull :

> Hello Andréas,
>
> Andréas Kühne wrote:
> > 1. First of all, you shouldn't run django with runserver on a production
> > system. runserver is just for development purposes, and doesn't do a lot
> of
> > optimization that you get when running it "correctly".
>
> not a lot of optimizations - uh really? I run Django under Win10 and access
> it as a single user only locally - so I use the runserver option, I didn't
> want to install a whole webserver environment - it must only be available
> when I need it so there is no need to run it always whenever the PC is on.
>
> Which optimizations are disabled when using runserver? Is the overall
> performance of all queries and generating the HTML response itself slower?
> I know that only one request is handled in parallel, but that's okay, I'm
> the only one accessing the pages :-)
>
>
The main thing is that when you start runserver it continuesly checks for
changes in your .py files. So if you change a file, you get a reload. This
shouldn't be running on a production environment.
Another thing is that runserver also serves static files - something that
you don't want your application server to do in production - that is better
handled by a webserver.

If only you are looking at the application that isn't a problem, but I
wouldn't allow it to be accessible to the Internet

Regards,

Andréas



> > Best regards,
> >
> > Andréas
>
> Best regards,
>
> Erik
>
> --
> 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/1ec07c78-8d9c-86c1-4918-10da1ccdf90c%40rdsoftware.de.
> 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/CAK4qSCc99ES1DNp%2BH7Le8CwD12i2tRXJXH%3DCpaFQ6Tq4fGu_uw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.11 and PostgreSQL 10 compatibility

2017-10-19 Thread Antonis Christofides
Hello,

It means exactly what it says: 9.3 or higher. "Higher" can mean 9.4, 9.5, 10, 
etc.

Regards,

Antonis

Antonis Christofides
http://djangodeployment.com


On 2017-10-19 11:27, Edandweb wrote:
> Hi,
>
> I am developing a new application in Python and Django, for the database we
> want to use the last version of PostgreSQL v10.
> The django Documentation says in
> https://docs.djangoproject.com/en/1.11/ref/databases/#postgresql-notes:
>
> /Django supports PostgreSQL 9.3 and higher. psycopg2
>  2.5.4 or higher is required, though the latest
> release is recommended.
>
> /I am not sure to understand, it's just 9.3 and higher like 9.3.1 or 9.3.2 or
> 9.3.4 ... or can we use 9.4 and 9.5 ... ?
>
> 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/99f8fa1b-e892-4d72-93e6-afac2f54736b%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.

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


Re: Referencing objects that don't exist that will be created in forms

2017-10-19 Thread Chris Wedgwood
Hi All

Ive overcome it by adding doing this:

def __init__(self, *args, **kwargs):
super(UniversityForm, self).__init__(*args, **kwargs)
self.fields['name'].choices = University.objects.values_list('id', 'name')


This makes sense. Don't reference objects that will be parsed before they 
exist  

On Thursday, 19 October 2017 10:23:36 UTC+1, Chris Wedgwood wrote:
>
> Hi 
>
> I have the following scenario in my forms.py: 
>
> UNIVERSITY_CHOICES = University.objects.values_list('id', 'name') 
>
> class UniversityForm(forms.Form): 
> name = forms.CharField(widget=forms.Select(attrs={"class": 
> "selectpicker", "data-live-search": "true","title": "find 
> university..."},choices=UNIVERSITY_CHOICES), required=False) 
>
> The migration fails as it is expecting the university table to exist 
> but does not yet. 
> This is clearly an anti-pattern on my part. What is the correct way to 
> approach this? 
>
> thanks 
> Chris 
>

-- 
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/d5f6e5d8-d03c-4c80-8fcb-fdc061cfc2e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django 1.11 and PostgreSQL 10 compatibility

2017-10-19 Thread Edandweb
Hi,

I am developing a new application in Python, Django and for the database 
we'll use PostgreSQL.

In the Django documentation, 
https://docs.djangoproject.com/en/1.11/ref/databases/#postgresql-notes :

Django supports PostgreSQL 9.3 and higher. psycopg2 
 2.5.4 or higher is required, though the latest 
release is recommended.

Can we use 9.4 or just 9.3.1 or 9.3.2 ?

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/f904291a-63d4-4a21-a9dd-e28203c58fc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: hello everyone! I'm working on Django Framework. but when I run the script $ ./manage.py runserver or $./manage.py runserver 0.0.0.0:8000 it only work on my system. how to make it public? so that

2017-10-19 Thread Erik Rull
Hello Andréas,

Andréas Kühne wrote:
> 1. First of all, you shouldn't run django with runserver on a production
> system. runserver is just for development purposes, and doesn't do a lot of
> optimization that you get when running it "correctly".

not a lot of optimizations - uh really? I run Django under Win10 and access
it as a single user only locally - so I use the runserver option, I didn't
want to install a whole webserver environment - it must only be available
when I need it so there is no need to run it always whenever the PC is on.

Which optimizations are disabled when using runserver? Is the overall
performance of all queries and generating the HTML response itself slower?
I know that only one request is handled in parallel, but that's okay, I'm
the only one accessing the pages :-)

> Best regards,
> 
> Andréas

Best regards,

Erik

-- 
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/1ec07c78-8d9c-86c1-4918-10da1ccdf90c%40rdsoftware.de.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.5 custom User model error. "Manager isn't available; User has been swapped"

2017-10-19 Thread sarfaraz . a
hey,

I am facing similar issue. You said here is solution I checked. .nothing 
related

On Wednesday, November 28, 2012 at 1:37:39 PM UTC+5:30, bpetit wrote:
>
> Thanks for reply but this solutions doesn't seem to work. I've found a 
> solution that is explained here 
> 
> .
>
> Regards
>
> On Tuesday, November 27, 2012 5:52:09 AM UTC+1, psjinx wrote:
>>
>> Hi, 
>>
>> You need to unregister `User` model from admin site before registering 
>> new one. 
>>
>> admin.site.unregister(User) 
>> admin.site.register(CustomUser, UserAdmin) 
>>
>> Please have a look at http://stackoverflow.com/a/2270704/353550 
>>
>> Pankaj Singh 
>> http://about.me/psjinx 
>>
>>
>> On Mon, Nov 26, 2012 at 9:14 PM, Benoit Petit 
>>  wrote: 
>> > Hi, 
>> > 
>> > I extend the django user model as described in the dev doc. I wan't to 
>> keep 
>> > most of the original User model features so I extend the AbstractUser 
>> class. 
>> > I've defined in settings.py: 
>> > 
>> > AUTH_USER_MODEL = 'myapp.CustomUser' 
>> > 
>> > My user class: 
>> > 
>> > class CustomUser(AbstractUser): 
>> >   custom_field = models.ForeignKey('OtherModel') 
>> >   objects = UserManager() 
>> > 
>> > Everything seems to work fine but when I try to make it managed by the 
>> admin 
>> > site: 
>> > 
>> > admin.site.register(CustomUser, UserAdmin) 
>> > 
>> > I get this error on the admin CustomUser creation page (after 
>> validation of 
>> > the password confirmation form): 
>> > 
>> > AttributeError: Manager isn't available; User has been swapped for 
>> > 'myapp.CustomUser' 
>> > 
>> > The point is that I need this model managed by the admin site in order 
>> to 
>> > have the same creation process as with the original User model (two 
>> step 
>> > process with password validation). 
>> > 
>> > Thanks for any reply 
>> > 
>> > -- 
>> > You received this message because you are subscribed to the Google 
>> Groups 
>> > "Django users" group. 
>> > To view this discussion on the web visit 
>> > https://groups.google.com/d/msg/django-users/-/8VtQghtcMFgJ. 
>> > To post to this group, send email to django...@googlegroups.com. 
>> > To unsubscribe from this group, send email to 
>> > django-users...@googlegroups.com. 
>> > For more options, visit this group at 
>> > http://groups.google.com/group/django-users?hl=en. 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To 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/ffa92f31-776a-4365-922c-3303c5350ea9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Introducing "Django Indonesia" Community

2017-10-19 Thread alzea arafat
Hi there!

I'm Alzea from Indonesia. I would like to introduce Django Indonesia 
community. I built this local community of fans, developers and django 
users, in 2014. And now we have around 2.5k members in facebook, and 
hundred in Slack. It's still relatively small, but we still growing every 
day :)

We also have a simple forum app as community project (just release it 
couple days ago), which you can find the source here : 
https://github.com/django-id/website

We expect support from all of you, django community.

Thank you,
Cheers!

Alzea.

-- 
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/7e85ccb9-54f8-464b-9862-837564af4acc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django 1.11 and PostgreSQL 10 compatibility

2017-10-19 Thread Edandweb
Hi,

I am developing a new application in Python and Django, for the database we 
want to use the last version of PostgreSQL v10.
The django Documentation says in 
https://docs.djangoproject.com/en/1.11/ref/databases/#postgresql-notes:



*Django supports PostgreSQL 9.3 and higher. psycopg2 
 2.5.4 or higher is required, though the latest 
release is recommended.*I am not sure to understand, it's just 9.3 and 
higher like 9.3.1 or 9.3.2 or 9.3.4 ... or can we use 9.4 and 9.5 ... ?

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/99f8fa1b-e892-4d72-93e6-afac2f54736b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Referencing objects that don't exist that will be created in forms

2017-10-19 Thread Chris Wedgwood
Hi

I have the following scenario in my forms.py:

UNIVERSITY_CHOICES = University.objects.values_list('id', 'name')

class UniversityForm(forms.Form):
name = forms.CharField(widget=forms.Select(attrs={"class":
"selectpicker", "data-live-search": "true","title": "find
university..."},choices=UNIVERSITY_CHOICES), required=False)

The migration fails as it is expecting the university table to exist
but does not yet.
This is clearly an anti-pattern on my part. What is the correct way to
approach this?

thanks
Chris

-- 
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/CACQBJYWMPHHnH7fs4ogYerxoT953pyX_K9eeKjgoMjjefXwo8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help with deployment

2017-10-19 Thread sarfaraz ahmed
Yes, I moved to linux all working fine now.

On Saturday, 13 May 2017 00:06:44 UTC+5:30, mohammed ferozkhan wrote:
>
> Hi 
> Problem will solved?? 
> If no ping me on what'sapp +91 8686962047

-- 
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/70ae2e40-6aa4-4118-b3fb-804323f406f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


“Manager isn't available; User has been swapped”

2017-10-19 Thread sarfaraz ahmed
Hello Friends,

I am trying to extend user model to setup email as username. Everything 
works find when I create new user using django admin I get error  “Manager 
isn't available; User has been swapped” when try to create user using 
signup view. 

There is very few articles on this error. Any help would be appreciated. 
Also, the login thing is working perfectly. 

I have defined 


AUTH_USER_MODEL = 'user_management.CustomUser'

AUTHENTICATION_BACKENDS = ('user_management.manager.CustomUserAuth',)


My code is as follows

--
Signup view


def signup(request):

form= CustomUserCreationForm(request.POST or None)

if request.POST and form.is_valid():
print "test2"
form.save(commit=False)
email=form.cleaned_data['email']
password=form.cleaned_data['password1']
CustomUser.objects.create_user(email=email,password=password)
user=CustomUser.objects.get(email=email)
user.is_active=0
user.save()
print email

salt = 
hashlib.sha1(str(random.random())).hexdigest()[:5]
activation_key = hashlib.sha1(salt+email).hexdigest()
key_expires = timezone.datetime.today() + timedelta(days=2)

   

if user:
return HttpResponseRedirect('/signup_success')

return render(request,'user_management/signup.html',{'form':form})



model.py for user_management app 


class CustomUserManager(BaseUserManager):
def _create_user(self,email,password,is_staff,is_superuser, 
**extra_fields):

if not email:
raise ValueError('The given email must be set')

email=self.normalize_email(email)
user= self.model(email=email,
 is_staff=is_staff,
 is_active = True,
 is_superuser =is_superuser,
 last_login=timezone.now(),
 date_joined=timezone.now(),
**extra_fields)
user.set_password(password)
user.save(using=self._db)
return user

def create_user(self, email,password=None,**extra_fields):
return self._create_user(email,password,False,False,**extra_fields)

def create_superuser(self, email,password,**extra_fields):
return self._create_user(email,password,True,True,**extra_fields)

class CustomUser(AbstractBaseUser,PermissionsMixin):
username =models.CharField(max_length =255, unique = True,blank = 
True,null= True)
email =models.EmailField(blank=False, unique =True)
date_joined  = models.DateTimeField(_('date joined'), default=now)
is_active= models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)
is_staff = models.BooleanField(default=False)
is_superuser = models.BooleanField(default=False)
   
USERNAME_FIELD ='email'
REQUIRED_FIELD =['user_name','date_joined']

objects=CustomUserManager()

class Meta:
verbose_name=_('user')
verbose_name_plural=_('users')

def get_absolute_url(self):
return "/user/%s" %urlquote(self.email)

def get_full_name(self):
  
a=UserProfile.objects.get(email_id=self.id)
self.first_name=a.first_name
self.last_name= a.last_name
if not self.first_name and not self.last_name:
full_name =self.email
else:
full_name = '%s %s' %(self.first_name,self.last_name)
return full_name.strip()

def get_short_name(self):
self.first_name='a'
return self.first_name

def email_user(self,subject,message,from_email=None):
send_mail(subject,message,from_email,[self.email])


#code
-
manager.py
-


from models import CustomUser
from models import CustomUserManager

class CustomUserAuth(object):

def authenticate(self, username = None, password =None):
try:
user =CustomUser.objects.get(email=username)
if user.check_password(password):
return user
except CustomUser.DoesNotExist:
return None

def get_user(self, user_id):
try:
user=CustomUser.objects.get(pk=user_id)
if user.is_active:
return user
return None
except CustomUser.DoesNotExist:
return None
 
 

Re: AttributeError When Overwritting AUTH_USER_MODEL in Test Cases

2017-10-19 Thread sarfaraz ahmed
I am getting similar issue. No reply on your question. Please share the 
solution if you found


On Monday, 8 February 2016 19:50:07 UTC+5:30, Aubrey Stark-Toller wrote:
>
> Hello, 
>
> When I override the AUTH_USER_MODEL setting to "auth.User",  when 
> AUTH_USER_MODEL in settings is not set to "auth.User", in 
> either a TestCase or individual test, and then try to access the objects 
> attribute on the user model, I get an AttributeError. 
>
> The exact error I get is: 
> AttributeError: Manager isn't available; 'auth.User' has been swapped 
> for 'None' 
>
> I've found this to be the case in both Django 1.8 and 1.9. 
>
> This is easily reproducible in a fresh project : create a boilerplate 
> project with a boilerplate app, add a new user model (call it 
> CustomUser) to the app and set to AUTH_USER_MODEL to CustomUser, and add 
> the following test case to the app: 
>
> > from django.test import TestCase, override_settings 
> > from django.contrib.auth import get_user_model 
> > 
> > class MyTestCase(TestCase): 
> >@override_settings(AUTH_USER_MODEL = 'auth.User') 
> >def test_custom_user(self): 
> >UserModel = get_user_model() 
> >UserModel.objects.all() 
>
> get_user_model() retrieves the correct model but accessing objects 
> attribute gives the stated error when running the test. 
>
> If I throw in another user model (say CustomerUser2) and write a test 
> such as: 
>
> >@override_settings(AUTH_USER_MODEL = 'another_app.CustomerUser2') 
> >def test_custom_user(self): 
> >UserModel = get_user_model() 
> >UserModel.objects.all() 
>
> this works fine, and if I unset AUTH_USER_MODEL in settings again 
> everything works as expected. 
>
> Perhaps someone can shed some light on this behavior? 
>
> Cheers, 
> Aubrey 
>

-- 
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/20fc529a-8452-40f6-8a6e-e8a11cdc2bd1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.