Re: Django TinyMCE external_image_list_url breaking admin urls

2015-11-08 Thread Chris Davies-Barnard
Hi James,

Thanks for the reply.   So I uncommented the line which now looks like: 

*mce_attrs={ 'external_image_list_url': reverse('imagelist')},*

and after restarting apache I get this.

Page not found (404)Request Method:GETRequest URL:
http://csmatrix.local/admin/main/page/add/

Using the URLconf defined in CSMatrix.urls, Django tried these URL 
patterns, in this order:

   1. ^$ [name='cover']
   2. ^m/
   3. ^curriculum/
   4. ^unitsoflearning/
   5. ^studyprogramme/
   6. ^gallery/
   7. ^reprographics/
   8. ^accounts/
   9. ^login/$
   10. ^logout/$
   11. ^tinymce/
   12. ^admin/doc/
   13. ^admin/ ^$ [name='index']
   14. ^admin/ ^login/$ [name='login']
   15. ^admin/ ^logout/$ [name='logout']
   16. ^admin/ ^password_change/$ [name='password_change']
   17. ^admin/ ^password_change/done/$ [name='password_change_done']
   18. ^admin/ ^jsi18n/$ [name='jsi18n']
   19. ^admin/ ^r/(?P\d+)/(?P.+)/$ 
   [name='view_on_site']

The current URL, admin/main/page/add/, didn't match any of these.

You're seeing this error because you have DEBUG = True in your Django 
settings file. Change that to False, and Django will display a standard 404 
page.

It makes no difference if I try and run it though runserver or apache - 
same result.  All my admin urls are broken!   I know this is not much help 
- is there another way of getting a traceback?

Regards

Chris



On Sunday, 8 November 2015 05:30:33 UTC, James Schneider wrote:
>
> Try changing the reverse() call to just reverse('imagelist'). I believe 
> reversing using the full view import path has been deprecated/removed. 
> That, and you named the URL 'imagelist', may as well refer to it by name. 
> ;-)
>
> If that doesn't work, please post the error and entire traceback that you 
> are receiving.
>
> -James
> On Nov 7, 2015 9:53 AM, "Chris Davies-Barnard"  > wrote:
>
>> Hi all,
>>
>> I posted this on SO but have not had any interest and I'm still stuck so 
>> would really really appreciate someone taking a look.
>>
>> I have a pages app into which I have implemented TinyMCE for the main 
>> content. This works and I am able to format content and view it on the 
>> front end. I'm now trying to add the image list support as per the 
>> Django/TinyMCE Docs 
>> 
>>  but 
>> have stumbled upon a problem. When I uncomment the mce_attrs line below all 
>> my admin urls break not just the page add/edit ones.  It is as if the 
>> line breaks my URL files but I cannot figure out why. 
>>
>>
>>  from tinymce.widgets import TinyMCE
>>  content = forms.CharField(widget=TinyMCE(
>>  attrs={ 'cols': 80, 'rows': 30 },
>>  #mce_attrs={ 'external_image_list_url': 
>> reverse('mediamanager.views.imagelist')},
>>  ))
>>
>>
>> The mediamanager.views.imagelist is set up and working.   I can browse to 
>> it as a normal URL and it shows a list of images 
>>
>>
>> url(r'^tinymce/$', views.imagelist, name='imagelist'),
>>
>>
>> var tinyMCEImageList = [["(/media/uploads/2015/10/20141205_142735.jpg", 
>> "/gallery/i/4"], ... ]
>>
>>
>> the view itself looks like:
>>
>>
>> def imagelist(request):  from tinymce.views import render_to_image_list
>>   objects = Image.objects.all()
>>   link_list = [(unicode("/media/" + str(obj.image)), obj.get_absolute_url()) 
>> for obj in objects]
>>   return render_to_image_list(link_list)
>>
>>
>> Thanks in advance for any advice.
>>
>>
>> Regards
>>
>>
>> Chris
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/a259e3d9-16fb-4c7a-ad80-3b06c52e40c0%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/91b3cdfc-fea5-4c90-973d-5523b196d20d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django TinyMCE external_image_list_url breaking admin urls

2015-11-08 Thread James Schneider
Do you have an app named 'main'? Is it part of INSTALLED_APPS? And is the
Page model properly registered with the admin site?

How exactly did you reach that URL? Does the admin work if you just use
/admin/?

-James
On Nov 8, 2015 1:46 AM, "Chris Davies-Barnard" 
wrote:

