Re: Where is all the time going?

2017-05-22 Thread Thomas Lockhart

On 5/22/17 10:12 PM, Bernd Wechner wrote:

James,

If you have the fortitude and kind heart to look at it, sure the code 
base (just checked in) is here:


https://github.com/bernd-wechner/CoGs

it's the Create view on the Session model that is taking 30s to 
render, no other model, and that one is the central model of interest 
with a custom form that needs related model forms as well, to wit is a 
tad complex and I'm experimenting with keeping it as generic as I can 
for reuse later (DRY), though it is highly experimental and hacked up 
as I'm learning on the fly.
In my experience long "render times" have always come from an unintended 
very long list in a menu of candidates for filling out a form. Make sure 
that the input choices are small in number!


hth

- 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/6759a167-50f9-2c01-b588-a963fd9ec24b%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where is all the time going?

2017-05-22 Thread Bernd Wechner

James,

If you have the fortitude and kind heart to look at it, sure the code 
base (just checked in) is here:


   https://github.com/bernd-wechner/CoGs

it's the Create view on the Session model that is taking 30s to render, 
no other model, and that one is the central model of interest with a 
custom form that needs related model forms as well, to wit is a tad 
complex and I'm experimenting with keeping it as generic as I can for 
reuse later (DRY), though it is highly experimental and hacked up as I'm 
learning on the fly.


I'd harboured the slight hope that there might be some experience out 
there of a more general nature regarding a 30s render time on a simple 
form and where Django may be sinking all that time, but of course I do 
appreciate that specifics are always useful in diagnosis. Only that I'm 
not really expecting anyone to wade knee deep into the code there.


So to be specific the model in question is at line 694:

   https://github.com/bernd-wechner/CoGs/blob/master/Leaderboards/models.py

The view in question is at line 276:

   https://github.com/bernd-wechner/CoGs/blob/master/Leaderboards/views.py

which derives from line 589:

   
https://github.com/bernd-wechner/CoGs/blob/master/django_generic_view_extensions/__init__.py

and the template is at:

   
https://github.com/bernd-wechner/CoGs/blob/master/Leaderboards/templates/CoGs/form_data.html

but it's a work in progress and full of notes and TODOs and experiments, 
a learning context while constructing a tool of use ;-).


Really part of me is wondering mainly how from that view Django comes to 
spend so much time doing stuff and what and I find Kcachegrind a rather 
steep learning curve itself, so was fishing around for any pointers from 
experience as to likely causes.


I'm a little time poor so can't push it fast and hard anyhow, (if you 
look at the timeline on commits) and best clue I have as noted in first 
post, so far is that it's inside of Django at_store_template_info which 
has 17506 on it in the call tree which I am guessing might be a call 
count, and seems large and also it seems clear that pprint.py is the 
likely main consumer and so Django experience regarding where that is 
used by Django might be handy. I can drill down into the code base 
slowly too and will and am, but it's a big slog and learning curve. 
Hence curious if experienced eyes out there have any tips that might 
save me time I guess. Certainly don't expect anyone to get knee deep 
into my code base, though if anyone is willing, heck mentoring is always 
welcome - anyone above that would surprise me in a sense. I'd be 
appreciative no less, just not expecting it.


Kind regards,

Bernd.

James Schneider wrote:



On May 21, 2017 5:50 AM, "Bernd Wechner" > wrote:


I'm a tad stuck with a slow performing form, like 30s to load,
totally studding, on a high specced local dev machine.

It's a generic CreateView, and the Django Toolbar reports this:


The relevant code for your view, form, template, and model would be 
super helpful. Without those, all of this profiling information 
doesn't have much meaning.


-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%2BciWJwNNc2h%3DDL9uiqtMCHfweavCnfnYUc3t2o8M%3D0Qj2-g%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/e9f57972-c327-3f51-84fc-cdc79c25babd%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Updating 1.10 to 1.11.1 and AttributeError

2017-05-22 Thread Tim Graham
Which database backend are you using? I wonder if it's a third-party 
backend that hasn't been updated for Django 1.11.

