Django module for a tag input field on a user form, with autocomplete & automatic adding new tags?

2017-02-25 Thread Mark London


I want to have a django form that has a field that allows inputting tags, 
with autocomplete functionality, and the ability to automatically add new 
tags. I was using django-tagulous for this, until I discovered that pasting 
a series of 3 or more comma delimited strings, would cause the browser to 
hang.


I have looked at the alternatives, but either they are mainly designed to 
be used by the admin module, or the documentation for implementation is 
very sparse, without a real hardcoded demo, which is included with the 
tagulous package. Can anyone help me out? Thanks very much!


Mark London

-- 
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/f01d0fab-7368-4994-bbc6-be5e830f8262%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


group by 3 fields

2017-02-25 Thread Larry Martell
I have a query set and I need to do the SQL equivalent of

GROUP BY col1, col2, col3

I have read many SO posts about using aggregate and count but I have
not been able to get this to work using 3 columns. Anyone know how to
do this?

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


Re: Subquery has too many columns

2017-02-25 Thread eltonplima
For me it's realy a bug.

I need to report them?

On Tuesday, February 21, 2017 at 11:55:16 PM UTC-3, eltonplima wrote:
>
> I tried many things, only work if I remove the annotate or 
> remove base_manager_name. But I need both!
>
> The save method is not the problem, I removed.
>
> If the last code I posted work, then, my production code works.
>
> PS: Sorry if my English is not very good, I'm trying to improve it.
>
> On Tuesday, February 21, 2017 at 10:16:04 PM UTC-3, Melvyn Sopacua wrote:
>>
>> While the testcase is simple, it is not the simplest test :)
>>
>>  
>>
>> Two things come to mind:
>>
>>1. If you get rid of the Sum(), does it work then? 
>>2. Saving the model with the base_manager_name should not use that 
>>manager as related manager. It is only used when a model with a foreign 
>> key 
>>to ProdutoServico is saved.
>>
>> In your original exception, it looks like ProdutoServico extends a model 
>> in sumario.models and both override the save method:
>>
>>  
>>
>> /home/eltonplima/ssd/repository/planonegocios/marketing/models.py in save
>>
>>super().save(*args, **kwargs) ...
>>
>> ▶ Local vars
>>
>> /home/eltonplima/ssd/repository/planonegocios/sumario/models.py in save
>>
>>super().save(*args, **kwargs) ...
>>
>>  
>>
>> Is it possible your problem is in one of those two?
>>
>>  
>>
>> On Tuesday 21 February 2017 16:37:12 eltonplima wrote:
>>
>> > This is part of my real code but demonstrate the issue in pratice:
>>
>> > 
>>
>> > from django.db import models
>>
>> > 
>>
>> > class ProdutoServicoManager(models.Manager):
>>
>> > def get_queryset(self):
>>
>> > custo_unitario = models.F('custounitario__valor')
>>
>> > quantidade = models.F('custounitario__quantidade')
>>
>> > expression = models.Sum(custo_unitario * quantidade)
>>
>> > custo_producao_expr = models.ExpressionWrapper(expression,
>>
>> > 
>>
>> > output_field=models.DecimalField())
>>
>> > return
>>
>> > super().get_queryset().annotate(custo_producao=custo_producao_expr)
>>
>> > 
>>
>> > 
>>
>> > class ProdutoServico(models.Model):
>>
>> > produto = models.BooleanField(default=True)
>>
>> > descricao = models.TextField()
>>
>> > objects = ProdutoServicoManager()
>>
>> > 
>>
>> > class Meta:
>>
>> > #
>>
>> > # Comment the line below and the test pass.
>>
>> > #
>>
>> > base_manager_name = 'objects'
>>
>> > 
>>
>> > 
>>
>> > class CustoUnitario(models.Model):
>>
>> > produto_servico = models.ForeignKey(ProdutoServico)
>>
>> > item = models.CharField(max_length=128)
>>
>> > quantidade = models.PositiveIntegerField()
>>
>> > valor = models.DecimalField(max_digits=10,
>>
>> > decimal_places=4,
>>
>> > verbose_name='Valor unitário')
>>
>> > 
>>
>> > 
>>
>> > class Faturamento(models.Model):
>>
>> > produto_servico = models.OneToOneField(ProdutoServico)
>>
>> > quantidade = models.PositiveIntegerField()
>>
>> > preco_unitario = models.DecimalField(max_digits=10,
>>
>> > decimal_places=2)
>>
>> > 
>>
>> > # We need only a single simple test to demonstrate this issue.
>>
>> > 
>>
>> > from django.test import TestCase
>>
>> > from django.db import utils
>>
>> > 
>>
>> > from model_mommy import mommy
>>
>> > 
>>
>> > from core import models
>>
>> > 
>>
>> > class FaturamentoTest(TestCase):
>>
>> > 
>>
>> > def test(self):
>>
>> > faturamento = mommy.make(models.Faturamento)
>>
>> > produto = faturamento.produto_servico
>>
>> > try:
>>
>> > produto.save()
>>
>> > except utils.OperationalError:
>>
>> > self.fail("Whats wrong?")
>>
>> > 
>>
>> > On Tuesday, February 21, 2017 at 9:01:50 AM UTC-3, Melvyn Sopacua wrote:
>>
>> > > On Monday 20 February 2017 17:09:40 eltonplima wrote:
>>
>> > > > Base class is abstract.
>>
>> > > > 
>>
>> > > > 
>>
>> > > > 
>>
>> > > > class Base(models.Model):
>>
>> > > > 
>>
>> > > > plano = models.ForeignKey(Plano)
>>
>> > > > 
>>
>> > > > 
>>
>> > > > 
>>
>> > > > 
>>
>> > > > 
>>
>> > > > class Meta:
>>
>> > > > 
>>
>> > > > abstract = True
>>
>> > > > 
>>
>> > > > 
>>
>> > > > 
>>
>> > > > 
>>
>> > > > 
>>
>> > > > base_manager_name
>>
>> > > > 
>>
>> > > > >
>> > > > anag
>>
>> > > > 
>>
>> > > > er-name>
>>
>> > > 
>>
>> > > Ack, my brain kept reading "default_manager_name".
>>
>> > > 
>>
>> > > Still - without a ForeignKey this shouldn't break anything. It seems
>>
>> > > it warrents a new bug report, but I'm curious where things break.
>>
>> > > It looks like this model is used as an inline in the admin. Is that
>>
>> > > correct?
>>
>> > > 
>>
>> > > 
>>
>> > > 
>>
>> > > I cannot reproduce this with a simple test case:
>>
>> > > 
>>
>> > > 
>>
>> > > 
>>
>> > > models:
>>
>> > > 
>>
>> > > class CartEntryManager(models.Manager):
>>
>> > > def get_queryset(self):
>>
>> > > qs = super(CartEntryManager, self).get_queryset()
>>
>> > > expression = models.F('quantity') * models.F('price')
>>
>> > > wrapped = 