> Hi James,
>
> Thanks for the reply.   So I uncommented the line which now looks like:
>
> *mce_attrs={ 'external_image_list_url': reverse('imagelist')},*
>
> and after restarting apache I get this.
>
> Page not found (404)Request Method:GETRequest URL:
> http://csmatrix.local/admin/main/page/add/
>
> Using the URLconf defined in CSMatrix.urls, Django tried these URL
> patterns, in this order:
>
>1. ^$ [name='cover']
>2. ^m/
>3. ^curriculum/
>4. ^unitsoflearning/
>5. ^studyprogramme/
>6. ^gallery/
>7. ^reprographics/
>8. ^accounts/
>9. ^login/$
>10. ^logout/$
>11. ^tinymce/
>12. ^admin/doc/
>13. ^admin/ ^$ [name='index']
>14. ^admin/ ^login/$ [name='login']
>15. ^admin/ ^logout/$ [name='logout']
>16. ^admin/ ^password_change/$ [name='password_change']
>17. ^admin/ ^password_change/done/$ [name='password_change_done']
>18. ^admin/ ^jsi18n/$ [name='jsi18n']
>19. ^admin/ ^r/(?P\d+)/(?P.+)/$
>[name='view_on_site']
>
> The current URL, admin/main/page/add/, didn't match any of these.
>
> You're seeing this error because you have DEBUG = True in your Django
> settings file. Change that to False, and Django will display a standard
> 404 page.
>
> It makes no difference if I try and run it though runserver or apache -
> same result.  All my admin urls are broken!   I know this is not much help
> - is there another way of getting a traceback?
>
> Regards
>
> Chris
>
>
>
> On Sunday, 8 November 2015 05:30:33 UTC, James Schneider wrote:
>>
>> Try changing the reverse() call to just reverse('imagelist'). I believe
>> reversing using the full view import path has been deprecated/removed.
>> That, and you named the URL 'imagelist', may as well refer to it by name.
>> ;-)
>>
>> If that doesn't work, please post the error and entire traceback that you
>> are receiving.
>>
>> -James
>> On Nov 7, 2015 9:53 AM, "Chris Davies-Barnard" 
>> wrote:
>>
>>> Hi all,
>>>
>>> I posted this on SO but have not had any interest and I'm still stuck so
>>> would really really appreciate someone taking a look.
>>>
>>> I have a pages app into which I have implemented TinyMCE for the main
>>> content. This works and I am able to format content and view it on the
>>> front end. I'm now trying to add the image list support as per the
>>> Django/TinyMCE Docs
>>> 
>>>  but
>>> have stumbled upon a problem. When I uncomment the mce_attrs line below all
>>> my admin urls break not just the page add/edit ones.  It is as if the
>>> line breaks my URL files but I cannot figure out why.
>>>
>>>
>>> from tinymce.widgets import TinyMCE
>>> content = forms.CharField(widget=TinyMCE(
>>> attrs={ 'cols': 80, 'rows': 30 },
>>> #mce_attrs={ 'external_image_list_url': 
>>> reverse('mediamanager.views.imagelist')},
>>> ))
>>>
>>>
>>> The mediamanager.views.imagelist is set up and working.   I can browse
>>> to it as a normal URL and it shows a list of images
>>>
>>>
>>> url(r'^tinymce/$', views.imagelist, name='imagelist'),
>>>
>>>
>>> var tinyMCEImageList = [["(/media/uploads/2015/10/20141205_142735.jpg", 
>>> "/gallery/i/4"], ... ]
>>>
>>>
>>> the view itself looks like:
>>>
>>>
>>> def imagelist(request):  from tinymce.views import render_to_image_list
>>>   objects = Image.objects.all()
>>>   link_list = [(unicode("/media/" + str(obj.image)), 
>>> obj.get_absolute_url()) for obj in objects]
>>>   return render_to_image_list(link_list)
>>>
>>>
>>> Thanks in advance for any advice.
>>>
>>>
>>> Regards
>>>
>>>
>>> Chris
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/a259e3d9-16fb-4c7a-ad80-3b06c52e40c0%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 http://groups.

Re: Django TinyMCE external_image_list_url breaking admin urls

2015-11-08 Thread Chris Davies-Barnard
Hi James,

Well,  I seem to have made it work by removing the reverse command all 
together.   

mce_attrs={ 'external_image_list_url': 
'http://csmatrix.local/gallery/imagelist/'},

obviously this is not a very elegant solution but its working.I also 
noted that I could not use tinymce 4 as the image box failed to load 
period.   I'm also wondering whether I could/should use reverse_lazy 
because of when this line is being called.

Cheers for your help.   I'd be interested in your thoughts.

Chris

On Sunday, 8 November 2015 09:46:25 UTC, Chris Davies-Barnard wrote:
>
> Hi James,
>
> Thanks for the reply.   So I uncommented the line which now looks like: 
>
> *mce_attrs={ 'external_image_list_url': reverse('imagelist')},*
>
> and after restarting apache I get this.
>
> Page not found (404)Request Method:GETRequest URL:
> http://csmatrix.local/admin/main/page/add/
>
> Using the URLconf defined in CSMatrix.urls, Django tried these URL 
> patterns, in this order:
>
>1. ^$ [name='cover']
>2. ^m/
>3. ^curriculum/
>4. ^unitsoflearning/
>5. ^studyprogramme/
>6. ^gallery/
>7. ^reprographics/
>8. ^accounts/
>9. ^login/$
>10. ^logout/$
>11. ^tinymce/
>12. ^admin/doc/
>13. ^admin/ ^$ [name='index']
>14. ^admin/ ^login/$ [name='login']
>15. ^admin/ ^logout/$ [name='logout']
>16. ^admin/ ^password_change/$ [name='password_change']
>17. ^admin/ ^password_change/done/$ [name='password_change_done']
>18. ^admin/ ^jsi18n/$ [name='jsi18n']
>19. ^admin/ ^r/(?P\d+)/(?P.+)/$ 
>[name='view_on_site']
>
> The current URL, admin/main/page/add/, didn't match any of these.
>
> You're seeing this error because you have DEBUG = True in your Django 
> settings file. Change that to False, and Django will display a standard 
> 404 page.
>
> It makes no difference if I try and run it though runserver or apache - 
> same result.  All my admin urls are broken!   I know this is not much help 
> - is there another way of getting a traceback?
>
> Regards
>
> Chris
>
>
>
> On Sunday, 8 November 2015 05:30:33 UTC, James Schneider wrote:
>>
>> Try changing the reverse() call to just reverse('imagelist'). I believe 
>> reversing using the full view import path has been deprecated/removed. 
>> That, and you named the URL 'imagelist', may as well refer to it by name. 
>> ;-)
>>
>> If that doesn't work, please post the error and entire traceback that you 
>> are receiving.
>>
>> -James
>> On Nov 7, 2015 9:53 AM, "Chris Davies-Barnard"  
>> wrote:
>>
>>> Hi all,
>>>
>>> I posted this on SO but have not had any interest and I'm still stuck so 
>>> would really really appreciate someone taking a look.
>>>
>>> I have a pages app into which I have implemented TinyMCE for the main 
>>> content. This works and I am able to format content and view it on the 
>>> front end. I'm now trying to add the image list support as per the 
>>> Django/TinyMCE Docs 
>>> 
>>>  but 
>>> have stumbled upon a problem. When I uncomment the mce_attrs line below all 
>>> my admin urls break not just the page add/edit ones.  It is as if the 
>>> line breaks my URL files but I cannot figure out why. 
>>>
>>>
>>> from tinymce.widgets import TinyMCE
>>> content = forms.CharField(widget=TinyMCE(
>>> attrs={ 'cols': 80, 'rows': 30 },
>>> #mce_attrs={ 'external_image_list_url': 
>>> reverse('mediamanager.views.imagelist')},
>>> ))
>>>
>>>
>>> The mediamanager.views.imagelist is set up and working.   I can browse 
>>> to it as a normal URL and it shows a list of images 
>>>
>>>
>>> url(r'^tinymce/$', views.imagelist, name='imagelist'),
>>>
>>>
>>> var tinyMCEImageList = [["(/media/uploads/2015/10/20141205_142735.jpg", 
>>> "/gallery/i/4"], ... ]
>>>
>>>
>>> the view itself looks like:
>>>
>>>
>>> def imagelist(request):  from tinymce.views import render_to_image_list
>>>   objects = Image.objects.all()
>>>   link_list = [(unicode("/media/" + str(obj.image)), 
>>> obj.get_absolute_url()) for obj in objects]
>>>   return render_to_image_list(link_list)
>>>
>>>
>>> Thanks in advance for any advice.
>>>
>>>
>>> Regards
>>>
>>>
>>> Chris
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/a259e3d9-16fb-4c7a-ad80-3b06c52e40c0%40googlegroups.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>