On Monday, May 22, 2017 at 6:40:11 PM UTC-4, Jorge Cadena wrote:
>
> Hello.
>
> updating 1.10 to 1.11.1 and get this error:
>
>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/utils/autoreload.py",
>>  
>> line 227, in wrapper
>> fn(*args, **kwargs)
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/channels/management/commands/runserver.py",
>>  
>> line 38, in inner_run
>> return RunserverCommand.inner_run(self, *args, **options)
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/core/management/commands/runserver.py",
>>  
>> line 125, in inner_run
>> self.check(display_num_errors=True)
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/core/management/base.py",
>>  
>> line 359, in check
>> include_deployment_checks=include_deployment_checks,
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/core/management/base.py",
>>  
>> line 346, in _run_checks
>> return checks.run_checks(**kwargs)
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/core/checks/registry.py",
>>  
>> line 81, in run_checks
>> new_errors = check(app_configs=app_configs)
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/core/checks/urls.py",
>>  
>> line 16, in check_url_config
>> return check_resolver(resolver)
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/core/checks/urls.py",
>>  
>> line 26, in check_resolver
>> return check_method()
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/urls/resolvers.py", 
>> line 254, in check
>> for pattern in self.url_patterns:
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/utils/functional.
>> res = instance.__dict__[self.name] = self.func(instance)
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/urls/resolvers.py
>> patterns = getattr(self.urlconf_module, "urlpatterns", 
>> self.urlconf_module)
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/utils/functional.
>> res = instance.__dict__[self.name] = self.func(instance)
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/urls/resolvers.py
>> return import_module(self.urlconf_name)
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/lib/python3.5/importlib/__init__.py", line 126, in import_
>> return _bootstrap._gcd_import(name[level:], package, level)
>>   File "", line 986, in _gcd_import
>>   File "", line 969, in _find_and_load
>>   File "", line 958, in 
>> _find_and_load_unlocked
>>   File "", line 673, in _load_unlocked
>>   File "", line 673, in exec_module
>>   File "", line 222, in 
>> _call_with_frames_removed
>>   File "/home/aztrock/workspace/ariatel.com.co/kibox/billing/urls.py", 
>> line 9, in 
>> from app.usuarios import views as UserViews
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/kibox/app/usuarios/views.py", line 31, in 
>> from .form import (
>>   File "/home/aztrock/workspace/ariatel.com.co/kibox/app/usuarios/form.py", 
>> line 22, in 
>> class UsuarioNuevoForm(forms.ModelForm):
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/forms/models.py",
>> opts.field_classes)
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/forms/models.py",
>> formfield = f.formfield(**kwargs)
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/db/models/fields/
>> 'queryset': self.remote_field.model._default_manager.using(db),
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/db/models/manager
>> return getattr(self.get_queryset(), name)(*args, **kwargs)
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/db/models/query.p
>> clone = self._clone()
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/db/models/query.p
>> query = self.query.clone()
>>   File "/home/aztrock/workspace/
>> ariatel.com.co/local/lib/python3.5/site-packages/django/db/models/sql/que
>> obj.select_for_update_skip_locked = self.select_for_update_skip_locked
>> AttributeError: 'Query' object has no attribute 
>> 'select_for_update_skip_locked'
>>
>
> models
>
> class Usuarios(AbstractBaseUser, PermissionsMixin):
>>
> codigo_cliente = models.BigIntegerField(
>> null=True,
>> blank=True,
>> )
>> 

Re: Realy not documented cache template if not DEBUG

2017-05-22 Thread Tim Graham
You can use "Blame" button at 
https://github.com/django/django/blob/master/django/template/engine.py to 
find the commit for the line in question:

https://github.com/django/django/commit/277fe2e8f2ee35cd389b079ce7691491bb5738ec

That includes documentation updates as well as a mention in the 1.11 
release notes.

On Monday, May 22, 2017 at 2:34:28 PM UTC-4, Иван Федосеев wrote:
>
> Hell, I spent 2 hours to understand why, when debug = False I have cached 
> templates!!!??!
>
> I have not found in documentation any mention that NEW! features
>
> class Engine(object):
>
>
> if loaders is None:
> loaders = ['django.template.loaders.filesystem.Loader']
> if app_dirs:
> loaders += ['django.template.loaders.app_directories.Loader']
> if not debug: # 
> !?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?v
> loaders = [('django.template.loaders.cached.Loader', loaders)] 
> #!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?
>
>
> What is this nonsense?
>

