Re: duplicated queries

2015-11-09 Thread James Schneider
>
> ###
> # 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
>

Sorry, I was re-reading the answer and thought I removed all of the
comments about hitting the database from your template code. This is the
original comment you put in, not one I inserted. I don't believe the
template will incur any further database hits if the pre-fetching works.

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


Re: Django on CentOS

2015-11-09 Thread Robin Fourcade
Hello, thanks for the answer.

I've this code in my wsgi:

import os, sys
#Calculate the path based on the location of the WSGI script
apache_configuration = os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(workspace)

os.environ['DJANGO_SETTINGS_MODULE'] = 'pizzaclub.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

And I don't know how to find the error as it works well when I run the 
project with manage.py.

My settings file is there:
/var/www/html/pizzaclub/pizza_club/settings.py

I just added this in httpd.conf:

Include "/var/www/html/pizzaclub/public/django_wsgi.conf"


and this in the wsgi:

Alias /static/ /var/www/html/pizzaclub/public/static/
Alias /media/ "/var/www/html/pizzaclub/public/media/"

WSGIScriptAlias / "/var/www/html/pizzaclub/public/pizzaclub.wsgi"
WSGIPythonPath 
/var/www/html/emergence/:/var/www/html/pizzaclub/pizza_club:/var/www/html/pizzaclub/pizza_club/db:/var/www/html/pizzaclub/public/media:/var/www/html/pizzaclub/apache:/usr/bin/python


Allow from all


Thanks again for your help.


-- 
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/ec3bba44-a637-48e5-9636-ff5ffadd13e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Merging Codeigniter withe Django

2015-11-09 Thread Russell Keith-Magee
Hi Masum,

On Sat, Nov 7, 2015 at 4:25 PM, Masum Hasan  wrote:

> Hi,
>
> I have a class project partially done with Django, but my lab partner has
> done her part in Codeigniter. I was wondering if it is possible to merge
> these two and complete the project?
> Any thought would help. Thank you in advance
>

It depends :-)

You’re not going to get a completely seamless merge - you’re not going to
be able to “import” your Django code into her Codeigniter project, or vice
versa.

However, you might be able to deploy a site that is “split down the middle”
by doing a bit of fancy web server configuration. For example, you could
configure your Django application to serve the homepage, and all URLs under
/foo; and configure the CodeIgniter project to serve all the urls under
/bar, but run them both in the same Apache instance. If you have similar
looking templates, the end-user won’t notice when they move from one
implementation to the other.

Two big areas of friction will be:

1) When someone logs in, you’ll need to make sure that they’re logged in to
both systems, and whatever login credentials you use can be shared. I don’t
know anything about CodeIgniter, but Django’s authentication backends are
fairly configurable, so you should be able to accommodate this.

2) If there is any shared data between the two projects, you’ll probably
need to make both projects talk to the same database. Django provides tools
like inspectdb and managed=False to help deal with legacy or external
database sources,

There will probably be other areas of friction too, depending on the nature
of your projects.

As an aside, with my
used-to-be-a-university-lecturer-and-is-now-a-grumpy-old-man hat on… :-)
One of the reasons you are assigned group projects is to teach you how to
collaborate. 2 people picking different web frameworks, and then trying to
smash them together at the end… that suggests to me that you’ve just missed
the point of the project. This is the sort of problem that should be
resolved at the start of the project, not patched over at the end.

Yours,
Russ Magee %-)

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


Re: Prefetch object with to_attr set to the same name as the field triggers rows deletions

2015-11-09 Thread Michele Ciccozzi
Hello Simon,

Thank you very much for this very interesting follow-up: it's like everyday
there's a new reason to keep digging in the source code!
I'll see you there ;)

All the best,
Michele

On Sat, Nov 7, 2015 at 11:35 AM, Simon Charette 
wrote:

> Hi Michele,
>
> I don't if someone beat you to it but a ticket for this exact issue just
> surfaced[1].
>
> Please chime in on Trac if you'd like to follow the progress of the
> resolution.
>
> Thanks,
> Simon
>
> [1] https://code.djangoproject.com/ticket/25693
>
> Le vendredi 6 novembre 2015 11:01:35 UTC+1, mccc a écrit :
>>
>> Thank you very much, Simon, for the detailed answer.
>> Now I'm digging through Django code, pull requests, and tickets, and it's
>> all very interesting.
>> Thank you also for the reminder of incoming deprecations: we'll
>> definitely be on the lookout for that!
>>
>> All the best,
>> Michele
>>
>> On Fri, Nov 6, 2015 at 12:00 AM, Simon Charette 
>> wrote:
>>
>>> Bonsoir Michele,
>>>
>>> I'll try to explain what happens here with a simplified model definition
>>> assuming you are using Django 1.8. I used a GenericRelation like your
>>> provided example but this issue can be triggered for about any M2M
>>> relationship.
>>>
>>> Given the following models:
>>>
>>> from django.db import models
>>> from django.contrib.contenttypes.fields import (
>>> GenericForeignKey, GenericRelation
>>> )
>>> from django.contrib.contenttypes.models import ContentType
>>>
>>> class TaggedItem(models.Model):
>>> tag = models.SlugField()
>>> content_type = models.ForeignKey(ContentType)
>>> object_id = models.PositiveIntegerField()
>>> content_object = GenericForeignKey('content_type', 'object_id')
>>>
>>> class Bookmark(models.Model):
>>> url = models.URLField()
>>> tags = GenericRelation(TaggedItem)
>>>
>>> Assigning directly to a Bookmark instance tags attribute (a 
>>> ReverseGenericRelatedObjectsDescriptor
>>> instance) will result in a delete query followed by multiple insert or
>>> update queries
>>> 
>>> depending on whether they exist or not. For example:
>>>
>>> >>> b = Bookmark.objects.create(url='www.djangoproject.com')
>>> >>> # The following line will result in the following queries:
>>> >>> # 1) DELETE FROM bookmark WHERE id = b.id;
>>> >>> # 2) INSERT INTO taggeditem ...;
>>> >>> # 3) INSERT INTO taggeditem ...;
>>> >>> b.tags = [TaggedItem(tag='Python'), TaggedItem(tag='Web')]
>>>
>>> Note that the DELETE query is not run as of 1.9 since Django now
>>> performs updates in 'bulk' instead (that is comparing the existing
>>> relationship with this specified value and only perform the required
>>> insert/update).
>>>
>>> Now, as documented, when you specify a `to_attr` Django simply uses
>>> `setattr()` onder de motorkap and ends up triggering the code path
>>> described above if the specified attribute happens to be a reverse
>>> relationship descriptor. Note that is behavior will be deprecated in
>>> Django 1.10 and removed in Django 2.0.
>>> 
>>>
>>> I have to say I'm unsure how we should proceed here. I guess I would
>>> favor raising a ValueError if the model the list of prefetched objects will
>>> be attached to has a reverse descriptor for the specified `to_attr` at
>>> least until this behavior is deprecated since it looks like a major footgun
>>> to me.
>>>
>>> I guess we should move the discussion to the development mailing list
>>>  to gather
>>> feedback.
>>>
>>> Au plaisir,
>>> Simon
>>>
>>>
>>> Le jeudi 5 novembre 2015 17:17:04 UTC+1, mccc a écrit :
>>>
 Hello Simon,

 I'm going to paste a trimmed-down version of the involved classes:

 class CeleryTask(models.Model):
 celery_task_id = models.CharField(max_length=50, primary_key=True)
 task_type = models.ForeignKey(ContentType)
 task_id = models.PositiveIntegerField()
 task = GenericForeignKey('task_type', 'task_id')

 class AccountManagementTask(models.Model):
 account = models.ForeignKey(Account, null=True, editable=False)
 task_content_type = models.ForeignKey(ContentType)
 task_content_id = models.PositiveIntegerField()
 task_content = GenericForeignKey('task_content_type',
 'task_content_id')
 celery_task = GenericRelation(CeleryTask,
 content_type_field='task_type', object_id_field='task_id',

 related_query_name='account_management_tasks')

 (the task_content thing is involved in a follow-up question that will
 be asked in a short while)

 This is the code triggering the weirdness:

 previous_tasks =
 AccountManagementTask.objects.filter(account=account)\
 .prefetch_related(
 Prefetch('celery

Re: Django on CentOS

2015-11-09 Thread Gergely Polonkai
Hello,

there’s a lot that is not clear for me in your included config:

• Why are all those paths in WSGIPythonPath?
• Are there Python modules in those directories?
• Do I get it right that your application is installed under /var/www
(which is generally a bad idea)?
• Is pizzaclub/settings.py available if you stand in any of those
directories? (Ie. try cd ; ls pizzaclub/settings.py)

Best,
Gergely

2015-11-09 9:48 GMT+01:00 Robin Fourcade :

> Hello, thanks for the answer.
>
> I've this code in my wsgi:
>
> import os, sys
> #Calculate the path based on the location of the WSGI script
> apache_configuration = os.path.dirname(__file__)
> project = os.path.dirname(apache_configuration)
> workspace = os.path.dirname(project)
> sys.path.append(workspace)
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'pizzaclub.settings'
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
>
> And I don't know how to find the error as it works well when I run the
> project with manage.py.
>
> My settings file is there:
> /var/www/html/pizzaclub/pizza_club/settings.py
>
> I just added this in httpd.conf:
>
> Include "/var/www/html/pizzaclub/public/django_wsgi.conf"
>
>
> and this in the wsgi:
>
> Alias /static/ /var/www/html/pizzaclub/public/static/
> Alias /media/ "/var/www/html/pizzaclub/public/media/"
>
> WSGIScriptAlias / "/var/www/html/pizzaclub/public/pizzaclub.wsgi"
> WSGIPythonPath
> /var/www/html/emergence/:/var/www/html/pizzaclub/pizza_club:/var/www/html/pizzaclub/pizza_club/db:/var/www/html/pizzaclub/public/media:/var/www/html/pizzaclub/apache:/usr/bin/python
>
> 
> Allow from all
> 
>
> Thanks again for your help.
>
>
> --
> 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/ec3bba44-a637-48e5-9636-ff5ffadd13e6%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/CACczBULzD%2BOH0viJBB5hTxEedWj%2B4umH24sDzON9AJKeVTdUzQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django on CentOS

2015-11-09 Thread James Schneider
On Sun, Nov 8, 2015 at 12:59 PM, 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)
>
>
That simply means that the Django runserver management command has found
all of the right pieces to run, and is (mostly) irrelevant to running your
site using Apache/mod_wsgi.



> 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
>
>
Aside from the path import issue that Gergely already pointed out, you
actually have a larger problem. The version of mod_wsgi that Apache is
using is compiled against the wrong version of Python per your mention of
Python 2.7. Even with tweaking the location of the Python interpreter to a
newer version, mod_wsgi needs to be compiled against the same version that
you are running. This means you need to either find an RPM that does this
for you somewhere, or you need to recompile mod_wsgi yourself against the
version of Python you presumably installed manually.

This guide may help, although I've never done this myself and I can't vouch
for its accuracy (especially given the typo in the URL). YMMV:
https://www.fir3net.com/Programming/Python/how-do-i-compile-modwgsi-for-python-27.html



> I think I've an issue with the python version. I installed django on
> python 2.7, but even if I make alias python=/usr/local/bin/python2.7, the
> log still shows python2.6, CentOS doesn't want to use the 2.7 version by
> default, even if I have this:
>
> python --version
>
> Python 2.7.8
>

Creating an alias will only affect your particular user environment (and
creating an alias in that manner will likely break other things on the
system you are trying to do that are expecting 2.6). Apache is running as a
different user and does not have a shell environment where aliases can be
applied. Either upgrade CentOS to a newer release that includes a more
recent version of Python by default (which would include a matching version
of mod_wsgi for Apache), or recompile mod_wsgi.

Reverting to an older version of Django is also not an option because none
of the currently supported Django versions work with Python 2.6 (1.4LTS
ended on Oct. 1, 2015).

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


Re: Django on CentOS

2015-11-09 Thread Robin Fourcade
Hi And thanks for your answer.

Le lundi 9 novembre 2015 10:51:01 UTC+1, Gergely Polonkai a écrit :
>
> Hello,
>
> there’s a lot that is not clear for me in your included config:
>
> • Why are all those paths in WSGIPythonPath?
>

I'm not used to install django projects so I followed this 
tutorial: 
http://www.science-emergence.com/LeWebFrameworkDjango/DeployerUneApplicationDjangoSurCentos/#deployer-votre-application-django

I copy-pasted django_wsgi.conf they gave here, and I replaced by the right 
paths.

• Are there Python modules in those directories?
>

Here's all my project:

+--- pizzaclub

|   +--- pizza_club

|   |   +--- settings.py

|   |   +--- wsgi.pyc

|   |   +--- settings.pyc

|   |   +--- wsgi.py

|   |   +--- __init__.pyc

|   |   +--- __init__.py

|   |   +--- templates

|   +--- public

|   |   +--- static

|   |   |   +--- fonts

|   |   |   +--- admin

|   |   |   |   +--- img

|   |   |   |   +--- js

|   |   |   |   +--- css

|   |   |   |   |   +--- base.css

|   |   |   +--- js

|   |   |   +--- css

|   |   +--- statics

|   |   |   +--- fonts

|   |   |   +--- admin

|   |   |   |   +--- js

|   |   |   |   |   +--- jquery.js

|   |   |   |   |   +--- timeparse.js

|   |   |   |   |   +--- actions.js

|   |   |   |   |   +--- collapse.js

|   |   |   |   |   +--- related-widget-wrapper.js

|   |   |   |   |   +--- admin

|   |   |   |   |   |   +--- DateTimeShortcuts.js

|   |   |   |   |   |   +--- RelatedObjectLookups.js

|   |   |   |   |   +--- LICENSE-JQUERY.txt

|   |   |   |   |   +--- urlify.js

|   |   |   |   |   +--- inlines.min.js

|   |   |   |   |   +--- jquery.init.js

|   |   |   |   |   +--- jquery.min.js

|   |   |   |   |   +--- core.js

|   |   |   |   |   +--- prepopulate.min.js

|   |   |   |   |   +--- collapse.min.js

|   |   |   |   |   +--- inlines.js

|   |   |   |   |   +--- SelectFilter2.js

|   |   |   |   |   +--- actions.min.js

|   |   |   |   |   +--- calendar.js

|   |   |   |   |   +--- SelectBox.js

|   |   |   |   |   +--- prepopulate.js

|   |   |   |   +--- css

|   |   |   |   |   +--- dashboard.css

|   |   |   |   |   +--- changelists.css

|   |   |   |   |   +--- forms.css

|   |   |   |   |   +--- widgets.css

|   |   |   |   |   +--- rtl.css

|   |   |   |   |   +--- login.css

|   |   |   |   |   +--- ie.css

|   |   |   |   |   +--- base.css

|   |   |   +--- js

|   |   |   |   +--- bootstrap.js

|   |   |   |   +--- bootstrap.min.js

|   |   |   |   +--- npm.js

|   |   |   +--- css

|   |   |   |   +--- styles.css

|   |   +--- urls.pyc

|   |   +--- media

|   |   +--- django_wsgi.conf

|   |   +--- __init__.pyc

|   |   +--- pizzaclub.wsgi

|   |   +--- urls.py

|   |   +--- __init__.py

|   +--- pizza_club_order

|   |   +--- migrations

|   |   |   +--- 0003_commande_cout.pyc

|   |   |   +--- 0003_commande_cout.py

|   |   |   +--- 0002_transaction.py

|   |   |   +--- 0006_pizza_taille.pyc

|   |   |   +--- 0002_transaction.pyc

|   |   |   +--- 0007_heures.py

|   |   |   +--- 0004_auto_20151025_2251.pyc

|   |   |   +--- __init__.pyc

|   |   |   +--- 0004_auto_20151025_2251.py

|   |   |   +--- 0005_auto_20151025_2251.py

|   |   |   +--- 0007_heures.pyc

|   |   |   +--- 0005_auto_20151025_2251.pyc

|   |   |   +--- __init__.py

|   |   |   +--- 0001_initial.pyc

|   |   |   +--- 0006_pizza_taille.py

|   |   |   +--- 0001_initial.py

|   |   +--- models.pyc

|   |   +--- admin.py

|   |   +--- urls.pyc

|   |   +--- views.pyc

|   |   +--- forms.pyc

|   |   +--- admin.pyc

|   |   +--- models.py

|   |   +--- __init__.pyc

|   |   +--- views.py

|   |   +--- forms.py

|   |   +--- urls.py

|   |   +--- __init__.py

|   |   +--- tests.py

|   |   +--- templates

|   |   |   +--- pizza_club_order

|   |   |   |   +--- intervenant.html

|   |   |   |   +--- inscription.html

|   |   |   |   +--- payement.html

|   |   |   |   +--- crediter.html

|   |   |   |   +--- accueil.html

|   |   |   |   +--- tresorerie.html

|   |   |   |   +--- login.html

|   |   |   |   +--- commander.html

|   |   |   |   +--- profil.html

|   |   |   +--- base.html

|   |   |   +--- .DS_Store

|   +--- manage.py

|   +--- db.sqlite3

|   +--- apache

|   +--- db.sql


Everything is here ! (It's quite a small project)
 

> • Do I get it right that your application is installed under /var/www 
> (which is generally a bad idea)?
>

You're right. I didn't know it was a bad idea, I followed the previous 
tutorial, which actually seems to be not so great.
 

> • Is pizzaclub/settings.py available if you stand in any of those 
> directories? (Ie. try cd ; ls pizzaclub/settings.py)
>
>
It's available, as we can see in my tree.
 

> Best,
> Gergely
>

Thanks,
Robin. 

-- 
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@google

Re: Django on CentOS

2015-11-09 Thread Robin Fourcade
Thanks for your answer James,
As this server is only the run this project, I can install another linux 
distribution.
I'm able to install theses :

*CentOS 6 minimal system (64 bits)*
Système de base openSUSE 13.1 (64 bits)
Système de base Debian 7 Wheezy (64 bits)
CentOS 6 avec Parallels Plesk Panel 12 (64 bits)
openSUSE 13.1 avec Parallels Plesk Panel 12 (64 bits)
Système de base ubuntu 14.04 (64 bits)

Do you think it's better to install one or another ?

Actually, I already tried on Debian 7 and I followed some tutorial but I 
wasn't able to run the server neither. So if you know a great tutorial 
which shows how to install&run a django project on one of theses 
distributions, it would be perfect! :)

Thanks again !

Robin.

-- 
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/cb18c238-d685-441d-842d-29f80b18b826%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Write django log to different.

2015-11-09 Thread tolerious feng
I want to write django log to different, especially I want to log daily log 
file, such as 2015-11-09-log.txt  2015-11-10-log.txt, this is my 
settings.py file:

TODAY_STRING = datetime.datetime.now().strftime("%F")
TODAY_LOG_DIR = os.path.dirname(__file__) + "/log/" + TODAY_STRING
# TODAY_LOG_DIR = "/log/" + TODAY_STRING
print "***"
print SITE_SRC_ROOT
print TODAY_LOG_DIR
print os.path.join(SITE_SRC_ROOT, TODAY_LOG_DIR, "todaytotal.log")
print os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, "todaytotal.log"),
if os.path.exists(TODAY_LOG_DIR):
pass
else:
os.mkdir(TODAY_LOG_DIR)

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(levelname)s: %(asctime)s %(module)s %(process)d 
%(thread)d %(message)s %(filename)s:%(funcName)s:%(lineno)d'
}
},
'handlers': {
'total': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'formatter': 'verbose',
'filename': os.path.join(SITE_SRC_ROOT, "log", "total.txt"),
},
'todaytotal': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'formatter': 'verbose',
'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
"todaytotal.txt"),
},
'dengbin': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'formatter': 'verbose',
'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
'dengbin.txt'),
},
'haiyang': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'formatter': 'verbose',
'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
'haiyang.txt'),
},
'meibo': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'formatter': 'verbose',
'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
"meibo.txt"),
},
'xiecheng': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'formatter': 'verbose',
'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
'xiecheng.txt'),
},
'tolerious': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'formatter': 'verbose',
'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
'tolerious.txt'),
}
},
'loggers': {
'xiecheng': {
'handlers': ['xiecheng', 'todaytotal', 'meibo', 'total'],
'propagate': False,
'level': 'DEBUG',
},
'dengbin': {
'handlers': ['dengbin', 'todaytotal', 'meibo', 'total'],
'propagate': False,
'level': 'DEBUG',
},
'haiyang': {
'handlers': ['haiyang', 'todaytotal', 'meibo', 'total'],
'propagate': False,
'level': 'DEBUG',
},
'tolerious': {
'handlers': ['tolerious', 'todaytotal', 'meibo', 'total'],
'propagate': False,
'level': 'DEBUG',
}
},
'root': {
'handlers': ['total'],
'level': 'DEBUG',
},
}