Re: Django TinyMCE external_image_list_url breaking admin urls

2015-11-08 Thread Chris Davies-Barnard
Hi James,

Thanks for the response.   I have just replied to say its working in one 
sense.   Main is my pages, blog and homepage app and then mediamanager is 
the app that manages images etc uploaded into the media folder.   I can 
create albums which are inserted using wordpress style shorttags into pages 
and posts and I can set featured images for both.  It all works very nicely 
for me except being able to easily insert single images into the middle of 
pages.

When I went to the main admin page with reverse included it gave a 
traceback that looked the following.

I would obviously like to get it working correctly but for now will leave 
it as is and move on.

Thanks for your help.

Chris

*Environment:*


*Request Method: GET*
*Request URL: http://csmatrix.local/admin/*

*Django Version: 1.8.5*
*Python Version: 2.7.10*
*Installed Applications:*
*('django.contrib.admin',*
* 'django.contrib.admindocs',*
* 'django.contrib.auth',*
* 'django.contrib.contenttypes',*
* 'django.contrib.sessions',*
* 'django.contrib.messages',*
* 'django.contrib.staticfiles',*
* 'tinymce',*
* 'mediamanager',*
* 'main',*
* 'almanac',*
* 'curriculum',*
* 'unitsoflearning',*
* 'studyprogramme',*
* 'reprographics')*
*Installed Middleware:*
*('django.contrib.sessions.middleware.SessionMiddleware',*
* 'django.middleware.common.CommonMiddleware',*
* 'django.middleware.csrf.CsrfViewMiddleware',*
* 'django.contrib.auth.middleware.AuthenticationMiddleware',*
* 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',*
* 'django.contrib.messages.middleware.MessageMiddleware',*
* 'django.middleware.clickjacking.XFrameOptionsMiddleware')*


*Traceback:*
*File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in 
get_response*
*  132. response = wrapped_callback(request, 
*callback_args, **callback_kwargs)*
*File "/Library/Python/2.7/site-packages/django/contrib/admin/sites.py" in 
wrapper*
*  254. return self.admin_view(view, cacheable)(*args, 
**kwargs)*
*File "/Library/Python/2.7/site-packages/django/utils/decorators.py" in 
_wrapped_view*
*  110. response = view_func(request, *args, **kwargs)*
*File "/Library/Python/2.7/site-packages/django/views/decorators/cache.py" 
in _wrapped_view_func*
*  57. response = view_func(request, *args, **kwargs)*
*File "/Library/Python/2.7/site-packages/django/contrib/admin/sites.py" in 
inner*
*  233. return view(request, *args, **kwargs)*
*File "/Library/Python/2.7/site-packages/django/views/decorators/cache.py" 
in _wrapped_view_func*
*  57. response = view_func(request, *args, **kwargs)*
*File "/Library/Python/2.7/site-packages/django/contrib/admin/sites.py" in 
index*
*  438. current_app=self.name,*
*File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in 
reverse*
*  578. return 
force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, 
**kwargs)))*
*File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in 
_reverse_with_prefix*
*  495.  (lookup_view_s, args, kwargs, 
len(patterns), patterns))*