-- 
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/46ddabc8-8ad5-4261-aaa1-5335bcfd151e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Updating 1.10 to 1.11.1 and AttributeError

2017-05-22 Thread Jorge Cadena
Hello.

updating 1.10 to 1.11.1 and get this error:

  File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/utils/autoreload.py",
>  
> line 227, in wrapper
> fn(*args, **kwargs)
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/channels/management/commands/runserver.py",
>  
> line 38, in inner_run
> return RunserverCommand.inner_run(self, *args, **options)
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/core/management/commands/runserver.py",
>  
> line 125, in inner_run
> self.check(display_num_errors=True)
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/core/management/base.py",
>  
> line 359, in check
> include_deployment_checks=include_deployment_checks,
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/core/management/base.py",
>  
> line 346, in _run_checks
> return checks.run_checks(**kwargs)
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/core/checks/registry.py",
>  
> line 81, in run_checks
> new_errors = check(app_configs=app_configs)
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/core/checks/urls.py",
>  
> line 16, in check_url_config
> return check_resolver(resolver)
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/core/checks/urls.py",
>  
> line 26, in check_resolver
> return check_method()
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/urls/resolvers.py",
>  
> line 254, in check
> for pattern in self.url_patterns:
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/utils/functional.
> res = instance.__dict__[self.name] = self.func(instance)
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/urls/resolvers.py
> patterns = getattr(self.urlconf_module, "urlpatterns", 
> self.urlconf_module)
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/utils/functional.
> res = instance.__dict__[self.name] = self.func(instance)
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/urls/resolvers.py
> return import_module(self.urlconf_name)
>   File 
> "/home/aztrock/workspace/ariatel.com.co/lib/python3.5/importlib/__init__.py", 
> line 126, in import_
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 986, in _gcd_import
>   File "", line 969, in _find_and_load
>   File "", line 958, in 
> _find_and_load_unlocked
>   File "", line 673, in _load_unlocked
>   File "", line 673, in exec_module
>   File "", line 222, in 
> _call_with_frames_removed
>   File "/home/aztrock/workspace/ariatel.com.co/kibox/billing/urls.py", 
> line 9, in 
> from app.usuarios import views as UserViews
>   File 
> "/home/aztrock/workspace/ariatel.com.co/kibox/app/usuarios/views.py", line 
> 31, in 
> from .form import (
>   File 
> "/home/aztrock/workspace/ariatel.com.co/kibox/app/usuarios/form.py", line 
> 22, in 
> class UsuarioNuevoForm(forms.ModelForm):
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/forms/models.py",
> opts.field_classes)
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/forms/models.py",
> formfield = f.formfield(**kwargs)
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/db/models/fields/
> 'queryset': self.remote_field.model._default_manager.using(db),
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/db/models/manager
> return getattr(self.get_queryset(), name)(*args, **kwargs)
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/db/models/query.p
> clone = self._clone()
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/db/models/query.p
> query = self.query.clone()
>   File 
> "/home/aztrock/workspace/ariatel.com.co/local/lib/python3.5/site-packages/django/db/models/sql/que
> obj.select_for_update_skip_locked = self.select_for_update_skip_locked
> AttributeError: 'Query' object has no attribute 
> 'select_for_update_skip_locked'
>

models