but this doesn't work, it only log 2015-11-09-log.txt, when today is 
2015-11-10, 2015-11-10-log.txt not generated.

-- 
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/0ca4d5be-88de-4e2e-afee-1c3b65bc3132%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Write django log to different.

2015-11-09 Thread Serdar Dalgic
Instead of solving this problem on django side, I'd recommend using a tool
such as logrotate for this problem
http://www.rackspace.com/knowledge_center/article/understanding-logrotate-utility


You can customise it to your needs, daily, weekly or per size basis.

One problem with solving it on django side would be, as the django settings
are loaded when you restart the server, and in production you may not want
to load the server every day, the TODAY_STRING would stay as the first day
the settings are loaded. So it's a better practice to solve the logging on
server side.

Best.

- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker
twitter:
https://twitter.com/serdaroncode
https://twitter.com/serdarintowild

On Mon, Nov 9, 2015 at 4:40 AM, tolerious feng 
wrote:

> I want to write django log to different, especially I want to log daily
> log file, such as 2015-11-09-log.txt  2015-11-10-log.txt, this is my
> settings.py file:
>
> TODAY_STRING = datetime.datetime.now().strftime("%F")
> TODAY_LOG_DIR = os.path.dirname(__file__) + "/log/" + TODAY_STRING
> # TODAY_LOG_DIR = "/log/" + TODAY_STRING
> print "***"
> print SITE_SRC_ROOT
> print TODAY_LOG_DIR
> print os.path.join(SITE_SRC_ROOT, TODAY_LOG_DIR, "todaytotal.log")
> print os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, "todaytotal.log"),
> if os.path.exists(TODAY_LOG_DIR):
> pass
> else:
> os.mkdir(TODAY_LOG_DIR)
>
> LOGGING = {
> 'version': 1,
> 'disable_existing_loggers': False,
> 'formatters': {
> 'verbose': {
> 'format': '%(levelname)s: %(asctime)s %(module)s %(process)d 
> %(thread)d %(message)s %(filename)s:%(funcName)s:%(lineno)d'
> }
> },
> 'handlers': {
> 'total': {
> 'level': 'DEBUG',
> 'class': 'logging.FileHandler',
> 'formatter': 'verbose',
> 'filename': os.path.join(SITE_SRC_ROOT, "log", "total.txt"),
> },
> 'todaytotal': {
> 'level': 'DEBUG',
> 'class': 'logging.FileHandler',
> 'formatter': 'verbose',
> 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
> "todaytotal.txt"),
> },
> 'dengbin': {
> 'level': 'DEBUG',
> 'class': 'logging.FileHandler',
> 'formatter': 'verbose',
> 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
> 'dengbin.txt'),
> },
> 'haiyang': {
> 'level': 'DEBUG',
> 'class': 'logging.FileHandler',
> 'formatter': 'verbose',
> 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
> 'haiyang.txt'),
> },
> 'meibo': {
> 'level': 'DEBUG',
> 'class': 'logging.FileHandler',
> 'formatter': 'verbose',
> 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
> "meibo.txt"),
> },
> 'xiecheng': {
> 'level': 'DEBUG',
> 'class': 'logging.FileHandler',
> 'formatter': 'verbose',
> 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
> 'xiecheng.txt'),
> },
> 'tolerious': {
> 'level': 'DEBUG',
> 'class': 'logging.FileHandler',
> 'formatter': 'verbose',
> 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 
> 'tolerious.txt'),
> }
> },
> 'loggers': {
> 'xiecheng': {
> 'handlers': ['xiecheng', 'todaytotal', 'meibo', 'total'],
> 'propagate': False,
> 'level': 'DEBUG',
> },
> 'dengbin': {
> 'handlers': ['dengbin', 'todaytotal', 'meibo', 'total'],
> 'propagate': False,
> 'level': 'DEBUG',
> },
> 'haiyang': {
> 'handlers': ['haiyang', 'todaytotal', 'meibo', 'total'],
> 'propagate': False,
> 'level': 'DEBUG',
> },
> 'tolerious': {
> 'handlers': ['tolerious', 'todaytotal', 'meibo', 'total'],
> 'propagate': False,
> 'level': 'DEBUG',
> }
> },
> 'root': {
> 'handlers': ['total'],
> 'level': 'DEBUG',
> },
> }
>
>
> but this doesn't work, it only log 2015-11-09-log.txt, when today is 
> 2015-11-10, 2015-11-10-log.txt not generated.
>
> --
> 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/0ca4d5be-88de-4e2e-afee-1c3b65bc3132%40googlegroups.com
> 

