Survey About Package Requirements Management

2016-10-18 Thread Robert Roskam
Hey all,  

To clarify my title quickly, this survey is not about replacing pip, as 
yarn (https://github.com/yarnpkg/yarn) did recently with npm. This is about 
helping you throughout the lifespan of projects you maintain keep a handle 
on the dependencies it has. Where I work, we've already made something 
internally, and we're trying to figure out how useful this is to other 
people. So if you could fill out this survey 
(https://docs.google.com/forms/d/e/1FAIpQLSfuXl-UCIJ4PEyQCAWLBB1zPG3Ay86lOxBblV5YJCiFVldFGg/viewform?c=0=1),
 
it would help us gauge interest. Thanks all!

-- 
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/def18f7f-1a09-418c-8763-e6af23d8b59d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django and uuid with PostgreSQL

2016-10-18 Thread Tim Graham
The SQL looks correct -- it's not using anything Python related. Are you 
encountering some error?

On Tuesday, October 18, 2016 at 9:15:46 AM UTC-4, Andrea Posi wrote:
>
> I'm creating a rest api using Django and DRF. I don't want to expose IDs 
> directly to clients so I'm trying to setup my models like this example:
>
> class AbstractGuidModel(models.Model):
> uuid = models.UUIDField(blank=True, default=uuid.uuid4, unique=True, 
> editable=False)
>
> class Meta:
> abstract = True
>
> class MyModel(AbstractGuidModel):
> name = models.CharField(max_length=NAME_LENGTH)
>
> Since the AbstractGuidModel has default=uuid.uuid4, uuid are generated by 
> python code and migrations look like:
>
> CREATE TABLE "MyModel" ( ... "uuid" uuid NOT NULL UNIQUE, ... );
>
> I've read Postgres has an extension for generating automatically uuids.
>
> Once extension is installed, how can I tell django to let database use his 
> own extension and not letting him create them with the Python uuid module?
>

-- 
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/29af39fa-b457-49c0-95d3-79bf70d95813%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Migrations for multiple Django versions

2016-10-18 Thread Tim Graham
Assuming the problem is makemigrations generating different migrations 
based on the Django version, conditionally adding operations in migrations 
with some django.VERSION checks may help.

On Tuesday, October 18, 2016 at 7:12:02 AM UTC-4, Vlastimil Zíma wrote:
>
> Hi everyone,
>
> we are trying in our application to support multiple Django versions, 
> specifically 1.7 to 1.9. But we encountered a problem with 
> `User.last_login` field. We use custom User model based on 
> `AbstractBaseUser` as specified by the documentation. Everything was fine 
> in Django 1.7, but we got stuck when we wanted to add support for Django 
> 1.8, where the `last_login` was modified to allow NULL values. As 
> recommended by 
> https://docs.djangoproject.com/en/1.10/topics/migrations/#supporting-multiple-django-versions
>  
> we have migrations generated in Django 1.7 (lowest supported version) an 
> thus `last_login` is NOT NULL, but that causes tests to fail when run in 
> Django 1.8/1.9, since code allows `last_login` to be NULL.
>
> We can't even redefine the field in our model, which would be the most 
> straight forward solution, but that's not allowed by Django either.
>
> What's the correct solution for this problem? It looks to us like there 
> are some unresolved issues regarding the model and migrations design.
>
> Thanks for any suggestions
> Vlastimil
>

-- 
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/75892077-4a6f-4df3-a846-1f8f810fdb2d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Tutorial part 3 help: bulleted-list

2016-10-18 Thread Johnny McClung
Thanks so much everyone. I looked over those files many times and I 
couldn't see it. 



On Tuesday, October 18, 2016 at 5:17:55 PM UTC-4, James Schneider wrote:
>
>
>
> On Tue, Oct 18, 2016 at 11:00 AM, Johnny McClung  > wrote:
>
>> I have gotten down to the part where the tutorial reads "Load the page by 
>> pointing your browser at “/polls/”, and you should see a bulleted-list 
>> containing the “What’s up” question from Tutorial 2. The link points to the 
>> question’s detail page."
>>
>> I do not see a bulleted-list. All I see is "No polls are available."
>>
>> This makes me think that I have an error in the if statement in the 
>> template index.html. However, I can not find the error or why it is not 
>> showing me the list. Any help would be appreciated. 
>>
>
> The {% if %} statement is fine. 
>
>  
>
>> mysite>>polls>>templates>>polls>>index.html
>>
>> {% if latest_question_list %}
>> 
>> {% for quesion in latest_question_list %}
>>
>
> You do have a typo in your {% for %} loop, however.
>
>
>
>  
>
>> def index(request):
>> latest_question_list = Question.objects.order_by('-pub_date')[:5]
>> template = loader.get_template('polls/index.html')
>> context = {'latest_quesion_list': latest_question_list,}
>> return HttpResponse(template.render(context, request))
>>
>>
> This is where your issue is. Your template context dictionary also has the 
> same typo as  your  {% for %} loop, so the {% if %} statement is returning 
> False because the variable it is checking (which is spelled correctly) 
> doesn't exist.
>
> -James
>

-- 
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/23054cef-e165-48b6-b75d-87c8dd81830b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Tutorial part 3 help: bulleted-list

2016-10-18 Thread James Schneider
On Tue, Oct 18, 2016 at 11:00 AM, Johnny McClung 
wrote:

> I have gotten down to the part where the tutorial reads "Load the page by
> pointing your browser at “/polls/”, and you should see a bulleted-list
> containing the “What’s up” question from Tutorial 2. The link points to the
> question’s detail page."
>
> I do not see a bulleted-list. All I see is "No polls are available."
>
> This makes me think that I have an error in the if statement in the
> template index.html. However, I can not find the error or why it is not
> showing me the list. Any help would be appreciated.
>

The {% if %} statement is fine.



> mysite>>polls>>templates>>polls>>index.html
>
> {% if latest_question_list %}
> 
> {% for quesion in latest_question_list %}
>

You do have a typo in your {% for %} loop, however.





> def index(request):
> latest_question_list = Question.objects.order_by('-pub_date')[:5]
> template = loader.get_template('polls/index.html')
> context = {'latest_quesion_list': latest_question_list,}
> return HttpResponse(template.render(context, request))
>
>
This is where your issue is. Your template context dictionary also has the
same typo as  your  {% for %} loop, so the {% if %} statement is returning
False because the variable it is checking (which is spelled correctly)
doesn't exist.

-James

-- 
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/CA%2Be%2BciV7HOuTkw5Azqoh%2BQmOHoHf%2Bbo1vvRMdfwf0jp2Hk-29w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Compiling/packing Django to one binary

2016-10-18 Thread Asad Jibran Ahmed
Hi,
 While I haven't personally dealt with such a situation with my Django
code, I have worked with people who had this issue (un-deterministic
production servers). They used Docker to solve this issue. Essentially
you're looking for deterministic deploys, and Docker is the first thing
that jumps to my mind for something like this.

Is that a possibility that you can consider? If not, then I'm sure there
will be better answers to your question from other people in this group.
Regards,

Asad Jibran Ahmed 
http://blog.asadjb.com

On Tue, Oct 18, 2016 at 10:45 PM, Александр Христюхин 
wrote:

> Hi!
>
>
> I would like to ask community about methods of shipping Django in
> production.
>
>
> I do have some limitations, one of which is I don't know what packages are
> installed on production server (for example, postgres dev libraries or
> specific version of python).
>
>
> Right now my method is to create venv with specific version of Python,
> make venv relocatable, copy missing libraries into venv/lib, pack it into
> archive and ship to production servers.
>
>
> On application launch server has to unpack archive and run it somewhat
> like that:
>
>> $ LD_LIBRARY_PATH=venv/lib venv/bin/python venv/bin/gunicorn -c
>> gunicorn.conf myapp.wsgi:application
>
>
> In my case LD_LIBRARY_PATH is required for libpython and libpq (PostgreSQL
> query library).
>
>
> This does work, but I have to go through a lot of stuff.
>
>
> What I want to do is pack my application with specific python and
> libraries into one binary (on build server) and only ship this binary to
> production server. So application launch will look somewhat like that:
>
>> $ my-awesome-python-bin gunicorn -c gunicorn.conf myapp.wsgi:application
>
>
> Or if I could go even further and describe some startup logic:
>
>>
>> def startup():
>> ...
>> args = argparser.parse()
>> config = args.config
>> gunicorn.server(config, myapp.wsgi, 'application').run()
>
> ...and then:
>
>> $ my-awesome-bin -c myapp.conf
>
>
> Is there any way of doing that?
>
> Or could you suggest any easier (well, more convenient) way of shipping
> Django?
>
>
> I did ask practically the same question on StackOverflow
> 
>  couple
> weeks ago, but none of given answers provide simple solution for my
> problem. I've tried nuitka, pyinstalled and cx_freeze with no success.
>
> --
> 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/51a3ef5f-800a-48db-9697-03d069238834%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/CA%2BYYaWcYQRQARWWVarMuvFnMnrQBkuiv03J3w12hp6F%2ByPVL_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Compiling/packing Django to one binary

2016-10-18 Thread Александр Христюхин
 

Hi!


I would like to ask community about methods of shipping Django in 
production.


I do have some limitations, one of which is I don't know what packages are 
installed on production server (for example, postgres dev libraries or 
specific version of python).


Right now my method is to create venv with specific version of Python, make 
venv relocatable, copy missing libraries into venv/lib, pack it into 
archive and ship to production servers.


On application launch server has to unpack archive and run it somewhat like 
that:

> $ LD_LIBRARY_PATH=venv/lib venv/bin/python venv/bin/gunicorn -c 
> gunicorn.conf myapp.wsgi:application


In my case LD_LIBRARY_PATH is required for libpython and libpq (PostgreSQL 
query library).


This does work, but I have to go through a lot of stuff.


What I want to do is pack my application with specific python and libraries 
into one binary (on build server) and only ship this binary to production 
server. So application launch will look somewhat like that:

> $ my-awesome-python-bin gunicorn -c gunicorn.conf myapp.wsgi:application


Or if I could go even further and describe some startup logic:

>
> def startup():
> ...
> args = argparser.parse()
> config = args.config
> gunicorn.server(config, myapp.wsgi, 'application').run()

...and then:

> $ my-awesome-bin -c myapp.conf


Is there any way of doing that?

Or could you suggest any easier (well, more convenient) way of shipping 
Django?


I did ask practically the same question on StackOverflow 

 couple 
weeks ago, but none of given answers provide simple solution for my 
problem. I've tried nuitka, pyinstalled and cx_freeze with no success.

-- 
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/51a3ef5f-800a-48db-9697-03d069238834%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Tutorial part 3 help: bulleted-list

2016-10-18 Thread Vineet Kothari
NYC

On Oct 19, 2016 12:57 AM, "Vijay Khemlani"  wrote:

> You wrote "latest_quesion_list" in the context dictionary key, it should
> be "latest_question_list"
>
> On Tue, Oct 18, 2016 at 3:00 PM, Johnny McClung 
> wrote:
>
>> I have gotten down to the part where the tutorial reads "Load the page by
>> pointing your browser at “/polls/”, and you should see a bulleted-list
>> containing the “What’s up” question from Tutorial 2. The link points to the
>> question’s detail page."
>>
>> I do not see a bulleted-list. All I see is "No polls are available."
>>
>> This makes me think that I have an error in the if statement in the
>> template index.html. However, I can not find the error or why it is not
>> showing me the list. Any help would be appreciated.
>>
>> mysite>>polls>>templates>>polls>>index.html
>>
>> {% if latest_question_list %}
>> 
>> {% for quesion in latest_question_list %}
>> {{ question.question_text
>> }}
>> {% endfor %}
>> 
>> {% else %}
>> No polls are available.
>> {% endif %}
>>
>>
>> mysite>>polls>>urls.py
>> from django.conf.urls import url
>>
>>
>> from . import views
>>
>> urlpatterns = [
>> url(r'^$', views.index, name='index'),
>> url(r'^(?P[0-9]+)/$', views.detail, name='detail'),
>> url(r'^(?P[0-9]+)/results/$', views.results,
>> name='results'),
>> url(r'^(?P[0-9]+)/vote/$', views.vote, name='vote'),
>> ]
>>
>>
>> .
>> mysite>>polls>>views.py
>> from django.shortcuts import render
>>
>> # Create your views here.
>> from django.http import HttpResponse
>> from django.template import loader
>>
>> from .models import Question
>>
>> def index(request):
>> latest_question_list = Question.objects.order_by('-pub_date')[:5]
>> template = loader.get_template('polls/index.html')
>> context = {'latest_quesion_list': latest_question_list,}
>> return HttpResponse(template.render(context, request))
>>
>>
>> def detail(request, question_id):
>> return HttpResponse("You're looking at question %s." % question_id)
>>
>> def results(request, question_id):
>> response = "You're looking at the results of question %s."
>> return HttpResonse(response % question_id)
>>
>> def vote(request, question_id):
>> return HttpResponse("You're voting on question %s." % question_id)
>>
>> --
>> 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/ms
>> gid/django-users/f0899689-fb34-4728-8ec6-7bfc661c348c%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/CALn3ei3LO9jqt5q7hAycoK5q1iUzt
> jzHQdKrdtmZ%3Dg2VEg6%2B1A%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Tutorial part 3 help: bulleted-list

2016-10-18 Thread Vijay Khemlani
You wrote "latest_quesion_list" in the context dictionary key, it should be
"latest_question_list"

On Tue, Oct 18, 2016 at 3:00 PM, Johnny McClung  wrote:

> I have gotten down to the part where the tutorial reads "Load the page by
> pointing your browser at “/polls/”, and you should see a bulleted-list
> containing the “What’s up” question from Tutorial 2. The link points to the
> question’s detail page."
>
> I do not see a bulleted-list. All I see is "No polls are available."
>
> This makes me think that I have an error in the if statement in the
> template index.html. However, I can not find the error or why it is not
> showing me the list. Any help would be appreciated.
>
> mysite>>polls>>templates>>polls>>index.html
>
> {% if latest_question_list %}
> 
> {% for quesion in latest_question_list %}
> {{ question.question_text
> }}
> {% endfor %}
> 
> {% else %}
> No polls are available.
> {% endif %}
>
>
> mysite>>polls>>urls.py
> from django.conf.urls import url
>
>
> from . import views
>
> urlpatterns = [
> url(r'^$', views.index, name='index'),
> url(r'^(?P[0-9]+)/$', views.detail, name='detail'),
> url(r'^(?P[0-9]+)/results/$', views.results,
> name='results'),
> url(r'^(?P[0-9]+)/vote/$', views.vote, name='vote'),
> ]
>
>
> .
> mysite>>polls>>views.py
> from django.shortcuts import render
>
> # Create your views here.
> from django.http import HttpResponse
> from django.template import loader
>
> from .models import Question
>
> def index(request):
> latest_question_list = Question.objects.order_by('-pub_date')[:5]
> template = loader.get_template('polls/index.html')
> context = {'latest_quesion_list': latest_question_list,}
> return HttpResponse(template.render(context, request))
>
>
> def detail(request, question_id):
> return HttpResponse("You're looking at question %s." % question_id)
>
> def results(request, question_id):
> response = "You're looking at the results of question %s."
> return HttpResonse(response % question_id)
>
> def vote(request, question_id):
> return HttpResponse("You're voting on question %s." % question_id)
>
> --
> 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/f0899689-fb34-4728-8ec6-7bfc661c348c%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/CALn3ei3LO9jqt5q7hAycoK5q1iUztjzHQdKrdtmZ%3Dg2VEg6%2B1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Tutorial part 3 help: bulleted-list

2016-10-18 Thread Johnny McClung
I have gotten down to the part where the tutorial reads "Load the page by 
pointing your browser at “/polls/”, and you should see a bulleted-list 
containing the “What’s up” question from Tutorial 2. The link points to the 
question’s detail page."

I do not see a bulleted-list. All I see is "No polls are available."

This makes me think that I have an error in the if statement in the 
template index.html. However, I can not find the error or why it is not 
showing me the list. Any help would be appreciated. 

mysite>>polls>>templates>>polls>>index.html

{% if latest_question_list %}

{% for quesion in latest_question_list %}
{{ question.question_text 
}}
{% endfor %}

{% else %}
No polls are available.
{% endif %}


mysite>>polls>>urls.py
from django.conf.urls import url


from . import views

urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^(?P[0-9]+)/$', views.detail, name='detail'),
url(r'^(?P[0-9]+)/results/$', views.results, 
name='results'),
url(r'^(?P[0-9]+)/vote/$', views.vote, name='vote'),
]


.
mysite>>polls>>views.py
from django.shortcuts import render

# Create your views here.
from django.http import HttpResponse
from django.template import loader

from .models import Question

def index(request):
latest_question_list = Question.objects.order_by('-pub_date')[:5]
template = loader.get_template('polls/index.html')
context = {'latest_quesion_list': latest_question_list,}
return HttpResponse(template.render(context, request))


def detail(request, question_id):
return HttpResponse("You're looking at question %s." % question_id)

def results(request, question_id):
response = "You're looking at the results of question %s."
return HttpResonse(response % question_id)

def vote(request, question_id):
return HttpResponse("You're voting on question %s." % question_id)

-- 
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/f0899689-fb34-4728-8ec6-7bfc661c348c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Slow first request django

2016-10-18 Thread 'Tom Evans' via Django users
On Fri, Oct 14, 2016 at 5:15 AM, Avraham Serour  wrote:
> I will take a wild guess here and say that this is a modwsgi problem, it
> seems it will only load the django app after the first request.

Indeed, see this SO post for how to tell it to load your app
immediately on start up:

http://stackoverflow.com/questions/1702562/speeding-up-the-first-page-load-in-django

(EasyReader: Add "WSGIImportScript" directive)

>
> Honestly I suggest you to use nginx with uwsgi, the killer feature is that
> it is not apache, I ran with so many bumps with apache that I turned to
> nginx and never looked back.
>
> Also the config files are sane and will not drive you crazy.

Apache is an excellent webserver, particularly Apache 2.4. It has the
largest installed base and ecosystem of third party support and
packages, and can be configured to serve both the smallest and the
largest sites without any bothers. If you are already using apache and
happy with it (bar this issue), you will only waste time (and perhaps
get different issues) by switching to a different webserver.

To not get into a vim/emacs style situation, nginx/uwsgi is also
excellent; the choice of what webserver used is largely irrelevant to
how real django based sites (that actually do things) will perform.

Cheers

Tom

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


Form input: "unlimited list," what does the backend look like?

2016-10-18 Thread Andrew Emory
I want to get user data where is use a ChoiceSelect field.  And if the user 
selects an option another one pops up giving them the same choices again.

I understand that I would do this with JavaScript on the front end.  But, it is 
unclear to me what kind of architecture and model fields I should use on the 
back end.

Let's say I have a main model w/ which I am using ModelFirms.  Would I create a 
separate model with a many to one relationship to my main model?

If not what is best way to achieve what I am trying to do?

Thanks for your thoughts.

-- 
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/8c62202f-7952-431c-8cb9-22f6d0d1837d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django and uuid with PostgreSQL

2016-10-18 Thread Andrea Posi
I'm creating a rest api using Django and DRF. I don't want to expose IDs 
directly to clients so I'm trying to setup my models like this example:

class AbstractGuidModel(models.Model):
uuid = models.UUIDField(blank=True, default=uuid.uuid4, unique=True, 
editable=False)

class Meta:
abstract = True

class MyModel(AbstractGuidModel):
name = models.CharField(max_length=NAME_LENGTH)

Since the AbstractGuidModel has default=uuid.uuid4, uuid are generated by 
python code and migrations look like:

CREATE TABLE "MyModel" ( ... "uuid" uuid NOT NULL UNIQUE, ... );

I've read Postgres has an extension for generating automatically uuids.

Once extension is installed, how can I tell django to let database use his 
own extension and not letting him create them with the Python uuid module?

-- 
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/03ace98f-7bf3-4147-8ca4-17e5f6cf6f5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Migrations for multiple Django versions

2016-10-18 Thread Vlastimil Zíma
Hi everyone,

we are trying in our application to support multiple Django versions, 
specifically 1.7 to 1.9. But we encountered a problem with 
`User.last_login` field. We use custom User model based on 
`AbstractBaseUser` as specified by the documentation. Everything was fine 
in Django 1.7, but we got stuck when we wanted to add support for Django 
1.8, where the `last_login` was modified to allow NULL values. As 
recommended by 
https://docs.djangoproject.com/en/1.10/topics/migrations/#supporting-multiple-django-versions
 
we have migrations generated in Django 1.7 (lowest supported version) an 
thus `last_login` is NOT NULL, but that causes tests to fail when run in 
Django 1.8/1.9, since code allows `last_login` to be NULL.

We can't even redefine the field in our model, which would be the most 
straight forward solution, but that's not allowed by Django either.

What's the correct solution for this problem? It looks to us like there are 
some unresolved issues regarding the model and migrations design.

Thanks for any suggestions
Vlastimil

-- 
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/cb797b9c-9b7e-47f3-85ca-3c9fedef6c9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.