class Usuarios(AbstractBaseUser, PermissionsMixin):
>
codigo_cliente = models.BigIntegerField(
> null=True,
> blank=True,
> )
> first_name = models.CharField(_('Nombres'),
>   max_length=30,
>   help_text="Nombres")
> last_name = models.CharField(
> _('Apellidos'),
> max_length=30,
> help_text="Apellidos",
> blank=True,
>

Re: tutorial on using dbshell?

2017-05-22 Thread James Schneider
On May 22, 2017 3:07 PM, "Jim Anderson"  wrote:

Hi James,

I'm looking at the sqlite3 documentation now, but I'm still not quite sure
how to run the dbshell. Once I am in the shell, I assume that I can run
sqlite3 commands as needed. But when I enter:

*% python manage.py dbshell*

I get the following error messages:



*setting.py: BASE_DIR =  /home/jja/...FINISHED settings.pyCommandError: You
appear not to have the 'sqlite3' program installed or on your path.*

Am I invoking it properly? Do I have to change my configuration?


>From a Django perspective, it looks correct. You'll need to install the
sqlite3 management package do that Django has access to it. In most cases,
if you are able to run the sqlite3 command by itself, Django should be able
to find it. How you install it is going to be dependent on your OS. Linux
distributions should have it really available in their package
repositories, and the necessary package for Windows should be available on
it's project page.

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


Re: Building correct queryset

2017-05-22 Thread Todor Velichkov
Hello, Дмитрий,
you can try this one, but w/o further optimizations it may be a very slow 
query.

qs = Product.objects.filter(
#Where score is greater or equal
#to the 4th max score from its group
score__gte=Subquery(
(Product.objects
.filter(brand=OuterRef('brand'))
.values('score')
.order_by('-score')[3:4]
)
)
).order_by('-score')




 

On Friday, May 19, 2017 at 12:32:49 PM UTC+3, Горобец Дмитрий wrote:
>
> Hello. I have these two models. I have to show 4 or less products on a page 
> for each brand ordered by score. Please, help construct correct queryset.
>
>
>
> class Brand(models.Model):
> title = models.CharField(
> verbose_name='Название бренда',
> max_length=64,
> unique=True,
> db_index=True,
> error_messages={
> 'unique': 'Бренд с таким именем уже существует.'
> }
> )
>
> slug = AutoSlugField(
> verbose_name='Адрес страницы бренда',
> populate_from='title',
> editable=True,
> unique=True,
> slugify=custom_slugify,
> db_index=True
> )
>
> owner = models.OneToOneField(
> to=settings.AUTH_USER_MODEL,
> verbose_name='Владелец',
> on_delete=models.PROTECT,
> )
>
>
> score = models.DecimalField(
> verbose_name='Рейтинг бренда',
> blank=True,
> null=True,
> max_digits=19,
> decimal_places=18,
> )
>
>
>
> class Product(models.Model):
> title = models.CharField(
> verbose_name='Название изделия',
> max_length=255,
> db_index=True,
> )
>
> slug = AutoSlugField(
> verbose_name='Адрес страницы изделия',
> populate_from='title',
> editable=False,
> unique_with='brand',
> slugify=custom_slugify,
> db_index=True,
> )
>
> brand = models.ForeignKey(
> to=Brand,
> verbose_name='Бренд',
> related_name='products',
> on_delete=models.CASCADE,
> )
>
>
>

-- 
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/16251879-81fd-4f25-83b7-5f6c920e3f8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: tutorial on using dbshell?

2017-05-22 Thread Jim Anderson
Hi James,

I'm looking at the sqlite3 documentation now, but I'm still not quite sure
how to run the dbshell. Once I am in the shell, I assume that I can run
sqlite3 commands as needed. But when I enter:

*% python manage.py dbshell*

I get the following error messages:



*setting.py: BASE_DIR =  /home/jja/...FINISHED settings.pyCommandError: You
appear not to have the 'sqlite3' program installed or on your path.*

Am I invoking it properly? Do I have to change my configuration?

Jim A.


On Mon, May 22, 2017 at 5:28 PM, James Schneider 
wrote:

>
>
> On May 22, 2017 2:20 PM,  wrote:
>
>
> I'm working with Django 1.10.3 and I'm trying to look at the database
> tables generated by Django using makemigrations and migrate. I was looking
> to use 'python manage.py sql', but it looks like that is no longer
> available. In a recent question to Django users, I was advised to use
> dbshell which I am planning to do, but thus fair I have not found and
> instructions or a tutorial on how to use deshell. Can someone point me to
> instructions?
>
>
> The dbshell command is simply a convenience command for opening the
> standard management console for your specific database. That interface will
> be different depending on the type of database you are using (MySQL,
> Postgres, or SQLite). You can find the commands for each database
> management tool by searching for " commands tutorial", as an
> example.
>
> -James
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/YYgAsqFhT8w/unsubscribe.
> To unsubscribe from this group and all its topics, 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%2BciWZyW7Q_xzDYrEBFzAHSjDD_
> XBBD%2Bh2XGbOCoePcFLueA%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/CAB5UADGurJko5ZHWtott%2BRO2%2BtO_%2BjOb2vbvYd3%2BEf1rE5S-OA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django+Haystack+Elastic issue

2017-05-22 Thread Nick Gilmour
Hi all,



I'm following an example to setup Django with Haystack and ES from here:

https://krzysztofzuraw.com/blog/2016/haystack-elasticsearch-part-one.html


Everything seems to be working OK except from the number of the results –
they are always maximal 20. But actually a single query should give more
than 50 results.

So, where does this limitation come from? How can I change it?

I cannot find a setting neither for haystack nor for django which prevents
showing more than 20 results.



Thanks,

Nick

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


Re: tutorial on using dbshell?

2017-05-22 Thread James Schneider
On May 22, 2017 2:20 PM,  wrote:


I'm working with Django 1.10.3 and I'm trying to look at the database
tables generated by Django using makemigrations and migrate. I was looking
to use 'python manage.py sql', but it looks like that is no longer
available. In a recent question to Django users, I was advised to use
dbshell which I am planning to do, but thus fair I have not found and
instructions or a tutorial on how to use deshell. Can someone point me to
instructions?


The dbshell command is simply a convenience command for opening the
standard management console for your specific database. That interface will
be different depending on the type of database you are using (MySQL,
Postgres, or SQLite). You can find the commands for each database
management tool by searching for " commands tutorial", as an
example.

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


tutorial on using dbshell?

2017-05-22 Thread jjanderson52000

I'm working with Django 1.10.3 and I'm trying to look at the database 
tables generated by Django using makemigrations and migrate. I was looking 
to use 'python manage.py sql', but it looks like that is no longer 
available. In a recent question to Django users, I was advised to use 
dbshell which I am planning to do, but thus fair I have not found and 
instructions or a tutorial on how to use deshell. Can someone point me to 
instructions?

Thank you.

Jim A.

-- 
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/b47a0de8-a888-4cd8-99f8-f251893fb52d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django REST API

2017-05-22 Thread Andréas Kühne
Hi,

That is a very broad question and hard to answer directly.

Reasons why you would want a REST API:
1. Communicating with another server
2. Communicating with a mobile application
3. Creating a single page application with a javascript framework like
angular, react, jquery or the like.

I think you need to define your question more :-)