Re: finding information on modules, imports, etc.

2015-11-09 Thread Gary Roach
Actually, I think I have been looking in the wrong place for my 
information. What I assumed was Django functions are actually Python 
functions. Most if the information I need is found in the Python web 
sites. Obviously, I'm a bit of a Nub all around. AFLE (Another xxx 
learning experience.)


Thanks for your reply

Gary R.

On 11/08/2015 11:19 AM, Gergely Polonkai wrote:


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 

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.


--
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/5640B028.7080702%40verizon.net.
For more options, visit https://groups.google.com/d/optout.


Aw: Re: Django-Restframework adding and accessing a user to a model / adding an owner?

2015-11-09 Thread lnzy35en


Hi Xavier,

 

You are an angel! Thank you very much, the link to the API helped so much

 

Best Regards,

Mike


 

Gesendet: Sonntag, 08. November 2015 um 08:43 Uhr
Von: "Xavier Ordoquy" 
An: django-users@googlegroups.com
Betreff: Re: Django-Restframework adding and accessing a user to a model / adding an owner?



Hi
 



Le 7 nov. 2015 à 22:00, lnzy3...@gmx.de a écrit :
 





 










It runs into an error. To me it seems like I cannot combine two models. My goal is to access all the tasks attached to that user, or to add a task to the user accessing the API at the moment

So it would be very helpful, when someone could explains me the two issues:

1) How can I access the User information in a model? 





 

Depending on what you want to achieve, you can:

- use authentication, set the UserTask model to Task and override the view’s get_queryset to filter against the authenticated user (explained in the documentation at http://www.django-rest-framework.org/api-guide/filtering/#filtering-against-the-current-user)

- set the UserTask model to Task and filter the task list against a user (http://www.django-rest-framework.org/api-guide/filtering/#filtering-against-query-parameters)
 





2) How can I add data and attach that to a model.





 

You code snippet is correct except for the model attached to the view.


Regards,

Xavier,

Linovia.

 
--
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/6C0670E8-4F53-4A40-9020-66D7B291F1B1%40linovia.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/trinity-6e000e85-9c2c-481b-94bf-785d93a6dcd1-1447080651299%403capp-gmx-bs22.
For more options, visit https://groups.google.com/d/optout.


django oauth and andriod authentication

2015-11-09 Thread Shekar Tippur
Hello,

I am trying to get an android app authenticated via django oauth2.

I am using https://github.com/wuman/android-oauth-client for generating the 
request

Here is the generated uri

http://localhost:8000/o/token/?client_id=rXBixkjnYvZf78HUm8Jw17fR2awHgV5nqGHfTAaE&redirect_uri=http://localhost:8000/o/authorize&response_type=token

I seem to get java.io.IOException: User authorization failed 
(net::ERR_CONNECTION_REFUSED)

I can get authenticated via curl 

curl -X POST -d 
"grant_type=password&username=user1&password=user1&client_secret=${ClientSecret}&client_id=${ClientId}"
 
http://localhost:8000/o/token/


I have set authorization grant type as "resource owner password-based"


Really appreciate if someone could point me the right way.


- S

-- 
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/cfd4446d-c65d-4c01-969d-4b92b3f33d21%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How can I limit records based on user group in admin?

2015-11-09 Thread frocco
Hi,

I want to deploy an admin app that only allows records with company=A to 
users in group A
and allows records with company=B to users in group B

Is this possible?

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/be2ada7b-b3f9-4466-ada6-7575272c3790%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: duplicated queries

2015-11-09 Thread V1ce
That's works really thank you for your time, learned a very good thing 
today, 1 week im on this X) . Already look a little to Prefetch() function 
but haven't understand how to use it in my case^^

I have replaced my {% with currscat=categ.getscateg %} by {% with 
currscat=categ.souscategorie_set.all %} like in your example, that's work 
"_set.all" return me only "visible" child without more request but i don't 
understand how that's work, it is supposed to return me all objects, it 
don't include a filter, Prefetch() function do this?

Thanks for your additionnals advices i'll look at this.


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


Re: Write django log to different.

2015-11-09 Thread Stephen J. Butler
That's not going to work because all of this stuff...

On Sun, Nov 8, 2015 at 9:40 PM, tolerious feng 
wrote:

> TODAY_STRING = datetime.datetime.now().strftime("%F")
> TODAY_LOG_DIR = os.path.dirname(__file__) + "/log/" + TODAY_STRING
> # TODAY_LOG_DIR = "/log/" + TODAY_STRING
> print "***"
> print SITE_SRC_ROOT
> print TODAY_LOG_DIR
> print os.path.join(SITE_SRC_ROOT, TODAY_LOG_DIR, "todaytotal.log")
> print os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, "todaytotal.log"),
> if os.path.exists(TODAY_LOG_DIR):
> pass
> else:
> os.mkdir(TODAY_LOG_DIR)
>
>
> ... is only run once, when you startup the app. TODAY_STRING won't change
until the next time you restart Django.