*Exception Type: NoReverseMatch at /admin/*
*Exception Value: Reverse for 'app_list' with arguments '()' and keyword 
arguments '{'app_label': 'unitsoflearning'}' not found. 0 pattern(s) tried: 
[]*


On Sunday, 8 November 2015 10:04:34 UTC, James Schneider wrote:
>
> Do you have an app named 'main'? Is it part of INSTALLED_APPS? And is the 
> Page model properly registered with the admin site? 
>
> How exactly did you reach that URL? Does the admin work if you just use 
> /admin/?
>
> -James
> On Nov 8, 2015 1:46 AM, "Chris Davies-Barnard"  > wrote:
>
>> Hi James,
>>
>> Thanks for the reply.   So I uncommented the line which now looks like: 
>>
>> *mce_attrs={ 'external_image_list_url': reverse('imagelist')},*
>>
>> and after restarting apache I get this.
>>
>> Page not found (404)Request Method:GETRequest URL:
>> http://csmatrix.local/admin/main/page/add/
>>
>> Using the URLconf defined in CSMatrix.urls, Django tried these URL 
>> patterns, in this order:
>>
>>1. ^$ [name='cover']
>>2. ^m/
>>3. ^curriculum/
>>4. ^unitsoflearning/
>>5. ^studyprogramme/
>>6. ^gallery/
>>7. ^reprographics/
>>8. ^accounts/
>>9. ^login/$
>>10. ^logout/$
>>11. ^tinymce/
>>12. ^admin/doc/
>>13. ^admin/ ^$ [name='index']
>>14. ^admin/ ^login/$ [name='login']
>>15. ^admin/ ^logout/$ [name='logout']
>>16. ^admin/ ^password_change/$ [name='password_change']
>>17. ^admin/ ^password_change/done/$ [name='password_change_done']
>>18. ^admin/ ^jsi18n/$ [name='jsi18n']
>>19. ^admin/ ^r/(?P\d+)/(?P.+)/$ 
>>[name='view_on_site']
>>
>> The current URL, admin/main/page/add/, didn't match any of these.
>>
>> You're seeing this error because you have DEBUG = True in your Django 
>> settings file. Change that to False, and Django will display a standar

Re: duplicated queries

2015-11-08 Thread V1ce

I post here my real models for better comprehension (and have cleaned it 
this morning with an abstract class)

class Rubrique(models.Model):
nom = models.CharField(max_length=30)
slug = models.SlugField(max_length=100)
page = models.CharField(max_length=50, null=True)
description = RichTextField(null=True, blank = True)
metaDesc = models.TextField("Balise meta description",null=True, blank 
= True)
position = models.PositiveSmallIntegerField("Position",default = 
0,null=True, blank = True)
visible = models.BooleanField("Visible",default = False)
redirect = models.CharField("Redirection",max_length=200, null=True, 
blank = True)
created = models.DateTimeField(_('Date de création'),editable=False)
modified  = models.DateTimeField(_('Dernière 
modification'),editable=False)

def __str__(self):
return self.nom

class Meta(object):
abstract = True
ordering = ('position',)

class Categorie(Rubrique): 
develop = models.BooleanField(_('develop?'), default=True, blank=True)
is_clickable = models.BooleanField(_('clickable?'), default=False, 
blank=True)

class Meta(Rubrique.Meta):
pass

def getscateg(self):
#return self.souscategorie_set.all().filter(visible = True)
return SousCategorie.objects.filter(visible = True, categorie = 
self).only('nom','slug','is_clickable','develop')


class SousCategorie(Rubrique):

is_clickable = models.BooleanField(_('clickable?'), default=False, 
blank=True)
develop = models.BooleanField(_('develop?'), default=False, blank=True)
categorie = 
models.ForeignKey(Categorie,verbose_name='Catégorie',null=True,on_delete=models.SET_NULL)

class Meta(Rubrique.Meta):
pass

def gettheme(self): 
return Theme.objects.filter(visible = True, souscategorie = 
self).only('nom','slug','is_clickable')
#return self.theme_set.all().filter(visible = True)


class Theme(Rubrique):
is_clickable = models.BooleanField(_('Clickable?'), default=False, 
blank=True)
souscategorie = 
models.ForeignKey('SousCategorie',verbose_name='Sous-catégorie',null=True,blank=True,on_delete=models.SET_NULL)

class Meta(Rubrique.Meta):
pass

def getstheme(self): 
return SousTheme.objects.filter(visible = True, theme = 
self).only('nom','slug')
#return self.soustheme_set.all().filter(visible=True)

class SousTheme(Rubrique):
theme = models.ForeignKey('Theme',verbose_name='Thème', null=True, 
blank = True,on_delete=models.SET_NULL)

class Meta(Rubrique.Meta):
pass

Actually it is normal if i have duplicate, because at each "Categorie" loop 
in template i load different data, but if i can optimize this with 1 
request i think will better, i look at cache funcionnality too for visitor 
not have to loads these data at each pages (because this menu is here in 
all pages of the website), but its an other thing.


Le samedi 7 novembre 2015 17:37:17 UTC+1, V1ce a écrit :
>
> Hi,
>
> I got a lot of duplicated queries (in django debug toolbag) when i load my 
> menu tabs , actually it's normal because i don't understand how to use 
> database optimization for this, if possible i want some advice to make my 
> reflexion better on this.
>
> Models(simplify) : 
>
> class Categorie(models.Model):
> nom = models.CharField(max_length=30)
> slug = models.SlugField(max_length=100)
> visible = models.BooleanField("Visible",default = False)
>
> def getscateg(self):
>
> return self.souscategorie_set.all().filter(visible = True)
>
>
> class SousCategorie(models.Model):
> nom = models.CharField(max_length=30)
> slug = models.SlugField(max_length=100)
> visible = models.BooleanField("Visible",default = False)
>
> def gettheme(self):
> 
> return self.theme_set.all().filter(visible = True)
>
>
> class Theme(models.Model):
> nom = models.CharField(max_length=100)
> slug = models.SlugField(max_length=100)
> visible = models.BooleanField("Visible",default = False)
>
> def getstheme(self): # Récupère les thèmes en fonction de la 
> sous-categ traité
>
> return self.soustheme_set.all().filter(visible=True)
>
>
> class SousTheme(models.Model):
> nom = models.CharField(max_length=100)
> slug = models.SlugField(max_length=100)
> visible = models.BooleanField("Visible",default = False)
>   
>
> views : 
>
>
> def page(request):
>
> categs = Categorie.objects.filter(visible=True)
>
> return render(request, 'page.html', locals())
>
> templates (simplify) : 
>
> {% for categ in categs %}
> {% with currscat=categ.getscateg %} 
>
>  {{categ.nom}}  
> # This line hit database
>
> {% if currscat %} # This line hit database 
>
>
>
>{% for souscateg in currscat %} 
>{% with currth=souscateg.gettheme %}
>
> 
> {{souscateg.nom}}  #This l

Re: Where does the static files reside

2015-11-08 Thread Gary Roach

On 11/07/2015 04:29 PM, René Fleschenberg wrote:

Hi Gary,

In your second example:

├── archive
│   ├── archive
│   │   ├── __init__.py
│   │   ├── settings.py
│   │   ├── urls.py
│   │   └── wsgi.py
│   ├── home
│   ├── static
|   | |___home
│   │ ├── home.css
│   │ ├── images

you have what I would call a "global" static files directory. Files from
this directory will only be found if you configure that directory in your
settings:

STATICFILES_DIRS = (
 os.path.join(BASE_DIR, "static"),
)

This is because that directory is not part of any app that is listed in
INSTALLED_APPS.

BASE_DIR is the top-level "archive" directory, by the way (the first
"archive" in the tree).

I hope this helps.


Because this gets asked so often, I am trying to  to sump it up here:

https://fleschenberg.net/django-staticfiles/

I'd love to hear your feedback about this article, i.e. if it clarifies
things for you, or how to improve it.

Thanks for the tips. I read your 'In a nutshell" . Good work. Now, 
getting into setup philosophy, it occurs to me that it would be nice to 
have  global static files for such things as a style.css file since the 
file should set the style of your whole web site. I suppose that one 
could put a copy of the file under each apps static folder but change 
control would be horrible. Could I set up both a global static folder 
and then have a static folder under each app? Being rather new to this 
rats nest (great framework all the same) I'm probably skating on rather 
thin ice here. Be kind.


As to your comment on the first tree, I think I created the problem 
while cutting and pasting. The actual project works - mostly.


A comment on "6 An alternative approach". This actually my case. When 
you say that the app listed first takes precedence.


Looking forward to your comments.

Gary R

--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/563F6DA5.1050909%40verizon.net.
For more options, visit https://groups.google.com/d/optout.


Re: Where does the static files reside

2015-11-08 Thread Andreas Kuhne
Hi Gary,

You can certainly setup a global static files location. All you need to do
is add a path to STATICFILES_DIRS in your settings file. However, that is
not really necessary. All files that are in a static directory in one app
are accessible in other apps. You can create an app that contains css and
js files needed for the other apps and concentrate them in one app. The
only thing you need to think about is if you want to make sure that the
apps are completely unconnected.

Regards,

Andréas

2015-11-08 16:43 GMT+01:00 Gary Roach :

> On 11/07/2015 04:29 PM, René Fleschenberg wrote:
>
>> Hi Gary,
>>
>> In your second example:
>>
>>> ├── archive
>>> │   ├── archive
>>> │   │   ├── __init__.py
>>> │   │   ├── settings.py
>>> │   │   ├── urls.py
>>> │   │   └── wsgi.py
>>> │   ├── home
>>> │   ├── static
>>> |   | |___home
>>> │   │ ├── home.css
>>> │   │ ├── images
>>>
>> you have what I would call a "global" static files directory. Files from
>> this directory will only be found if you configure that directory in your
>> settings:
>>
>> STATICFILES_DIRS = (
>>  os.path.join(BASE_DIR, "static"),
>> )
>>
>> This is because that directory is not part of any app that is listed in
>> INSTALLED_APPS.
>>
>> BASE_DIR is the top-level "archive" directory, by the way (the first
>> "archive" in the tree).
>>
>> I hope this helps.
>>
>>
>> Because this gets asked so often, I am trying to  to sump it up here:
>>
>> https://fleschenberg.net/django-staticfiles/
>>
>> I'd love to hear your feedback about this article, i.e. if it clarifies
>> things for you, or how to improve it.
>>
>> Thanks for the tips. I read your 'In a nutshell" . Good work. Now,
> getting into setup philosophy, it occurs to me that it would be nice to
> have  global static files for such things as a style.css file since the
> file should set the style of your whole web site. I suppose that one could
> put a copy of the file under each apps static folder but change control
> would be horrible. Could I set up both a global static folder and then have
> a static folder under each app? Being rather new to this rats nest (great
> framework all the same) I'm probably skating on rather thin ice here. Be
> kind.
>
> As to your comment on the first tree, I think I created the problem while
> cutting and pasting. The actual project works - mostly.
>
> A comment on "6 An alternative approach". This actually my case. When you
> say that the app listed first takes precedence.
>
> Looking forward to your comments.
>
> Gary R
>
> --
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/563F6DA5.1050909%40verizon.net
> .
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALXYUb%3D3N%3D4ZRVv9ChR4PJDAOEy2aXMm%2B4ERt%3DWMEUasnbaYig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Managing and synchronising users on multiple sites

2015-11-08 Thread Stodge
I have several Django sites and I need to synchronize user accounts across them 
all. I need the ability to create the same user on all sites at the same time 
and also to keep their info in sync. The servers are in different locations in 
DMZs and can't open connections to external servers. So no third party access. 
I thought I could write a Java app that uses a REST API to query and update 
accounts to synchronize them but that opens a security issue as I have to 
expose the ability to read/write passwords. I can't think of any other 
solutions - any ideas? Thanks

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


finding information on modules, imports, etc.

2015-11-08 Thread Gary Roach

I can't seem to find a "dictionary" of modules? or what ever on the use of:

import os or other possible imports

from django.contrib  import admin possibilities.>


Maybe I'm using the wrong terminology but after a gazillion searches, I 
still haven't found a decent reference.


Any help to this relatively new user would be sincerely appreciated.


Gary R.

--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/563F8575.1000208%40verizon.net.
For more options, visit https://groups.google.com/d/optout.


Re: Managing and synchronising users on multiple sites

2015-11-08 Thread Gergely Polonkai
How about an SSO solution hosted at one of the sites? When the user logs
in, the site authenticates them against the SSO, and fetches user data. See
Stack Exchange sites (Stack Overflow, Server Fault, etc) as an example.
On 8 Nov 2015 18:24, "Stodge"  wrote:

> I have several Django sites and I need to synchronize user accounts across
> them all. I need the ability to create the same user on all sites at the
> same time and also to keep their info in sync. The servers are in different
> locations in DMZs and can't open connections to external servers. So no
> third party access. I thought I could write a Java app that uses a REST API
> to query and update accounts to synchronize them but that opens a security
> issue as I have to expose the ability to read/write passwords. I can't
> think of any other solutions - any ideas? Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c05af7b9-965c-47d9-9106-524a1e6cd46d%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUKsafmFD1BCjZy97q42SME2-t-0-ao5-rf6w4T%2BME%3Dbew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: finding information on modules, imports, etc.

2015-11-08 Thread Gergely Polonkai
It's a bit unclear what you want to do. Could you write a use case? I'm
afraid of an XY problem here…
On 8 Nov 2015 18:25, "Gary Roach"  wrote:

> I can't seem to find a "dictionary" of modules? or what ever on the use of:
>
> import os or other possible imports
>
> from django.contrib  import admin  possibilities.>
>
> Maybe I'm using the wrong terminology but after a gazillion searches, I
> still haven't found a decent reference.
>
> Any help to this relatively new user would be sincerely appreciated.
>
>
> Gary R.
>
> --
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/563F8575.1000208%40verizon.net
> .
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBULYKLmZ4bB%2BqDQAQqZjFPF2TN7ciyhhjBPb5k7TZSapDQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Best practices for writing functional tests to exercise forms?

2015-11-08 Thread Tim Chase
On 2015-11-06 01:09, Carl Meyer wrote:
> I recommend the WebTest package [1], along with django-webtest [2]
> to adapt it for use with Django.
> 
> [1] https://pypi.python.org/pypi/WebTest
> [2] https://pypi.python.org/pypi/django-webtest

Thanks for your suggestions, Carl.  I'll check them out as it sounds
like they do at least some of what I want to do.

-tkc





-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20151108132108.6c239228%40bigbox.christie.dr.
For more options, visit https://groups.google.com/d/optout.


Django on CentOS

2015-11-08 Thread Robin Fourcade
Hello,
I'm trying to run my django project on my CentOS server.

I followed this tutorial 
: 
http://www.science-emergence.com/LeWebFrameworkDjango/DeployerUneApplicationDjangoSurCentos/#deployer-votre-application-django

And at the end, they say that I just have to enter my server IP address and 
I'll have access to my project, but I only have a 500 error: *Internal 
Server Error*

However, when I shutdown apache and run: python manage.py runsever 
0.0.0.0:80, everything works fine.

How is it possible to do without runsever, because I read somewhere that it 
what not the right thing to do.

Can somebody help me ?

Thanks,
Robin Fourcade.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/638bd85d-6ac4-4ee9-8a54-69f33dda08c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django on CentOS

2015-11-08 Thread James Schneider
On Nov 8, 2015 11:25 AM, "Robin Fourcade"  wrote:
>
> Hello,
> I'm trying to run my django project on my CentOS server.
>
> I followed this tutorial :
http://www.science-emergence.com/LeWebFrameworkDjango/DeployerUneApplicationDjangoSurCentos/#deployer-votre-application-django
>
> And at the end, they say that I just have to enter my server IP address
and I'll have access to my project, but I only have a 500 error: Internal
Server Error
>

What do your Apache access and error logs have to say?

> However, when I shutdown apache and run: python manage.py runsever
0.0.0.0:80, everything works fine.
>

Then it is likely an issue with your Apache setup.

> How is it possible to do without runsever, because I read somewhere that
it what not the right thing to do.

You are correct. Apache or another production grade web server should be
used when your site is made available on the Internet.

>
> Can somebody help me ?
>
> Thanks,
> Robin Fourcade.
>
> --

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUzJRhdMO8qKBjZQ1F2n0Op9eT%2B%3DkJR_iKA31jJ2rgKKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Managing and synchronising users on multiple sites

2015-11-08 Thread Stodge
The servers are in DMZs in different cities. I don't control the firewall 
configuration and I'm not allowed to open extra ports.

On Sunday, 8 November 2015 14:18:37 UTC-5, Gergely Polonkai  wrote:
> How about an SSO solution hosted at one of the sites? When the user logs in, 
> the site authenticates them against the SSO, and fetches user data. See Stack 
> Exchange sites (Stack Overflow, Server Fault, etc) as an example.
> 
> On 8 Nov 2015 18:24, "Stodge"  wrote:
> I have several Django sites and I need to synchronize user accounts across 
> them all. I need the ability to create the same user on all sites at the same 
> time and also to keep their info in sync. The servers are in different 
> locations in DMZs and can't open connections to external servers. So no third 
> party access. I thought I could write a Java app that uses a REST API to 
> query and update accounts to synchronize them but that opens a security issue 
> as I have to expose the ability to read/write passwords. I can't think of any 
> other solutions - any ideas? Thanks
> 
> 
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> 
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@googlegroups.com.
> 
> To post to this group, send email to django...@googlegroups.com.
> 
> Visit this group at http://groups.google.com/group/django-users.
> 
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/c05af7b9-965c-47d9-9106-524a1e6cd46d%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5cd372d7-9b36-4fe2-8381-dfcd69e63eba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django on CentOS

2015-11-08 Thread Robin Fourcade
Hi,
Thanks for your answer !
(I'd add that even if apache is running, if I run the server on the port 
8000, I can acces the django project on this port without any issue)

Here's the log

[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] mod_wsgi 
(pid=22420): Exception occurred processing WSGI script 
'/var/www/html/pizzaclub/public/pizzaclub.wsgi'.
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] Traceback (most 
recent call last):
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 219, 
in __call__
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] 
self.load_middleware()
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 37, 
in load_middleware
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] for 
middleware_path in settings.MIDDLEWARE_CLASSES:
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/utils/functional.py", line 184, in 
inner
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] self._setup()
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 42, in 
_setup
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] self._wrapped 
= Settings(settings_module)
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 95, in 
__init__
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] raise 
ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % 
(self.SETTINGS_MODULE, e))
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] ImportError: 
Could not import settings 'pizzaclub.settings' (Is it on sys.path?): No 
module named pizzaclub.settings
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] mod_wsgi 
(pid=22420): Exception occurred processing WSGI script 
'/var/www/html/pizzaclub/public/pizzaclub.wsgi'., referer: 
http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] Traceback (most 
recent call last):, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 219, 
in __call__, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] 
self.load_middleware(), referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 37, 
in load_middleware, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] for 
middleware_path in settings.MIDDLEWARE_CLASSES:, referer: 
http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/utils/functional.py", line 184, in 
inner, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] 
self._setup(), referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 42, in 
_setup, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] self._wrapped 
= Settings(settings_module), referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 95, in 
__init__, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] raise 
ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % 
(self.SETTINGS_MODULE, e)), referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] ImportError: 
Could not import settings 'pizzaclub.settings' (Is it on sys.path?): No 
module named pizzaclub.settings, referer: http://212.227.107.82/
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52] mod_wsgi 
(pid=22420): Exception occurred processing WSGI script 
'/var/www/html/pizzaclub/public/pizzaclub.wsgi'.
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52] Traceback (most 
recent call last):
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 219, 
in __call__
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52] 
self.load_middleware()
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 37, 
in load_middleware
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52] for 
middleware_path in settings.MIDDLEWARE_CLASSES:
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-p

Copy table data in moodels in django project

2015-11-08 Thread Bhanu Kathuria
I have crawled some data and stored it in table using phpmyadmin. How can I 
copy that data in a model in my djangoproject.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c6ee754c-9b35-4e01-a7b6-99bd08d696c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Managing and synchronising users on multiple sites

2015-11-08 Thread Gergely Polonkai
I meant web based SSO :) The aforementioned Stack Exchange sites work like
this; when you authenticate to one of their sites, you actually
authenticate to Stack Exchange, which sets a cookie that is processed by
the sites. This can be done by one of the already available web servers
(although a separate one would be the best)
On 8 Nov 2015 21:09, "Stodge"  wrote:

> The servers are in DMZs in different cities. I don't control the firewall
> configuration and I'm not allowed to open extra ports.
>
> On Sunday, 8 November 2015 14:18:37 UTC-5, Gergely Polonkai  wrote:
> > How about an SSO solution hosted at one of the sites? When the user logs
> in, the site authenticates them against the SSO, and fetches user data. See
> Stack Exchange sites (Stack Overflow, Server Fault, etc) as an example.
> >
> > On 8 Nov 2015 18:24, "Stodge"  wrote:
> > I have several Django sites and I need to synchronize user accounts
> across them all. I need the ability to create the same user on all sites at
> the same time and also to keep their info in sync. The servers are in
> different locations in DMZs and can't open connections to external servers.
> So no third party access. I thought I could write a Java app that uses a
> REST API to query and update accounts to synchronize them but that opens a
> security issue as I have to expose the ability to read/write passwords. I
> can't think of any other solutions - any ideas? Thanks
> >
> >
> >
> > --
> >
> > You received this message because you are subscribed to the Google
> Groups "Django users" group.
> >
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com.
> >
> > To post to this group, send email to django...@googlegroups.com.
> >
> > Visit this group at http://groups.google.com/group/django-users.
> >
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c05af7b9-965c-47d9-9106-524a1e6cd46d%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5cd372d7-9b36-4fe2-8381-dfcd69e63eba%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUJ_TCH3jJczBUf%2BzLViTsVF1nzTsN%2Bzn7aKDTnsjp5akA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django on CentOS

2015-11-08 Thread Gergely Polonkai
Hello,

no, the problem is here:

[Sun Nov 08 14:46:43 2015] [error] [client 109.10.154.52] ImportError:
Could not import settings 'pizzaclub.settings' (Is it on sys.path?): No
module named pizzaclub.settings, referer:http 
://212.227.107.82/ 

It seems that your settings file is either missing, or Apache is
misconfigured so mod_wsgi can not find it.
On 8 Nov 2015 21:59, "Robin Fourcade"  wrote:

> Hi,
> Thanks for your answer !
> (I'd add that even if apache is running, if I run the server on the port
> 8000, I can acces the django project on this port without any issue)
>
> Here's the log
>
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] mod_wsgi
> (pid=22420): Exception occurred processing WSGI script
> '/var/www/html/pizzaclub/public/pizzaclub.wsgi'.
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] Traceback (most
> recent call last):
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File
> "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 219,
> in __call__
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]
> self.load_middleware()
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File
> "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 37,
> in load_middleware
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] for
> middleware_path in settings.MIDDLEWARE_CLASSES:
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File
> "/usr/lib/python2.6/site-packages/django/utils/functional.py", line 184, in
> inner
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] self._setup()
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File
> "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 42, in
> _setup
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]
> self._wrapped = Settings(settings_module)
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File
> "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 95, in
> __init__
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] raise
> ImportError("Could not import settings '%s' (Is it on sys.path?): %s" %
> (self.SETTINGS_MODULE, e))
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] ImportError:
> Could not import settings 'pizzaclub.settings' (Is it on sys.path?): No
> module named pizzaclub.settings
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] mod_wsgi
> (pid=22420): Exception occurred processing WSGI script
> '/var/www/html/pizzaclub/public/pizzaclub.wsgi'., referer:
> http://212.227.107.82/
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] Traceback (most
> recent call last):, referer: http://212.227.107.82/
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File
> "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 219,
> in __call__, referer: http://212.227.107.82/
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]
> self.load_middleware(), referer: http://212.227.107.82/
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File
> "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 37,
> in load_middleware, referer: http://212.227.107.82/
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] for
> middleware_path in settings.MIDDLEWARE_CLASSES:, referer:
> http://212.227.107.82/
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File
> "/usr/lib/python2.6/site-packages/django/utils/functional.py", line 184, in
> inner, referer: http://212.227.107.82/
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]
> self._setup(), referer: http://212.227.107.82/
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File
> "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 42, in
> _setup, referer: http://212.227.107.82/
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]
> self._wrapped = Settings(settings_module), referer: http://212.227.107.82/
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File
> "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 95, in
> __init__, referer: http://212.227.107.82/
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] raise
> ImportError("Could not import settings '%s' (Is it on sys.path?): %s" %
> (self.SETTINGS_MODULE, e)), referer: http://212.227.107.82/
> [Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] ImportError:
> Could not import settings 'pizzaclub.settings' (Is it on sys.path?): No
> module named pizzaclub.settings, referer: http://212.227.107.82/
> [Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52] mod_wsgi
> (pid=22420): Exception occurred processing WSGI script
> '/var/www/html/pizzaclub/public/pizzaclub.wsgi'.
> [Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52] Traceback (most
> recent call last):
> [Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52]   File

Search capability on Django 3.1.3 (Haystack)

2015-11-08 Thread nAncy sharma
Hi there,

I am building a website using Django cms 3.1.3 !
I am facing problem in implementing search capability (Haystack 
elasticsearch) .Could you provide me with someuseful links? And is the 
Django cms VERSION (3.1.3) also an issue because of which i am not able to 
implement it ?

Thank you in advance!

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/196c68ea-7510-40b8-ac28-9f38a813d4ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: duplicated queries

2015-11-08 Thread James Schneider
The reason that you are seeing multiple hits on the database is due to the
way that your template loops are built. The {% with %} statements are
calling a method on your model, which is returning a fresh queryset for
every iteration of the for loop (which is then compounded by the inner {%
with %} calls and more inner {% for %} loops. The fresh querysets are then
evaluated, causing excessive (and unnecessary) database hits. Any
prefetch_related() action within your view would result in the behavior
you've seen, only adding more database queries to pull data that is never
used since you are requesting fresh querysets on every loop in the template.

I believe what you'll need to do is filter and prefetch all of the rows
from the various models using Prefetch() objects. Let's see if I can work
this out, YMMV, I'm typing this as I go based on the models you sent out
almost 24 hours ago:

###
# view code - see
https://docs.djangoproject.com/en/1.8/ref/models/querysets/#prefetch-related
section regarding the Prefetch object
###
# add this to your imports
from django.db.models import Prefetch

# Note that these Prefetch() objects act as your filters for the related
objects, so we don't need to add them to the Categorie filter
pf_souscategorie = Prefetch('souscategorie_set',
SousCategorie.objects.filter(visible=True)) # prefetch only visible
SousCategorie's
pf_theme = Prefetch('souscategorie_set__theme_set',
Theme.objects.filter(visible=True)) # prefetch only visible Theme's
pf_soustheme = Prefetch('souscategorie_set__theme_set__soustheme_set',
SousTheme.objects.filter(visible=True)) # prefetch only visible SousTheme's

# Here were filtering on visible Categorie's, related objects are filtered
by the Prefetch() objects above
categs =
Categorie.objects.filter(visible=True).prefetch_related(pf_souscategorie,
pf_theme, pf_soustheme)

###
# template code - I removed the blank lines and reduced the indentation for
readability in an email.
###

{% for categ in categs %}
  {% with currscat=categ.souscategorie_set.all %}
 {{categ.nom}}
  {% if currscat %} # This line hit database
  
   {% for souscateg in currscat %}
   {% with currth=souscateg.theme_set.all %}
 
{{souscateg.nom}}
   {% if currth %} # this line hit database
 
   ..
   {# Assuming you would loop through currth here to get
all of the soustheme's, use same strategy as above, otherwise, remove the
reference to pf_soustheme above in the view #}
 
   {% endif %}
 
   {% endwith %}
   {% endfor %}
  
  {% endif %}

  {% endwith %}
{% endfor %}


Hopefully that works out for you. I did test Prefetch() against multiple
levels of reverse relationships in my own project, and it appeared to work
as expected.

Another related but tangent thought: Your parent and child models (ie Theme
and SousTheme) appear to be the same model, but one is considered a 'child'
of the other purely by virtue of the FK relationship. You could potentially
eliminate the 'Sous' models and use a M2M relationship with 'self' in
asymmetric mode to capture the parent/child relationship. It would save you
a table and a reverse relationship query in situations like this. It would
also allow you to add more levels to the relationship (parents, children,
grandchildren, and so on). Just a thought.

https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ManyToManyField.symmetrical

You could also look at implementing an MPTT model, which is often used for
hierarchical objects like categories.
http://django-mptt.github.io/django-mptt/overview.html#what-is-modified-preorder-tree-traversal
as an example.

HTH,

-James


On Sun, Nov 8, 2015 at 3:46 AM, V1ce  wrote:

>
> I post here my real models for better comprehension (and have cleaned it
> this morning with an abstract class)
>
> class Rubrique(models.Model):
> nom = models.CharField(max_length=30)
> slug = models.SlugField(max_length=100)
> page = models.CharField(max_length=50, null=True)
> description = RichTextField(null=True, blank = True)
> metaDesc = models.TextField("Balise meta description",null=True, blank
> = True)
> position = models.PositiveSmallIntegerField("Position",default =
> 0,null=True, blank = True)
> visible = models.BooleanField("Visible",default = False)
> redirect = models.CharField("Redirection",max_length=200, null=True,
> blank = True)
> created = models.DateTimeField(_('Date de création'),editable=False)
> modified  = models.DateTimeField(_('Dernière
> modification'),editable=False)
>
> def __str__(self):
> return self.nom
>
> class Meta(object):
> abstract = True
> ordering = ('position',)
>
> class Categorie(Rubrique):
> develop = models.BooleanField(_('develop?'), default=True, blank=True)
> is_clickable = mode