Re: "TemplateDoesNotExist at /"

2017-02-25 Thread Michal Petrucha
On Sat, Feb 25, 2017 at 01:20:49PM -0800, Richard Belew wrote:
> "TemplateDoesNotExist at /"
> 
> (full trace log at http://dpaste.com/3XZ8H3C)
> 
> this must be near the top of django newby issues, but i'm stumped
> on the simplest example i can generate:
> 
> i've used the `settings.TEMPLATES.DIRS` variable to specify a
> shared templates directory (also to simplify things), and
> am using an application's `views.py` file to anchor a
> named url, but the django engine still cannot find the `index.html` file
> i've put there.
> 
> what am i missing?  any hints appreciated,  Rik

[...]

>TEMPLATES = [
> {
> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
> 
> 'DIRS': [ ( os.path.join(BASE_DIR, 'templates'), ) ],

This appears to be the incorrect line – here, you set 'DIRS' to a list
containing a single item, which is a tuple containing a path. The
problem is that you wrap the path twice. Django only expects a simple
list of paths, so if you just drop the tuple wrapping the path, you
should be fine::

'DIRS': [os.path.join(BASE_DIR, 'templates')],

> * djggApp/views.py
> 
>def index(request):
> template = loader.get_template('index.html')
> context = Context({})
> return HttpResponse(template.render(context))

This is not strictly related to your problem, but I would strongly
advise not to render templates used as HTTP responses in this way.
Instead, you should be using either the render shortcut [1], or
TemplateResponse [2]. They are mostly equivalent, and both accomplish
the same thing as the above code, only with a single function call.
More often than not, less code is better.

Also, unlike TemplateResponse and render, the code above will not
apply context processors, unless you change that Context to a
RequestContext, which is something that's super easy to forget, and
I've actually seen people get bitten by that in the past, and spend a
lot of time trying to figure out why their templates are not behaving.

Cheers,

Michal

[1]: https://docs.djangoproject.com/en/1.10/topics/http/shortcuts/#render
[2]: 
https://docs.djangoproject.com/en/1.10/ref/template-response/#templateresponse-objects

-- 
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/20170225222908.GW23772%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: "TemplateDoesNotExist at /"

2017-02-25 Thread Richard Belew
wow, very good and thank you!it was this mal-formed line:

 
   'DIRS': [ ( os.path.join(BASE_DIR, 'templates'), ) ],


which should have been:

'DIRS': [ os.path.join(BASE_DIR, 'templates'),  ],

i had an extra set of parentheses, for whatever bad reason.  thanks again!

On Saturday, February 25, 2017 at 2:08:21 PM UTC-8, ludovic coues wrote:
>
> yep, look like your settings are wrong 
> try to add that at the end of your settings.py and watch the console 
> you are using to launch django 
>
> print(TEMPLATES["DIRS"]) 
> print(BASE_DIR) 
>
> 2017-02-25 23:05 GMT+01:00 Richard Belew : 
>
> > another possibly relevant bit:  the Template-loader postmortem shows: 
> > 
> >> Django tried loading these templates, in this order: 
> >> 
> >> Using engine django: 
> >> 
> >> django.template.loaders.filesystem.Loader: 
> >> 
> /Data/virtualenv/django/djggProj/('/Data/virtualenv/django/djggProj/templates',)/index.html
>  
>
> >> (Source does not exist) 
> > 
> > 
> > this error message has a badly formed path 
> > 
> "/Data/virtualenv/django/djggProj/('/Data/virtualenv/django/djggProj/templates',)/index.html"
>  
>
> > ; should i care? 
> > 
> > -- 
> > 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/8fbefe48-945d-4f4a-9629-d8e59dfd23af%40googlegroups.com.
>  
>
> > 
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
> -- 
>
> Cordialement, Coues Ludovic 
> +336 148 743 42 
>

-- 
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/0208c448-b9e6-42ef-a460-628ba036a972%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: "TemplateDoesNotExist at /"

2017-02-25 Thread ludovic coues
yep, look like your settings are wrong
try to add that at the end of your settings.py and watch the console
you are using to launch django

print(TEMPLATES["DIRS"])
print(BASE_DIR)

2017-02-25 23:05 GMT+01:00 Richard Belew :
> another possibly relevant bit:  the Template-loader postmortem shows:
>
>> Django tried loading these templates, in this order:
>>
>> Using engine django:
>>
>> django.template.loaders.filesystem.Loader:
>> /Data/virtualenv/django/djggProj/('/Data/virtualenv/django/djggProj/templates',)/index.html
>> (Source does not exist)
>
>
> this error message has a badly formed path
> "/Data/virtualenv/django/djggProj/('/Data/virtualenv/django/djggProj/templates',)/index.html"
> ; should i care?
>
> --
> 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/8fbefe48-945d-4f4a-9629-d8e59dfd23af%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

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


Re: "TemplateDoesNotExist at /"

2017-02-25 Thread Richard Belew
another possibly relevant bit:  the Template-loader postmortem shows:

Django tried loading these templates, in this order:
>
> Using engine django:
>
>- django.template.loaders.filesystem.Loader: 
>
> /Data/virtualenv/django/djggProj/('/Data/virtualenv/django/djggProj/templates',)/index.html
>  
>(Source does not exist)
>
>
this error message has a badly formed path 
"/Data/virtualenv/django/djggProj/('/Data/virtualenv/django/djggProj/templates',)/index.html"
 
; should i care?

-- 
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/8fbefe48-945d-4f4a-9629-d8e59dfd23af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


"TemplateDoesNotExist at /"

2017-02-25 Thread Richard Belew
"TemplateDoesNotExist at /"

(full trace log at http://dpaste.com/3XZ8H3C)

this must be near the top of django newby issues, but i'm stumped
on the simplest example i can generate:

i've used the `settings.TEMPLATES.DIRS` variable to specify a
shared templates directory (also to simplify things), and
am using an application's `views.py` file to anchor a
named url, but the django engine still cannot find the `index.html` file
i've put there.

what am i missing?  any hints appreciated,  Rik

.
├── db.sqlite3
├── djggApp
│   ├── __init__.py
│   ├── __init__.pyc
...
│   ├── views.py
│   └── views.pyc
├── djggProj
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── settings.py
│   ├── settings.pyc
│   ├── urls.py
│   ├── urls.pyc
│   ├── wsgi.py
│   └── wsgi.pyc
├── manage.py
└── templates
...
├── index.html 
* djggProj/settings.py:
 
   TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',

'DIRS': [ ( os.path.join(BASE_DIR, 'templates'), ) ],

# 'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]


* djggProj/urls.py

  
  from djggApp import views

urlpatterns = [
url(r'^$', views.index, name='index'),
...
url(r'^admin/', admin.site.urls),
]


* djggApp/views.py

   def index(request):
template = loader.get_template('index.html')
context = Context({})
return HttpResponse(template.render(context))




-- 
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/9adb4f23-8382-4313-9873-aa13c30a06a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Template packages for simple data entry and table data management for business applications

2017-02-25 Thread Melvyn Sopacua
On Friday 24 February 2017 01:15:12 Kai Fisch wrote:

> Is there any widget/template set i can download and create web-based
> applications by simply instantiating templates/widgets for my model
> elements? I realy like the admin site but I came across some postings
> saying that this is a bad idea.

Apply basic "the internet always knows best" filtering:
- Discard any without reason
- Discard any for which the reason does not apply
- Weigh pro's and cons of reasons that do apply

> But maybe its exactly what I am
> looking for. Maybe there are other packes that provide such
> templates/widgets.

The admin is excellent for your basic CRUD operations on a model level and to 
some 
extent on multiple models.
Nested inlines (Pizza -> Topping -> Ingredient) are not supported and probably 
the 
thing you're gonna run into.
While this can be seen as a disadvantage, there's something to be said about 
form/widget complexity: Is it really that important to have ingredients of 
toppings 
available when creating/editing pizza's or is it better to use two workflows?
Another thing you may run into with the admin is customized overviews, like 
dashboards and reporting features. A lot can be done with list_display[1] and 
customized templates, but in the end the scope of a page is usually one model.

As for customized look/feel and widgets, here's some useful links:
 *  Admin interfaces[2] 
 *  Smart Selects for foreign objects[3] 
 *  Tighter permissions[4] 
 *  RichText Editor: CkEditor[5] / TinyMCE[6] 
-- 
Melvyn Sopacua


[1] 
https://docs.djangoproject.com/en/1.10/ref/contrib/admin/#django.contrib.admin.Mode
lAdmin.list_display
[2] https://djangopackages.org/grids/g/admin-interface/
[3] https://pypi.python.org/pypi/django-smart-selects
[4] https://pypi.python.org/pypi/django-guardian
[5] https://pypi.python.org/pypi/django-ckeditor
[6] https://pypi.python.org/pypi/django-tinymce

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


Re: Benefit of 'return Foo.objects.all()' in a ListView

2017-02-25 Thread Melvyn Sopacua
Hi Richard,

Don't be discouraged to ask questions. It's what the list is for.

Ludovic is right, you'd normally use the regroup tag. But let's say you wanted 
to do 
this, then get_queryset isn't the right method.
It should return a queryset, and one only.

On Saturday 25 February 2017 03:42:11 Richard Jackson wrote:

> class MyBlogPosts(generic.ListView):
> def get_queryset(self, request):

My bad: request is not an argument here.

> ...is it possible to return two uniquely identifiable sets - for
> example, if a model has a function which returns True or False, to
> return one set for all the True and one for all the False?

General overview:

The goal of a View is to turn a HTTP request into a HTTP response. A 
Template[1] 
provides context[2] to the template,
A ListView[3] uses a Template to do that and is responsible for providing a 
list of 
ModelInstances[4] to the template. The get_queryset() method is used to 
retrieve 
those instances.

So, the logical place to provide a different grouping of a queryset is in the 
part where it 
gets sent to the template:

class BlogRoll(generic.ListView):
def get_context_data(self, **kwargs):
# let ListView do the hard work first
context = super(BlogRoll, self).get_context_data(**kwargs)
# Now make two groups
qs = context['object_list']
group1 = [ obj for obj in qs if obj.boolean_method() is True ]
group2 = [ obj for obj in qs if obj.boolean_method() is False ]
# update the context
context.update(
{ 'group1': group1, 'group2': group2 }
)
# and return it
return context


-- 
Melvyn Sopacua


[1] 
https://ccbv.co.uk/projects/Django/1.10/django.views.generic.base/TemplateResponseM
ixin/
[2] 
https://ccbv.co.uk/projects/Django/1.10/django.views.generic.base/ContextMixin/
[3] https://ccbv.co.uk/projects/Django/1.10/django.views.generic.list/ListView/
[4] 
https://ccbv.co.uk/projects/Django/1.10/django.views.generic.list/MultipleObjectMixin/

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


Re: Benefit of 'return Foo.objects.all()' in a ListView

2017-02-25 Thread ludovic coues
That's what regroup is for
https://docs.djangoproject.com/en/1.10/ref/templates/builtins/#regroup

2017-02-25 12:42 GMT+01:00 Richard Jackson :
> Apologies if this is too off-topic, but in the case of using a
> get_queryset() as below:
>
> class MyBlogPosts(generic.ListView):
> def get_queryset(self, request):
> return self.model.objects.filter(user=self.request.user)
>
> ...is it possible to return two uniquely identifiable sets - for example, if
> a model has a function which returns True or False, to return one set for
> all the True and one for all the False?
>
> Right now I'm splitting them in the template in something such as the below:
>
> True ones
> {% for p in object_list %} 
> 
> {% if p.true_or_false == True %}
> {{ p.foo }}
> {% endif %}
> 
> {% endfor %}
>
> False ones
> {% for p in object_list %} 
> 
> {% if p.true_or_false == False %}
> {{ p.foo }}
> {% endif %}
> 
> {% endfor %}
>
>
> Thanks, and apologies for the constant basic questions!
>
> Rich
>
>
>
> On Saturday, February 25, 2017 at 9:32:32 AM UTC, Melvyn Sopacua wrote:
>>
>> Hi Richard,
>>
>> On Friday 24 February 2017 15:51:15 Richard Jackson wrote:
>>
>> > What is the advantage of including the get_queryset(self) function in
>> > a ListView? When I've run it with a very basic model ('Foo') there
>> > doesn't appear to be any difference with/without it - this could well
>> > be that my examples are currently too basic.
>>
>> There is none. The benefit of the get_queryset() method is that you can
>> return something other than Foo.objects.all(). For example:
>>
>> class MyBlogPosts(generic.ListView):
>> def get_queryset(self, request):
>> return self.model.objects.filter(user=self.request.user)
>> --
>> Melvyn Sopacua
>
> --
> 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/b8556d2f-079a-4ba0-9697-0dbaaa07823d%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
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/CAEuG%2BTZtkSU1NNZTn0g%3DUROZPOBD-CpkBBsHU1%2BFxMhJotJYuw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Benefit of 'return Foo.objects.all()' in a ListView

2017-02-25 Thread Richard Jackson
Apologies if this is too off-topic, but in the case of using a 
get_queryset() as below:

class MyBlogPosts(generic.ListView): 
def get_queryset(self, request): 
return self.model.objects.filter(user=self.request.user) 

...is it possible to return two uniquely identifiable sets - for example, 
if a model has a function which returns True or False, to return one set 
for all the True and one for all the False?

Right now I'm splitting them in the template in something such as the below:

True ones
{% for p in object_list %} 

{% if p.true_or_false == True %}
{{ p.foo }}
{% endif %}

{% endfor %}

False ones
{% for p in object_list %} 

{% if p.true_or_false == False %}
{{ p.foo }}
{% endif %}

{% endfor %}


Thanks, and apologies for the constant basic questions!

Rich



On Saturday, February 25, 2017 at 9:32:32 AM UTC, Melvyn Sopacua wrote:
>
> Hi Richard, 
>
> On Friday 24 February 2017 15:51:15 Richard Jackson wrote: 
>
> > What is the advantage of including the get_queryset(self) function in 
> > a ListView? When I've run it with a very basic model ('Foo') there 
> > doesn't appear to be any difference with/without it - this could well 
> > be that my examples are currently too basic. 
>
> There is none. The benefit of the get_queryset() method is that you can 
> return something other than Foo.objects.all(). For example: 
>
> class MyBlogPosts(generic.ListView): 
> def get_queryset(self, request): 
> return self.model.objects.filter(user=self.request.user) 
> -- 
> Melvyn Sopacua 
>

-- 
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/b8556d2f-079a-4ba0-9697-0dbaaa07823d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Benefit of 'return Foo.objects.all()' in a ListView

2017-02-25 Thread Richard Jackson
Grand, thank you for clarifying!

On Saturday, February 25, 2017 at 9:32:32 AM UTC, Melvyn Sopacua wrote:
>
> Hi Richard, 
>
> On Friday 24 February 2017 15:51:15 Richard Jackson wrote: 
>
> > What is the advantage of including the get_queryset(self) function in 
> > a ListView? When I've run it with a very basic model ('Foo') there 
> > doesn't appear to be any difference with/without it - this could well 
> > be that my examples are currently too basic. 
>
> There is none. The benefit of the get_queryset() method is that you can 
> return something other than Foo.objects.all(). For example: 
>
> class MyBlogPosts(generic.ListView): 
> def get_queryset(self, request): 
> return self.model.objects.filter(user=self.request.user) 
> -- 
> Melvyn Sopacua 
>

-- 
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/5044035d-af8b-42cc-9191-eb7151cf04ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Benefit of 'return Foo.objects.all()' in a ListView

2017-02-25 Thread Melvyn Sopacua
Hi Richard,

On Friday 24 February 2017 15:51:15 Richard Jackson wrote:

> What is the advantage of including the get_queryset(self) function in
> a ListView? When I've run it with a very basic model ('Foo') there
> doesn't appear to be any difference with/without it - this could well
> be that my examples are currently too basic.

There is none. The benefit of the get_queryset() method is that you can 
return something other than Foo.objects.all(). For example:

class MyBlogPosts(generic.ListView):
def get_queryset(self, request):
return self.model.objects.filter(user=self.request.user)
-- 
Melvyn Sopacua

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


Re: Daphne does not handle wss requests

2017-02-25 Thread Giovanni Colapinto
Sadly it doesn't work, also with DEBUG=False

On Saturday, 25 February 2017 02:19:17 UTC+1, chris rose wrote:
>
> I too experience this in my local development environment
>
> I find secure web sockets throwing an error in the browser console when 
> attempting to send a message:
>
> InvalidStateError: DOM Exception 11: An attempt was made to use an object 
> that is not, or is no longer, usable.
>
> I had attributed this to django being in debug mode, not serving secure 
> http and thus not supporting secure ws
>

-- 
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/b3f3138a-e484-437e-957b-07b877ae3625%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.