Instead look logging.TimedRotatingFileHandler.

at
https://docs.python.org/2/library/logging.handlers.html#timedrotatingfilehandler

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


Re: Search capability on Django 3.1.3 (Haystack)

2015-11-09 Thread Aaron C. de Bruyn
Without any specific information on the problems you are having, here
is a link to the Haystack search tool:
http://haystacksearch.org/

If you can provide us with more detail, we would be happy to help.

-A

On Sun, Nov 8, 2015 at 11:06 PM, nAncy sharma  wrote:
> 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.

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


Ayuda con filtro

2015-11-09 Thread miguel angel lopez mendo

def clientes(request):
clientes = Clientes.objects.order_by('Nombre')
clientes2 = Clientes.objects.order_by('Nombre').filter(medio='1')
clientes3 = Clientes.objects.order_by('Nombre').filter(medio='2')
clientes4 = Clientes.objects.order_by('Nombre').filter(medio='3')
c = Clientes.objects.filter( Nombre__startswith='a').order_by('Nombre')
template = 'products/Clientes.html'
return render(request, template, locals())

tengo el siguiente problema quiero filtrar por la letra del abecedario y lo 
realizo con 

  c = Clientes.objects.filter( Nombre__startswith='a').order_by('Nombre')

pero tengo uno para cada letra nose si me puedan ayudar con alguna funcion 
que me facilite obtener esto

-- 
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/d29776bb-a965-4a89-a2af-00e539d03bea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Ayuda con filtro

2015-11-09 Thread Gustavo Andrés Angulo
Hola, puedes utilizar un for y guardar la salida en un query aunque por 
optimización los queries de django solo se ejecutan en el momento de usarlos 
entonces podrias crear un templetag para esto.


def cliente(request):
...
...
clientes = Clientes.objects.order_by('Nombre')
queries = {}
for a in range(97, 123):
queries[a] = clientes.filter(Nombre__starswith=a)
...
...
print queries['f']
print queries['z']


> 
> def clientes(request):
> clientes = Clientes.objects.order_by('Nombre')
> clientes2 = Clientes.objects.order_by('Nombre').filter(medio='1')
> clientes3 = Clientes.objects.order_by('Nombre').filter(medio='2')
> clientes4 = Clientes.objects.order_by('Nombre').filter(medio='3')
> c = Clientes.objects.filter( Nombre__startswith='a').order_by('Nombre')
> template = 'products/Clientes.html'
> return render(request, template, locals())
> 
> tengo el siguiente problema quiero filtrar por la letra del abecedario y lo 
> realizo con 
> 
>   c = Clientes.objects.filter( Nombre__startswith='a').order_by('Nombre')
> 
> pero tengo uno para cada letra nose si me puedan ayudar con alguna funcion 
> que me facilite obtener esto
> 
> -- 
> 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/d29776bb-a965-4a89-a2af-00e539d03bea%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/20151109174657.GA24937%40pehik.co.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: PGP signature


Re: Ayuda con filtro

2015-11-09 Thread miguel angel lopez mendo
Soy nuevo en este tema y no me queda lo deje como lo subiste

El lunes, 9 de noviembre de 2015, 11:36:29 (UTC-6), miguel angel lopez 
mendo escribió:
>
>
> def clientes(request):
> clientes = Clientes.objects.order_by('Nombre')
> clientes2 = Clientes.objects.order_by('Nombre').filter(medio='1')
> clientes3 = Clientes.objects.order_by('Nombre').filter(medio='2')
> clientes4 = Clientes.objects.order_by('Nombre').filter(medio='3')
> c = Clientes.objects.filter( Nombre__startswith='a').order_by('Nombre')
> template = 'products/Clientes.html'
> return render(request, template, locals())
>
> tengo el siguiente problema quiero filtrar por la letra del abecedario y 
> lo realizo con 
>
>   c = Clientes.objects.filter( Nombre__startswith='a').order_by('Nombre')
>
> pero tengo uno para cada letra nose si me puedan ayudar con alguna funcion 
> que me facilite obtener esto
>

-- 
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/97f689d9-d2a0-4c7b-884e-3ddc3742d90b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Ayuda con filtro

2015-11-09 Thread miguel angel lopez mendo



{% for cliente in queries %}


Nombre del Cliente: {{ 
cliente.Nombre}}
Medio por el cual llego: {{ 
cliente.get_medio_display}} 

{% endfor %}



En el template que modificaria ?
El lunes, 9 de noviembre de 2015, 11:36:29 (UTC-6), miguel angel lopez 
mendo escribió:
>
>
> def clientes(request):
> clientes = Clientes.objects.order_by('Nombre')
> clientes2 = Clientes.objects.order_by('Nombre').filter(medio='1')
> clientes3 = Clientes.objects.order_by('Nombre').filter(medio='2')
> clientes4 = Clientes.objects.order_by('Nombre').filter(medio='3')
> c = Clientes.objects.filter( Nombre__startswith='a').order_by('Nombre')
> template = 'products/Clientes.html'
> return render(request, template, locals())
>
> tengo el siguiente problema quiero filtrar por la letra del abecedario y 
> lo realizo con 
>
>   c = Clientes.objects.filter( Nombre__startswith='a').order_by('Nombre')
>
> pero tengo uno para cada letra nose si me puedan ayudar con alguna funcion 
> que me facilite obtener esto
>

-- 
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/bebf8d03-7594-4dc0-8687-24ebcd768473%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: coding in template

2015-11-09 Thread Dariusz Mysior
Thank's i set it in PyCharm on encoding utf-8 like You said and it's work!

W dniu sobota, 7 listopada 2015 21:44:25 UTC+1 użytkownik Dariusz Mysior 
napisał:
>
> I try use polish letters in my template index.html but I had an error
>
>
> utf-8' codec can't decode byte 0xb3 in position 149: invalid start byte
>>
>>
> How can I fix it? 
>
>

-- 
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/610cf50e-be60-4b9c-9313-3c5b568b8366%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


how to filter request.user.groups.all()

2015-11-09 Thread frocco
Hello,

request.user.groups.all() returns:

[, ]


z = request.user.groups.all()

I am trying to limit records based on:

mytable.filter(company__in=z)


What am I doing wrong?



-- 
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/d0ea2805-fab2-4274-a974-df04208d85d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django on CentOS

2015-11-09 Thread James Schneider
On Mon, Nov 9, 2015 at 2:29 AM, Robin Fourcade 
wrote:

> Thanks for your answer James,
> As this server is only the run this project, I can install another linux
> distribution.
> I'm able to install theses :
>
> *CentOS 6 minimal system (64 bits)*
> Système de base openSUSE 13.1 (64 bits)
> Système de base Debian 7 Wheezy (64 bits)
> CentOS 6 avec Parallels Plesk Panel 12 (64 bits)
> openSUSE 13.1 avec Parallels Plesk Panel 12 (64 bits)
> Système de base ubuntu 14.04 (64 bits)
>
> Do you think it's better to install one or another ?
>
> Actually, I already tried on Debian 7 and I followed some tutorial but I
> wasn't able to run the server neither. So if you know a great tutorial
> which shows how to install&run a django project on one of theses
> distributions, it would be perfect! :)
>
>

Debian 7 should work fine and would be my personal preference (all of the
Linux servers that I manager are Debian), as it includes Python 2.7.3 as
the default Python version. Ubuntu would be my second choice. I can
personally confirm that I've had Django working under Apache/WSGI on a
Debian 7 machine at some point.

The ultimate choice, though, is up to you, and how familiar you are with
the particular flavor of Linux you choose. You'll be in charge of
maintaining the system, so it should be something you are comfortable with.

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