Regards,

Andréas

2017-05-22 16:28 GMT+02:00 DEVENDRA BAJAJ :

> When is it best to build the Backed with Django's REST API
>
> --
> 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/5158d042-a147-401d-92d3-8a19119a02bb%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/CAK4qSCe0i_E%3DDq_G0q4PMYisHH5m%3DMonh%2B%2BU436sfY3YDCtk7w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Realy not documented cache template if not DEBUG

2017-05-22 Thread Иван Федосеев
Hell, I spent 2 hours to understand why, when debug = False I have cached 
templates!!!??!

I have not found in documentation any mention that NEW! features

class Engine(object):


if loaders is None:
loaders = ['django.template.loaders.filesystem.Loader']
if app_dirs:
loaders += ['django.template.loaders.app_directories.Loader']
if not debug: # 
!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?v
loaders = [('django.template.loaders.cached.Loader', loaders)] 
#!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?


What is this nonsense?

-- 
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/3369e14f-0a9c-44aa-b92e-4662a3ea146f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django REST API

2017-05-22 Thread DEVENDRA BAJAJ
When is it best to build the Backed with Django's REST API

-- 
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/5158d042-a147-401d-92d3-8a19119a02bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: sqlite3 table not found

2017-05-22 Thread jjanderson52000

James,

I will read up on dbshell and give it a try. Thanks for the pointer.

Yes, I ran both 'makemigrations' and 'migrate' prior to posting.

If I can figure out how to close out the thread, I will.

Jim A.