Re: how to filter request.user.groups.all()

2015-11-09 Thread James Schneider
On Mon, Nov 9, 2015 at 10:46 AM, frocco  wrote:

> Hello,
>
> request.user.groups.all() returns:
>
> [, ]
>
>
> z = request.user.groups.all()
>
> I am trying to limit records based on:
>
> mytable.filter(company__in=z)
>
>
> What am I doing wrong?
>
>
>From the look of it, nothing. What happens when you do that? We'll need
error tracebacks or an explanation of symptoms to diagnose further.

Is mytable.company a foreign key to django.contrib.auth.models.Group? If
not, I can see why such a filter wouldn't work (or worse, would give
inaccurate results).

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


Re: duplicated queries

2015-11-09 Thread James Schneider
> That's works really thank you for your time, learned a very good thing
> today, 1 week im on this X) . Already look a little to Prefetch() function
> but haven't understand how to use it in my case^^
>

Don't feel that bad. Prefetch() stumped me for a long time until I saw a
post about it on this list a year or so back, and the Django dev team added
examples to the documentation which clarified even more.


>
> I have replaced my {% with currscat=categ.getscateg %} by {% with
> currscat=categ.souscategorie_set.all %} like in your example, that's work
> "_set.all" return me only "visible" child without more request but i don't
> understand how that's work, it is supposed to return me all objects, it
> don't include a filter, Prefetch() function do this?
>

The filter to only retrieve the 'visible' related objects is built into the
Prefetch() objects as part of the queryset:

pf_souscategorie = Prefetch('souscategorie_set',
SousCategorie.objects.filter(visible=True)) # prefetch only visible
SousCategorie's

Here, the PF object is configured to use the query
SousCategorie.objects.filter(visible=True) when it pre-fetches all of the
related SousCategorie objects.

When you access the set that was pre-fetched (using the PF object), the
.all() will only gather the rows that were pre-fetched and cached in the
queryset, and not execute a typical .all() query against the DB (which is
the point of pre-fetching, not to run queries later). Since we limited the
original query with a PF object, any subsequent
categ.souscategorie_set.all() calls use the pre-fetched rows, and hence are
filtered.

If you wanted to see all of the objects and have the
souscategorie_set.all() work as it does typically (fetching all of the
related rows instead of just the visible ones), you can do this instead:

# Note that we do not need the pf_* objects that were created before.
categs =
Categorie.objects.filter(visible=True).prefetch_related('souscategorie_set__theme_set__soustheme_set')

That should keep the number of queries the same, but return all of the
*_set objects, not just the visible ones (although it will still filter out
only the visible Categorie objects, remove the visible=True if you want
everything).

-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 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%2BciXvfMOH2ZaMocsTZ9v1U4wScNwQ3SBQNQDXzgEFye%2BzXA%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-09 Thread Tim Chase
On 2015-11-06 01:09, Carl Meyer wrote:
> [1] https://pypi.python.org/pypi/WebTest
> [2] https://pypi.python.org/pypi/django-webtest

Just to follow up, django-webtest has been pretty much exactly what I
was looking for.  Thanks!

-Tim



-- 
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/20151109124112.689e53f4%40bigbox.christie.dr.
For more options, visit https://groups.google.com/d/optout.


Re: how to filter request.user.groups.all()

2015-11-09 Thread frocco
I was stuck on the syntax.

This seems to be working.

return qs.filter(company__in=list(request.user.groups.all()))


On Monday, November 9, 2015 at 1:46:19 PM UTC-5, frocco wrote:
>
> Hello,
>
> request.user.groups.all() returns:
>
> [, ]
>
>
> z = request.user.groups.all()
>
> I am trying to limit records based on:
>
> mytable.filter(company__in=z)
>
>
> What am I doing wrong?
>
>
>
>

-- 
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/d137be69-56b9-424d-9e1d-08099a6638d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I limit records based on user group in admin?

2015-11-09 Thread frocco
I solved this using

def get_queryset(self, request):
qs = super(TrackingAdmin, self).get_queryset(request)
return qs.filter(company__in=list(request.user.groups.all()))


*Sorry for the duplicate post*



On Monday, November 9, 2015 at 11:28:50 AM UTC-5, frocco wrote:
>
> Hi,
>
> I want to deploy an admin app that only allows records with company=A to 
> users in group A
> and allows records with company=B to users in group B
>
> Is this possible?
>
> 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/46d32f00-e325-41bb-9af4-0147b17c25c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Setting up PortgreSQL with Djano 1.8

2015-11-09 Thread Ele. O.
Hello Everyone, 
I tried to insall PostgreSQL with Djngo 1.8 and when running "migrate" to 
ensure the database is connected and created successfully, i faced a an 
error regarding the settings and couldn't go further . Below you can fine 
the steps that was taken at the time of setting up the database , if you 
can point me in where was the missing step or if there's a different way 
that this can be done... 

OS: Arch Linux

*First Step: *


$sudo pacman -S posgresql
$sudo -i -u postgres
[postgres@dworld~]$ initdb --locale en_US.UTF-8 -E UTF8 -D 
'/var/lib/postgres/data'
[postgres@dworld~]$ postgres -D /var/lib/postgres/data

*# then in another terminal while the above terminal live:*

$ sudo -i -u posgres
[postgres@dworld ~]$ psql

postgres=# CREATE DATABASE fdatabase
postgres=# CREATE USER dan WITH PASSWORD 'password'
postgres-# ALTER ROLE dan SET client_encoding TO 'utf8'
postgres-# ALTER ROLE dan SET default_transaction_isolation To 'read 
committed'
postgres-# ALTER ROLE dan SET timezone TO 'UTC+03:00'
postgres-# GRANT ALL PRIVILEGES ON DATABASE fdatabase TO dan
postgres-# \q

[postgres@dworld ~]$ exit



*Second Step:*
$ django-admin startproject mysite

$ pip install psycopg2
$ vim settings.py

*# then did the following changes to Settings.py :*



DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'fdatabase',
'USER': 'dan',
'PASSWORD': 'password',
'HOST': '',
'PORT': '',
}
}

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC+03:00'





*Third Step:*
(my_site)[dan@dworld my_site]$ python2 manage.py migrate
Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/home/dan/.virtualenvs/my_site/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 354, in execute_from_command_line
utility.execute()
  File 
"/home/dan/.virtualenvs/my_site/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 303, in execute
settings.INSTALLED_APPS
  File 
"/home/dan/.virtualenvs/my_site/lib/python2.7/site-packages/django/conf/__init__.py",
 
line 48, in __getattr__
self._setup(name)
  File 
"/home/dan/.virtualenvs/my_site/lib/python2.7/site-packages/django/conf/__init__.py",
 
line 44, in _setup
self._wrapped = Settings(settings_module)
  File 
"/home/dan/.virtualenvs/my_site/lib/python2.7/site-packages/django/conf/__init__.py",
 
line 131, in __init__
raise ValueError("Incorrect timezone setting: %s" % self.TIME_ZONE)
ValueError: Incorrect timezone setting: UTC+03:00


Thanks all 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/dd96cf9c-18e1-4139-8fe1-48fbe6aa9036%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting up PortgreSQL with Djano 1.8

2015-11-09 Thread James Schneider
>
>
> TIME_ZONE = 'UTC+03:00'
>
> 
>
>
>
> *Third Step:*
> (my_site)[dan@dworld my_site]$ python2 manage.py migrate
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File
> "/home/dan/.virtualenvs/my_site/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 354, in execute_from_command_line
> utility.execute()
>   File
> "/home/dan/.virtualenvs/my_site/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 303, in execute
> settings.INSTALLED_APPS
>   File
> "/home/dan/.virtualenvs/my_site/lib/python2.7/site-packages/django/conf/__init__.py",
> line 48, in __getattr__
> self._setup(name)
>   File
> "/home/dan/.virtualenvs/my_site/lib/python2.7/site-packages/django/conf/__init__.py",
> line 44, in _setup
> self._wrapped = Settings(settings_module)
>   File
> "/home/dan/.virtualenvs/my_site/lib/python2.7/site-packages/django/conf/__init__.py",
> line 131, in __init__
> raise ValueError("Incorrect timezone setting: %s" % self.TIME_ZONE)
> ValueError: Incorrect timezone setting: UTC+03:00
>
>
> Thanks all in advance ..
>

Seems like an issue with setting TIME_ZONE in settings.py:

https://docs.djangoproject.com/en/1.8/ref/settings/#time-zone and from
there: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones (You'll
want to use a value out of the 3rd column)

ie TIME_ZONE = 'America/Los_Angeles'

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


How do I add permissions in admin for proxy model?

2015-11-09 Thread frocco
I have 

class qry485Missing(Tracking):
class Meta:
proxy = True
permissions = (
("qry485Missing_display", "May display information"),
("qry485Missing_edit", "May edit information"),
)
verbose_name = "485 Missing"
verbose_name_plural = "485 Missing"


This does not show up in admin to allow users access.

I have to grant superuser status to see it.


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/2fdf73eb-e1ce-49c4-8d57-2d9dcaaf3281%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Team project via Git repo

2015-11-09 Thread Ralph Castain
My apologies for the long, long delay in finally responding. Your advice worked 
like a charm!!

Thanks a lot to all who responded.
Ralph