On Sunday, May 21, 2017 at 12:03:42 PM UTC-4, James Schneider wrote:
>
>
>
> On May 21, 2017 8:49 AM,  wrote:
>
>
> Hi,
>
> I'm fairly new to Django and I'm very much still in the learning process.
>
>
>
> I'm using Django 1.10.3 on a project and have just added some new models. 
> When I run the server and enter a URL to visit one of my views, I get an 
> error, an excerpt of which is shown below:
>
> File 
> "/home/jja/testenv3.5/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py",
>  
> line 337, in execute
> return Database.Cursor.execute(self, query, params)
> sqlite3.OperationalError: no such table: siggy_siggytemplate
>
> I would like to look at the SQL tables and it looks like 'python manage.py 
> sql' is a command that could do the job, but whichh is no longer available. 
> Is this correct?
>
> Is there an alternative command that I can run?\
>
>
> I believe you're looking for the 'dbshell' command, which will open the 
> sqlite shell for you.
>
>
> I would like to look at the tables to see if I can figure out why the 
> table 'siggy_siggytemplate' was not generated. BTW, my project is 'siggy' 
> and my model is 'SiggyTemplate' so I think this would cause generation of 
> the table 
> 'siggy_siggytemplate'.
>
>
> Did you run the 'makemigrations' and 'migrate' commands? That pair of 
> commands will apply your changes to the DB schema.
>
> -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/ba78993e-02c4-479b-8508-6da22b538c26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with CircularDependency Model

2017-05-22 Thread Tobias Dacoir
Thank you very much for the great answer! 
You are correct, I didn't had a clear understanding of the RelatedObject 
Principle. I think I added this when I was fiddling with the rest framework.
Of course, I also had thought about making MasterUser a boolean, but I need 
to ensure that there is only one MasterUser. I thought about doing it in 
the Code, but I thought it might be better to enforce it at Database Level. 
However, I think your solution is much better. 
I also thought having a separate Table for the MasterUser Relationship, 
like you suggested. I tried to some find some suggestions on how to model a 
relationship like that. I think, I will go for the boolean field but my 
intuitive assumption would be to overwrite the pre_save method. post_save 
kinda sounds like it is too late at that point. 

Anyway, thanks a lot for you recommendations!

On Friday, May 19, 2017 at 5:50:42 PM UTC+2, Melvyn Sopacua wrote:
>
>  
>
> Yep, let me see if I got it right:
>
> - The User model is defined as AUTH_USER_MODEL in settings.py
>
> - User points to institute
>
> - Institute points to User
>
>  
>
> So it is in fact a circular dependency on the model level as well. And one 
> you don't need.
>
>  
>
> From the way you defined the related_name it is also clear you don't get 
> the RelatedObject principle of Django.
>
>  
>
> A ForeignKey creates a bridge between two models: you can travel in both 
> directions. Using your models:
>
>  
>
> class User(AbstractBaseUser, PermissionsMixin):
>
> username = ...
>
>  
>
> class Institute(models.Model):
>
> master_user = models.ForeignKey(settings.AUTH_USER_MODEL, 
> related_name='institute')
>
> members = models.ManyToManyField(settings.AUTH_USER_MODEL)
>
>  
>
> Because of the ForeignKey on Institute, Django creates an attribute on 
> User, called 'institute'. It uses institute, because I specified that as 
> related_name. You could use a different name there, but it has to be a name 
> that can be used on the model you point to.
>
>  
>
> However, this isn't a good representation of realitity, given your own 
> description.
>
> So this is a better way to do it:
>
>  
>
> class User(AbstractBaseUser, PermissionsMixin):
>
> institute = models.ForeignKey('port.Institute', related_name='members')
>
> is_master_user = models.BooleanField(default=False)
>
>  
>
> class Institute(models.Model)
>
> name = models.CharField(max_length=255)
>
> # members is now created by the foreign key
>
> @property
>
> def master_user(self):
>
> return self.members.get(is_master_user=True)
>
>  
>
> This model is much simpler. All you need to do is to verify that when 
> someone is made master user, that all other members of the institute are 
> *not* master user.
>
>  
>
> You can do this in a post_save signal or in the clean method of User , 
> both with its own caveats.
>
>  
>
> Another way would be to define a MasterUser model, which is easier to 
> maintain in the admin:
>
>  
>
> class MasterUser(models.Model):
>
> # Assume one person can be master user of many institutes
>
> # if not, this also has to be a OneToOneFIeld
>
> user = models.ForeignKey(settings.AUTH_USER_MODEL)
>
> institute = models.OneToOneField(Institute, related_name='master_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/8c82ccfa-769f-4218-bff5-5adb7d851f97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.