> On Oct 13, 2015, at 7:00 PM, Aaron C. de Bruyn  wrote:
> 
> Without knowing too much about your environment, I figured I'd tell
> you how I do it on my Debian-derivative systems.
> 
> * Install python-virtualenv and virtualenvwrapper - These tools help
> you create isolated python environments under your home folder under
> '.virtualenv'.
> * Create a virtualenv for the project.  If my project name is CarSite
> I run 'mkvirtualenv carsite'.  (After the virtualenv is created it
> should leave you *inside* the virtual environment)
> * Install the latest version of Django into your virtual env by
> running 'pip install django'
> * Create your project by going in to your code folder (this is
> different than your virtualenv) "cd ~/code" and then creating the
> project "django-admin startproject carsite"
> * Go in to the carsite directory "cd ~/code/carsite"
> * Create a requirements.txt file for other developers ('pip freeze >
> requirements.txt')
> * Turn it into a git repo "git init ."
> * Commit your new project (or make changes, then commit) "git commit
> -m 'My first commit'"
> * Connect it to github by following their directions (something like
> 'git remote add origin g...@github.com:username/carsite.git' and then
> 'git push -u origin master')
> 
> Now other developers should be able to start working on the project by
> doing the following:
> * cd ~/code
> * git clone g...@github.com:username/carsite.git carsite
> * cd ~/code/carsite
> * mkvirtualenv -r requirements.txt
> 
> -A
> 
> 
> 
> On Tue, Oct 13, 2015 at 5:38 PM,   wrote:
>> Just to update: we also tried simply copying the entire virtual environment
>> across, correcting for any differences in path. Still go the same behavior.
>> 
>> We'd really welcome some advice on this one as otherwise we won't be able to
>> use Django - we need a way to collaborate on implementation.
>> 
>> Thanks
>> Ralph
>> 
>> 
>> On Tuesday, October 13, 2015 at 2:57:50 PM UTC-7, rhc.o...@gmail.com wrote:
>>> 
>>> Hi folks
>>> 
>>> I'm a Django newbie (have found it very helpful!), so please excuse the
>>> naivete. I have a question regarding team work on a Django project via
>>> GitHub.
>>> 
>>> I followed your excellent tutorial and have a virtual Python v2.7
>>> environment with Django 1.8.5 installed in it (FWIW: I thought I installed
>>> Django 1.11, but django-admin --version shows 1.8.5). I then created my app
>>> using "django-admin startproject foo" and got the project subdirectory as
>>> expected. A quick check of the server showed the "Welcome to Django" page.
>>> 
>>> I then added a bunch of model definitions and customized the admin page. I
>>> verified that everything was okay by looking at the admin web page on my
>>> localhost - the customized page is there, and I was able to add some test
>>> data for one of the models. At this point, others want to pitch in to help,
>>> and so I bundled everything in my project subdirectory (including manage.py
>>> and the initial sqlite3 db) into a git repo and pushed it up to GitHub.
>>> 
>>> The other team members also setup a virtual environment with Django, using
>>> the same versions, and activated it. They then cloned the GitHub repo and
>>> got all the project files as expected, and the directory structure looks
>>> exactly the same.
>>> 
>>> However, when they runserver in the project, they only get the "Welcome to
>>> Django" page. The project admin and login page doesn't show up. I've
>>> verified that all the model and settings info is correct, but we haven't
>>> been able to get the info to show on the web page.
>>> 
>>> Any suggestions on what we are doing wrong? I'm assuming a team can share
>>> a Django project, but suspect we aren't collecting all the relevant files or
>>> not getting the other team's environment set correctly.
>>> 
>>> Thanks
>>> Ralph
>>> 
>> --
>> 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/b13c6d50-2a22-40bf-a78d-752a7305914a%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> 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/MlbkfJcJo08/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 t

Re: Team project via Git repo

2015-11-09 Thread m1chael
What ended up solving your issue, Ralph? ~Mike

On Mon, Nov 9, 2015 at 4:34 PM, Ralph Castain  wrote:
> My apologies for the long, long delay in finally responding. Your advice 
> worked like a charm!!
>
> Thanks a lot to all who responded.
> Ralph
>
>
>> On Oct 13, 2015, at 7:00 PM, Aaron C. de Bruyn  wrote:
>>
>> Without knowing too much about your environment, I figured I'd tell
>> you how I do it on my Debian-derivative systems.
>>
>> * Install python-virtualenv and virtualenvwrapper - These tools help
>> you create isolated python environments under your home folder under
>> '.virtualenv'.
>> * Create a virtualenv for the project.  If my project name is CarSite
>> I run 'mkvirtualenv carsite'.  (After the virtualenv is created it
>> should leave you *inside* the virtual environment)
>> * Install the latest version of Django into your virtual env by
>> running 'pip install django'
>> * Create your project by going in to your code folder (this is
>> different than your virtualenv) "cd ~/code" and then creating the
>> project "django-admin startproject carsite"
>> * Go in to the carsite directory "cd ~/code/carsite"
>> * Create a requirements.txt file for other developers ('pip freeze >
>> requirements.txt')
>> * Turn it into a git repo "git init ."
>> * Commit your new project (or make changes, then commit) "git commit
>> -m 'My first commit'"
>> * Connect it to github by following their directions (something like
>> 'git remote add origin g...@github.com:username/carsite.git' and then
>> 'git push -u origin master')
>>
>> Now other developers should be able to start working on the project by
>> doing the following:
>> * cd ~/code
>> * git clone g...@github.com:username/carsite.git carsite
>> * cd ~/code/carsite
>> * mkvirtualenv -r requirements.txt
>>
>> -A
>>
>>
>>
>> On Tue, Oct 13, 2015 at 5:38 PM,   wrote:
>>> Just to update: we also tried simply copying the entire virtual environment
>>> across, correcting for any differences in path. Still go the same behavior.
>>>
>>> We'd really welcome some advice on this one as otherwise we won't be able to
>>> use Django - we need a way to collaborate on implementation.
>>>
>>> Thanks
>>> Ralph
>>>
>>>
>>> On Tuesday, October 13, 2015 at 2:57:50 PM UTC-7, rhc.o...@gmail.com wrote:

 Hi folks

 I'm a Django newbie (have found it very helpful!), so please excuse the
 naivete. I have a question regarding team work on a Django project via
 GitHub.

 I followed your excellent tutorial and have a virtual Python v2.7
 environment with Django 1.8.5 installed in it (FWIW: I thought I installed
 Django 1.11, but django-admin --version shows 1.8.5). I then created my app
 using "django-admin startproject foo" and got the project subdirectory as
 expected. A quick check of the server showed the "Welcome to Django" page.

 I then added a bunch of model definitions and customized the admin page. I
 verified that everything was okay by looking at the admin web page on my
 localhost - the customized page is there, and I was able to add some test
 data for one of the models. At this point, others want to pitch in to help,
 and so I bundled everything in my project subdirectory (including manage.py
 and the initial sqlite3 db) into a git repo and pushed it up to GitHub.

 The other team members also setup a virtual environment with Django, using
 the same versions, and activated it. They then cloned the GitHub repo and
 got all the project files as expected, and the directory structure looks
 exactly the same.

 However, when they runserver in the project, they only get the "Welcome to
 Django" page. The project admin and login page doesn't show up. I've
 verified that all the model and settings info is correct, but we haven't
 been able to get the info to show on the web page.

 Any suggestions on what we are doing wrong? I'm assuming a team can share
 a Django project, but suspect we aren't collecting all the relevant files 
 or
 not getting the other team's environment set correctly.

 Thanks
 Ralph

>>> --
>>> 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/b13c6d50-2a22-40bf-a78d-752a7305914a%40googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> 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/MlbkfJcJo08/unsubscri

Re: Team project via Git repo

2015-11-09 Thread Ralph Castain
The primary issue was that I naively placed all the code in the same location 
as the virtual environment. I subsequently wound up slurping the environment 
code into the repo, which broke as soon as it was transitioned to a new 
location.

The “secret” was to put the code in a separate location from the virtual 
environment, and use the mkvirtualenv -r requirements.txt trick Aaron 
mentioned. As soon as I did that, I was able to migrate pretty simply.

So it had nothing to do with Django itself - just had to cleanly separate the 
environment from the code.


> On Nov 9, 2015, at 2:12 PM, m1chael  wrote:
> 
> What ended up solving your issue, Ralph? ~Mike
> 
> On Mon, Nov 9, 2015 at 4:34 PM, Ralph Castain  wrote:
>> My apologies for the long, long delay in finally responding. Your advice 
>> worked like a charm!!
>> 
>> Thanks a lot to all who responded.
>> Ralph
>> 
>> 
>>> On Oct 13, 2015, at 7:00 PM, Aaron C. de Bruyn  wrote:
>>> 
>>> Without knowing too much about your environment, I figured I'd tell
>>> you how I do it on my Debian-derivative systems.
>>> 
>>> * Install python-virtualenv and virtualenvwrapper - These tools help
>>> you create isolated python environments under your home folder under
>>> '.virtualenv'.
>>> * Create a virtualenv for the project.  If my project name is CarSite
>>> I run 'mkvirtualenv carsite'.  (After the virtualenv is created it
>>> should leave you *inside* the virtual environment)
>>> * Install the latest version of Django into your virtual env by
>>> running 'pip install django'
>>> * Create your project by going in to your code folder (this is
>>> different than your virtualenv) "cd ~/code" and then creating the
>>> project "django-admin startproject carsite"
>>> * Go in to the carsite directory "cd ~/code/carsite"
>>> * Create a requirements.txt file for other developers ('pip freeze >
>>> requirements.txt')
>>> * Turn it into a git repo "git init ."
>>> * Commit your new project (or make changes, then commit) "git commit
>>> -m 'My first commit'"
>>> * Connect it to github by following their directions (something like
>>> 'git remote add origin g...@github.com:username/carsite.git' and then
>>> 'git push -u origin master')
>>> 
>>> Now other developers should be able to start working on the project by
>>> doing the following:
>>> * cd ~/code
>>> * git clone g...@github.com:username/carsite.git carsite
>>> * cd ~/code/carsite
>>> * mkvirtualenv -r requirements.txt
>>> 
>>> -A
>>> 
>>> 
>>> 
>>> On Tue, Oct 13, 2015 at 5:38 PM,   wrote:
 Just to update: we also tried simply copying the entire virtual environment
 across, correcting for any differences in path. Still go the same behavior.
 
 We'd really welcome some advice on this one as otherwise we won't be able 
 to
 use Django - we need a way to collaborate on implementation.
 
 Thanks
 Ralph
 
 
 On Tuesday, October 13, 2015 at 2:57:50 PM UTC-7, rhc.o...@gmail.com wrote:
> 
> Hi folks
> 
> I'm a Django newbie (have found it very helpful!), so please excuse the
> naivete. I have a question regarding team work on a Django project via
> GitHub.
> 
> I followed your excellent tutorial and have a virtual Python v2.7
> environment with Django 1.8.5 installed in it (FWIW: I thought I installed
> Django 1.11, but django-admin --version shows 1.8.5). I then created my 
> app
> using "django-admin startproject foo" and got the project subdirectory as
> expected. A quick check of the server showed the "Welcome to Django" page.
> 
> I then added a bunch of model definitions and customized the admin page. I
> verified that everything was okay by looking at the admin web page on my
> localhost - the customized page is there, and I was able to add some test
> data for one of the models. At this point, others want to pitch in to 
> help,
> and so I bundled everything in my project subdirectory (including 
> manage.py
> and the initial sqlite3 db) into a git repo and pushed it up to GitHub.
> 
> The other team members also setup a virtual environment with Django, using
> the same versions, and activated it. They then cloned the GitHub repo and
> got all the project files as expected, and the directory structure looks
> exactly the same.
> 
> However, when they runserver in the project, they only get the "Welcome to
> Django" page. The project admin and login page doesn't show up. I've
> verified that all the model and settings info is correct, but we haven't
> been able to get the info to show on the web page.
> 
> Any suggestions on what we are doing wrong? I'm assuming a team can share
> a Django project, but suspect we aren't collecting all the relevant files 
> or
> not getting the other team's environment set correctly.
> 
> Thanks
> Ralph
> 
 --
 You received this message because you are subscribed to the G

Re: Django on CentOS

2015-11-09 Thread Matthias Runge
On 09/11/15 11:29, Robin Fourcade wrote:
> Thanks for your answer James,
> As this server is only the run this project, I can install another linux
> distribution.
> I'm able to install theses :
> 
> *CentOS 6 minimal system (64 bits)*
> Système de base openSUSE 13.1 (64 bits)
> Système de base Debian 7 Wheezy (64 bits)
> CentOS 6 avec Parallels Plesk Panel 12 (64 bits)
> openSUSE 13.1 avec Parallels Plesk Panel 12 (64 bits)
> Système de base ubuntu 14.04 (64 bits)
> 
> Do you think it's better to install one or another ?
> 
> Actually, I already tried on Debian 7 and I followed some tutorial but I
> wasn't able to run the server neither. So if you know a great tutorial
> which shows how to install&run a django project on one of theses
> distributions, it would be perfect! :)
> 
> Thanks again !
> 
> Robin.

CentOS 6 is fine, as you saw your developer server already worked.

Looking at your project, I can not find a file
pizzaclub.settings,
but pizza_club.settings

(see the '_' ?)

Matthias

-- 
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/5641A340.5080701%40matthias-runge.de.
For more options, visit https://groups.google.com/d/optout.