Re: authenticate a user without databse

2016-06-06 Thread prabhat jha
hey bro thanx,but i am not using django authentication pattern.
so @login required will not work in my condition.

>
>

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


Re: Passing hidden foreign key to form as initial value

2016-06-06 Thread Peter of the Norse
Because CharField is designed for text data.  So the form field turns the 
course into a string and tries to save a string to the model.  That doesn’t 
work.

The only built-in field designed to work with foreign keys is ModelChoiceField. 
 You could update it so that it doesn’t run a queryset and uses HiddenInput.

The other option is to remove course from the ModelForm and instead use 
course_id with IntergerField.  This would be the fastest and not hit the 
database as often.  I recommend doing this.  Or, if this uses an existing 
object, not have anything there.  Things left out of the ModelForm don’t get 
updated when you save the form. 

> On May 6, 2016, at 9:22 AM, Michel Z. Santello  wrote:
> 
> Can somebody explain why did occurs with widget=forms.HiddenInput ?
> 
> Thank's.
> 
> 
> 
> 
> Em quarta-feira, 31 de março de 2010 10:20:48 UTC-3, Phoebe Bright escreveu:
> Displayed fields resolve as expected, hidden fields cause errors.
> This works:
> 
> in the model
> CourseBook has a foreign key to Course
> 
> In the view:
> 
> course = Course.objects.get(pk=whatever)
> form = CouseBook(initial = {'course': course})
> 
> 
> in the Form:
> 
> class CourseBook(ModelForm):
> class Meta:
> model = CourseBooking
> 
> 
> The web page now displays a picklist of courses with the initial value
> highlighted.  I can now do a form.save() no problem.
> 
> However, if I make the course a hidden field, which is what I want.
> 
> class CourseBook(ModelForm):
> course = forms.CharField(widget=forms.HiddenInput())
> 
> class Meta:
> model = CourseBooking
> 
> then when I come to save() I get a ValueError, unable to assign "My
> course"  etc. as it tries to put the name of the course into the
> foreign key instead of a course instance.
> 
> I can work around this putting a save method on the form, but it seems
> to me django should resolve this for me
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/3628bd01-59b2-4291-94f5-072d6de9f7c7%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Peter of the Norse
rahmc...@radio1190.org



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


Re: How to set default ordering to Lower case?

2016-06-06 Thread Simon Charette
Hi Neto,

Ordering by expression (order_by(Lower('name')) is not supported yet but 
it's
tracked as a feature request[1].

If we manage to allow transforms in `order_by()`[2] in the future you 
should be
able to define a ['name__lower'] ordering in the future but until then you
have to use a combination of `annotate()` and `order_by()` on a custom 
manager:

class PersonManager(models.Manager):
def get_queryset(self, *args, **kwargs):
queryset = super(PersonManager, self).get_queryset(*args, **kwargs)
return queryset.annotate(
name_lower=Lower('name'),
).order_by('name_lower')

class Person(models.Model):
name = models.CharField(_('name'), max_length=100)

objects = PersonManager()

Cheers,
Simon

[1] https://code.djangoproject.com/ticket/26257
[2] https://code.djangoproject.com/ticket/24747 

Le lundi 6 juin 2016 19:21:32 UTC-4, Neto a écrit :
>
> It does not works:
>
> from django.db.models.functions import Lower
>
>
> class Person(models.Model):
> 
> name = models.CharField(_('name'), max_length=100)
>
> class Meta:
> ordering = [Lower('name')]
>
>

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


Re: How to set default ordering to Lower case?

2016-06-06 Thread Ezequiel Bertti
You can create a migration file and create index by sql.

https://docs.djangoproject.com/ja/1.9/ref/migration-operations/#django.db.migrations.operations.RunSQL

On Mon, Jun 6, 2016 at 8:21 PM, Neto  wrote:

> It does not works:
>
> from django.db.models.functions import Lower
>
>
> class Person(models.Model):
>
> name = models.CharField(_('name'), max_length=100)
>
> class Meta:
> ordering = [Lower('name')]
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/07398d69-2af5-4dad-9bf9-0eb32248e65f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Ezequiel Bertti

https://telegram.me/ebertti
https://twitter.com/ebertti
https://github.com/ebertti

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


How to set default ordering to Lower case?

2016-06-06 Thread Neto
It does not works:

from django.db.models.functions import Lower


class Person(models.Model):

name = models.CharField(_('name'), max_length=100)

class Meta:
ordering = [Lower('name')]

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


Re: django1.6 with uwsgi and nginx on RHEL 7

2016-06-06 Thread Larry Martell
In general, yes, I agree. But in this cast the machine is dedicated to
just running that one app.

On Mon, Jun 6, 2016 at 4:54 PM, Avraham Serour  wrote:
> you should use isolated virtual environments for each python project, don't
> install packages on the system wide python, see
> https://virtualenv.pypa.io/en/stable/
>
>
> On Mon, Jun 6, 2016 at 11:45 PM, Larry Martell 
> wrote:
>>
>> I figured this out - the problem turned out to be that the RHEL 7
>> machine had django 1.6.0 whereas the RHEL 6 machine had 1.6.10. Once I
>> installed 1.6.10 on the 7 machine all was well.
>>
>> On Mon, Jun 6, 2016 at 12:50 PM, Larry Martell 
>> wrote:
>> > I have successfully deployed django1.6 with uwsgi and nginx on RHEL6
>> > but I cannot seem to get it working on RHEL7.
>> >
>> > I get Internal Server Error in the browser, and this in the uwsgi log:
>> >
>> > --- no python application found, check your startup logs for errors ---
>> > [pid: 10582|app: -1|req: -1/2] xx.xx.xx.xx () {46 vars in 803 bytes}
>> > [Mon Jun  6 11:58:50 2016] GET /favicon.ico => generated 21 bytes in 0
>> > msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
>> >
>> > I have tried everything I can think of. Where am I going wrong here?
>> >
>> > Here are my files:
>> >
>> > nginx config:
>> >
>> > upstream django {
>> > server unix:///projects/elucid/elucid.sock; # for a file socket
>> > }
>> >
>> > # configuration of the server
>> > server {
>> > # the port your site will be served on
>> > listen  9004;
>> > # the domain name it will serve for
>> > server_name foo.bar.com;
>> > charset utf-8;
>> >
>> > # max upload size
>> > client_max_body_size 75M;   # adjust to taste
>> >
>> > # Django media
>> > location /media  {
>> > alias /projects/elucid/elucid/media;
>> > }
>> >
>> > location /static {
>> > alias /projects/elucid/static;
>> > }
>> >
>> > # Finally, send all non-media requests to the Django server.
>> > location / {
>> > uwsgi_pass  django;
>> > include /projects/elucid/elucid/uwsgi_params;
>> > }
>> > }
>> >
>> > /etc/uwsgi/sites/elucid_uwsgi.ini:
>> >
>> > # mysite_uwsgi.ini file
>> > [uwsgi]
>> >
>> > # Django-related settings
>> > # the base directory (full path)
>> > chdir   = /projects/elucid
>> > # Django's wsgi file
>> > module  = elucid.wsgi
>> > # the virtualenv (full path)
>> > # home= /
>> >
>> > # process-related settings
>> > # master
>> > master  = true
>> > # maximum number of worker processes
>> > processes   = 10
>> > # the socket (use the full path to be safe
>> > socket  = /projects/elucid/elucid.sock
>> > # ... with appropriate permissions - may be needed
>> > chmod-socket= 666
>> > # clear environment on exit
>> > vacuum  = true
>> > logto   = /var/log/uwsgi/error.log
>> >
>> > /etc/systemd/system/uwsgi.service:
>> >
>> > [Unit]
>> > Description=uWSGI Emperor service
>> >
>> > [Service]
>> > ExecStartPre=/usr/bin/bash -c 'mkdir -p /run/uwsgi; chown nginx
>> > /run/uwsgi'
>> > ExecStart=/usr/bin/uwsgi --emperor /etc/uwsgi/sites
>> > Restart=always
>> > KillSignal=SIGQUIT
>> > Type=notify
>> > NotifyAccess=all
>> >
>> > [Install]
>> > WantedBy=multi-user.target
>> >
>> > wsgi.py:
>> >
>> > import os
>> > from django.core.wsgi import get_wsgi_application
>> > os.environ.setdefault("DJANGO_SETTINGS_MODULE", "elucid.settings")
>> > application = get_wsgi_application()

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


Re: django1.6 with uwsgi and nginx on RHEL 7

2016-06-06 Thread Avraham Serour
you should use isolated virtual environments for each python project, don't
install packages on the system wide python, see
https://virtualenv.pypa.io/en/stable/


On Mon, Jun 6, 2016 at 11:45 PM, Larry Martell 
wrote:

> I figured this out - the problem turned out to be that the RHEL 7
> machine had django 1.6.0 whereas the RHEL 6 machine had 1.6.10. Once I
> installed 1.6.10 on the 7 machine all was well.
>
> On Mon, Jun 6, 2016 at 12:50 PM, Larry Martell 
> wrote:
> > I have successfully deployed django1.6 with uwsgi and nginx on RHEL6
> > but I cannot seem to get it working on RHEL7.
> >
> > I get Internal Server Error in the browser, and this in the uwsgi log:
> >
> > --- no python application found, check your startup logs for errors ---
> > [pid: 10582|app: -1|req: -1/2] xx.xx.xx.xx () {46 vars in 803 bytes}
> > [Mon Jun  6 11:58:50 2016] GET /favicon.ico => generated 21 bytes in 0
> > msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
> >
> > I have tried everything I can think of. Where am I going wrong here?
> >
> > Here are my files:
> >
> > nginx config:
> >
> > upstream django {
> > server unix:///projects/elucid/elucid.sock; # for a file socket
> > }
> >
> > # configuration of the server
> > server {
> > # the port your site will be served on
> > listen  9004;
> > # the domain name it will serve for
> > server_name foo.bar.com;
> > charset utf-8;
> >
> > # max upload size
> > client_max_body_size 75M;   # adjust to taste
> >
> > # Django media
> > location /media  {
> > alias /projects/elucid/elucid/media;
> > }
> >
> > location /static {
> > alias /projects/elucid/static;
> > }
> >
> > # Finally, send all non-media requests to the Django server.
> > location / {
> > uwsgi_pass  django;
> > include /projects/elucid/elucid/uwsgi_params;
> > }
> > }
> >
> > /etc/uwsgi/sites/elucid_uwsgi.ini:
> >
> > # mysite_uwsgi.ini file
> > [uwsgi]
> >
> > # Django-related settings
> > # the base directory (full path)
> > chdir   = /projects/elucid
> > # Django's wsgi file
> > module  = elucid.wsgi
> > # the virtualenv (full path)
> > # home= /
> >
> > # process-related settings
> > # master
> > master  = true
> > # maximum number of worker processes
> > processes   = 10
> > # the socket (use the full path to be safe
> > socket  = /projects/elucid/elucid.sock
> > # ... with appropriate permissions - may be needed
> > chmod-socket= 666
> > # clear environment on exit
> > vacuum  = true
> > logto   = /var/log/uwsgi/error.log
> >
> > /etc/systemd/system/uwsgi.service:
> >
> > [Unit]
> > Description=uWSGI Emperor service
> >
> > [Service]
> > ExecStartPre=/usr/bin/bash -c 'mkdir -p /run/uwsgi; chown nginx
> /run/uwsgi'
> > ExecStart=/usr/bin/uwsgi --emperor /etc/uwsgi/sites
> > Restart=always
> > KillSignal=SIGQUIT
> > Type=notify
> > NotifyAccess=all
> >
> > [Install]
> > WantedBy=multi-user.target
> >
> > wsgi.py:
> >
> > import os
> > from django.core.wsgi import get_wsgi_application
> > os.environ.setdefault("DJANGO_SETTINGS_MODULE", "elucid.settings")
> > application = get_wsgi_application()
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CACwCsY7iXZJMcwn7ZuCgMeOv9brh9HF3xgDfE1B0Z%2BN_bJfWGw%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: django1.6 with uwsgi and nginx on RHEL 7

2016-06-06 Thread Larry Martell
I figured this out - the problem turned out to be that the RHEL 7
machine had django 1.6.0 whereas the RHEL 6 machine had 1.6.10. Once I
installed 1.6.10 on the 7 machine all was well.

On Mon, Jun 6, 2016 at 12:50 PM, Larry Martell  wrote:
> I have successfully deployed django1.6 with uwsgi and nginx on RHEL6
> but I cannot seem to get it working on RHEL7.
>
> I get Internal Server Error in the browser, and this in the uwsgi log:
>
> --- no python application found, check your startup logs for errors ---
> [pid: 10582|app: -1|req: -1/2] xx.xx.xx.xx () {46 vars in 803 bytes}
> [Mon Jun  6 11:58:50 2016] GET /favicon.ico => generated 21 bytes in 0
> msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
>
> I have tried everything I can think of. Where am I going wrong here?
>
> Here are my files:
>
> nginx config:
>
> upstream django {
> server unix:///projects/elucid/elucid.sock; # for a file socket
> }
>
> # configuration of the server
> server {
> # the port your site will be served on
> listen  9004;
> # the domain name it will serve for
> server_name foo.bar.com;
> charset utf-8;
>
> # max upload size
> client_max_body_size 75M;   # adjust to taste
>
> # Django media
> location /media  {
> alias /projects/elucid/elucid/media;
> }
>
> location /static {
> alias /projects/elucid/static;
> }
>
> # Finally, send all non-media requests to the Django server.
> location / {
> uwsgi_pass  django;
> include /projects/elucid/elucid/uwsgi_params;
> }
> }
>
> /etc/uwsgi/sites/elucid_uwsgi.ini:
>
> # mysite_uwsgi.ini file
> [uwsgi]
>
> # Django-related settings
> # the base directory (full path)
> chdir   = /projects/elucid
> # Django's wsgi file
> module  = elucid.wsgi
> # the virtualenv (full path)
> # home= /
>
> # process-related settings
> # master
> master  = true
> # maximum number of worker processes
> processes   = 10
> # the socket (use the full path to be safe
> socket  = /projects/elucid/elucid.sock
> # ... with appropriate permissions - may be needed
> chmod-socket= 666
> # clear environment on exit
> vacuum  = true
> logto   = /var/log/uwsgi/error.log
>
> /etc/systemd/system/uwsgi.service:
>
> [Unit]
> Description=uWSGI Emperor service
>
> [Service]
> ExecStartPre=/usr/bin/bash -c 'mkdir -p /run/uwsgi; chown nginx /run/uwsgi'
> ExecStart=/usr/bin/uwsgi --emperor /etc/uwsgi/sites
> Restart=always
> KillSignal=SIGQUIT
> Type=notify
> NotifyAccess=all
>
> [Install]
> WantedBy=multi-user.target
>
> wsgi.py:
>
> import os
> from django.core.wsgi import get_wsgi_application
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "elucid.settings")
> application = get_wsgi_application()

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


Re: Allow users to vote up, down or nothing

2016-06-06 Thread ludovic coues
I will assume user can vote a specific article. I would go for another
model, like that

class VoteForArticle(models.Model):
DOWN = 0
NEUTRAL = 1
UP = 2
VOTES = ((DOWN, "down"), (NEUTRAL, "neutral)", (UP, "up"))
user = models.ForeignKey(settings.AUTH_USER_MODEL)
article = models.ForeignKey("Article")
vote = models.IntegerField(choices=VOTES)

If you are concerned with space, use a models.CharField with max_length = 1

2016-06-06 18:35 GMT+02:00 Avraham Serour :

> Maybe a nullable boolean field
> On Jun 6, 2016 6:27 PM, "Robin Lery"  wrote:
>
>> Hello,
>> I have made an app to create article. This is the model:
>>
>> class Article(models.Model):
>> user = models.ForeignKey(settings.AUTH_USER_MODEL)
>> title = models.CharField(max_length=150)
>> body = models.TextField()
>> pub_date = models.DateTimeField(default=timezone.now)
>> tags = models.ManyToManyField(Tag)
>> article_image = models.ImageField(upload_to=get_upload_file_name,
>> blank=True)
>>
>> Here I want to setup a voting system for each app. There I would the user
>> to vote up, or vote down, or do nothing. Boolean field would have been
>> great, but since an article can have 3 choices of votes  (vote up / vote
>> down / no vote ), how should I go about doing this? Your help and guidance
>> will be very much appreciated.
>>
>> Thank you.
>>
>>
>> 
>>  Virus-free.
>> www.avast.com
>> 
>> <#m_387066654494763674_m_1256279215608716353_DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CA%2B4-nGo-pNLjsEoE5bVT%3DaGxcJGcCm9nvx%2Bqjj8J6rT2J%3Dgq%3DQ%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFWa6t%2BP5jGVHKW1zuDaV9GqfDWBz3Vx8ChSHHSkt3bf1hACQA%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Cordialement, Coues Ludovic
+336 148 743 42

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


django1.6 with uwsgi and nginx on RHEL 7

2016-06-06 Thread Larry Martell
I have successfully deployed django1.6 with uwsgi and nginx on RHEL6
but I cannot seem to get it working on RHEL7.

I get Internal Server Error in the browser, and this in the uwsgi log:

--- no python application found, check your startup logs for errors ---
[pid: 10582|app: -1|req: -1/2] xx.xx.xx.xx () {46 vars in 803 bytes}
[Mon Jun  6 11:58:50 2016] GET /favicon.ico => generated 21 bytes in 0
msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)

I have tried everything I can think of. Where am I going wrong here?

Here are my files:

nginx config:

upstream django {
server unix:///projects/elucid/elucid.sock; # for a file socket
}

# configuration of the server
server {
# the port your site will be served on
listen  9004;
# the domain name it will serve for
server_name foo.bar.com;
charset utf-8;

# max upload size
client_max_body_size 75M;   # adjust to taste

# Django media
location /media  {
alias /projects/elucid/elucid/media;
}

location /static {
alias /projects/elucid/static;
}

# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass  django;
include /projects/elucid/elucid/uwsgi_params;
}
}

/etc/uwsgi/sites/elucid_uwsgi.ini:

# mysite_uwsgi.ini file
[uwsgi]

# Django-related settings
# the base directory (full path)
chdir   = /projects/elucid
# Django's wsgi file
module  = elucid.wsgi
# the virtualenv (full path)
# home= /

# process-related settings
# master
master  = true
# maximum number of worker processes
processes   = 10
# the socket (use the full path to be safe
socket  = /projects/elucid/elucid.sock
# ... with appropriate permissions - may be needed
chmod-socket= 666
# clear environment on exit
vacuum  = true
logto   = /var/log/uwsgi/error.log

/etc/systemd/system/uwsgi.service:

[Unit]
Description=uWSGI Emperor service

[Service]
ExecStartPre=/usr/bin/bash -c 'mkdir -p /run/uwsgi; chown nginx /run/uwsgi'
ExecStart=/usr/bin/uwsgi --emperor /etc/uwsgi/sites
Restart=always
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all

[Install]
WantedBy=multi-user.target

wsgi.py:

import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "elucid.settings")
application = get_wsgi_application()

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


Re: Allow users to vote up, down or nothing

2016-06-06 Thread Avraham Serour
Maybe a nullable boolean field
On Jun 6, 2016 6:27 PM, "Robin Lery"  wrote:

> Hello,
> I have made an app to create article. This is the model:
>
> class Article(models.Model):
> user = models.ForeignKey(settings.AUTH_USER_MODEL)
> title = models.CharField(max_length=150)
> body = models.TextField()
> pub_date = models.DateTimeField(default=timezone.now)
> tags = models.ManyToManyField(Tag)
> article_image = models.ImageField(upload_to=get_upload_file_name,
> blank=True)
>
> Here I want to setup a voting system for each app. There I would the user
> to vote up, or vote down, or do nothing. Boolean field would have been
> great, but since an article can have 3 choices of votes  (vote up / vote
> down / no vote ), how should I go about doing this? Your help and guidance
> will be very much appreciated.
>
> Thank you.
>
>
> 
>  Virus-free.
> www.avast.com
> 
> <#m_1256279215608716353_DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2B4-nGo-pNLjsEoE5bVT%3DaGxcJGcCm9nvx%2Bqjj8J6rT2J%3Dgq%3DQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Django inside Docker

2016-06-06 Thread Davi Diório Mendes
Ezequiel helped me at hangouts.

at settings.py I had:
TEMPLATES: [
{
[...]
'DIRS': ['templates']
[...]
},
]

and as Ezequiel said, is better to use:
'DIRS': [os.path.join(BASE_DIR, 'templates')]

now everything is working,

Thank you Ezequiel, and everyone that helped me here.

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


Re: Django inside Docker

2016-06-06 Thread Davi Diório Mendes
Hi, sorry the late response

Ezequiel, this docker will run on an IBM PowerPC and there is no base image 
ready to ppc64 architecture.
Soon this dockerfile will be ported to ppc64.

Akhil, I use this snippet to run the image
docker run -d --name ltc-client \
-v $(PROJ_HOME)/client:/home/client \
ddiorio/ltc-client:latest

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


Re: Loader Template without context (request), Use Case and Proposal

2016-06-06 Thread Tim Graham
Doesn't seem too likely to me as all user-facing rendering functions would 
have to accept (require?) the request argument.

By the way, not sure if this post might have been meant for the 
django-developers mailing list?

On Monday, June 6, 2016 at 6:02:26 AM UTC-4, aRkadeFR wrote:
>
>
> Hello all, 
>
> I'd like to open a discussion on the Loader Template 
> (django/template/loaders/app_directories.py) 
> which is linked to the Template Engine (django/template/engine.py) about 
> the context it has when determining the templates to load. 
>
> ## Use Case 
>
> In order to do multi-tenancy on our project, we set the current_site on 
> the input request in a middleware (almost the same as 
> django/contrib/sites/middleware.py). 
>
> Then our part of the system base its computation on the current_site of 
> the request. 
>
> Some of our clients needs to have specific markup template (.html 
> template). 
>
> In order to do that, we chose a hierarchy of templates, that can be 
> overriden if we have another folder with the same name of the 
> client/website. 
>
> Let's take an example: 
>
> We have as templates: 
> - /default/base.html 
> - /custom/base.html 
>
> If the request.site is named "custom", then we want to load the 
> /custom/base.html . Otherwise we load the /default/base.html 
>
>
> ## Problem encounter 
>
> The Loader for the template doesn't have any context, and so we have 
> setup a global state with the request in threads local. I personnaly 
> hate global state in Django 
> (https://code.djangoproject.com/wiki/GlobalState). 
>
>
> ## Proposal 
>
> I'd like to know if we could add the possibility to have more context on 
> the Loader? At least the request? 
>
> This is a bit of refacto in the code of Django as the Engine is created 
> only once for every Django process. 
>
>
> Thanks for your reading, 
>
> Have a good day 
>

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


Allow users to vote up, down or nothing

2016-06-06 Thread Robin Lery
Hello,
I have made an app to create article. This is the model:

class Article(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL)
title = models.CharField(max_length=150)
body = models.TextField()
pub_date = models.DateTimeField(default=timezone.now)
tags = models.ManyToManyField(Tag)
article_image = models.ImageField(upload_to=get_upload_file_name,
blank=True)

Here I want to setup a voting system for each app. There I would the user
to vote up, or vote down, or do nothing. Boolean field would have been
great, but since an article can have 3 choices of votes  (vote up / vote
down / no vote ), how should I go about doing this? Your help and guidance
will be very much appreciated.

Thank you.


Virus-free.
www.avast.com

<#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

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


Re: Django suit and Static files not working in Django 1.6

2016-06-06 Thread Ricardo Daniel Quiroga
The current version for django 1.6 is obsolete... please upgrade to 1.9

2016-06-01 15:34 GMT-03:00 Roger Lanoue jr :

> Hello All.
>
> I learning my first Django experience and I am making some headway. I am
> stuck on my test server and Django suit admin.
>
> I my goal is to get the new admin from Django suit to work.
>
> *Server setup*
> Ubuntu 14.04 ( A Digital Ocean VPS with one click install )
> Django Version 1.6
> Python: 2.7
> Nginx
> Postgres
>
> *Test server *
> http://162.243.201.237/
>
> *Admin (with django suit installed ) *
> http://django-suit.readthedocs.io/en/develop/
> http://162.243.201.237/admin/
>
> User: Demo
> password: Demo
>
> The css is being applied to the djando suit .
>
> *Ran command:*
> python manage.py collectstatic
>
> Results: 0 static files copied, 116 unmodified.
>
>
> *My setting.py basics*
>
> DEBUG = False
>
> TEMPLATE_DEBUG = False
>
> STATIC_URL = '/static/'
>
> STATICFILES_DIRS = [
> os.path.join(BASE_DIR, "static"),
> '/home/django/django_project/static/',
>
> When I look in to the static directory. nothing had been copied.
>
> Thank your for taking time to look at this and also sharing with me any
> clues on how to fix this.
>
> Roger
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ee2b40b1-0716-4f5b-b4f1-8f35a60d54f6%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Ricardo Daniel Quiroga

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


Loader Template without context (request), Use Case and Proposal

2016-06-06 Thread aRkadeFR

Hello all,

I'd like to open a discussion on the Loader Template 
(django/template/loaders/app_directories.py)
which is linked to the Template Engine (django/template/engine.py) about
the context it has when determining the templates to load.

## Use Case

In order to do multi-tenancy on our project, we set the current_site on
the input request in a middleware (almost the same as
django/contrib/sites/middleware.py).

Then our part of the system base its computation on the current_site of
the request.

Some of our clients needs to have specific markup template (.html
template).

In order to do that, we chose a hierarchy of templates, that can be
overriden if we have another folder with the same name of the
client/website.

Let's take an example:

We have as templates:
- /default/base.html
- /custom/base.html

If the request.site is named "custom", then we want to load the
/custom/base.html . Otherwise we load the /default/base.html


## Problem encounter

The Loader for the template doesn't have any context, and so we have
setup a global state with the request in threads local. I personnaly
hate global state in Django
(https://code.djangoproject.com/wiki/GlobalState).


## Proposal

I'd like to know if we could add the possibility to have more context on
the Loader? At least the request?

This is a bit of refacto in the code of Django as the Engine is created
only once for every Django process.


Thanks for your reading,

Have a good day

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


ANN: eGenix PyRun - One file Python Runtime 2.2.1

2016-06-06 Thread eGenix Team: M.-A. Lemburg


ANNOUNCING

eGenix PyRun - One file Python Runtime

Version 2.2.1


   An easy-to-use single file relocatable Python run-time -
  available for Linux, Mac OS X and Unix platforms,
  with support for Python 2.6, 2.7, 3.4 and
 * now also for Python 3.5 *


This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-PyRun-2.2.1-GA.html



INTRODUCTION

eGenix PyRun is our open source, one file, no installation version of
Python, making the distribution of a Python interpreter to run based
scripts and applications to Unix based systems as simple as copying a
single file.

eGenix PyRun's executable only needs 11MB for Python 2 and 13MB for
Python 3, but still supports most Python application and scripts - and
it can be compressed to just 3-4MB using upx, if needed.

Compared to a regular Python installation of typically 100MB on disk,
eGenix PyRun is ideal for applications and scripts that need to be
distributed to several target machines, client installations or
customers.

It makes "installing" Python on a Unix based system as simple as
copying a single file.

eGenix has been using eGenix PyRun internally in the mxODBC Connect
Server product since 2008 with great success and decided to make it
available as a stand-alone open-source product.

We provide both the source archive to build your own eGenix PyRun, as
well as pre-compiled binaries for Linux, FreeBSD and Mac OS X, as 32-
and 64-bit versions. The binaries can be downloaded manually, or you
can let our automatic install script install-pyrun take care of the
installation: ./install-pyrun dir and you're done.

Please see the product page for more details:

http://www.egenix.com/products/python/PyRun/



NEWS

This minor level release of eGenix PyRun comes with the following
enhancements:

Enhancements / Changes
--

 * Fixed support for -u command line option with Python 3. Since this
   is used by pip since version 8.0, it also removes issues with pip.

 * Removed ensurepip package from PyRun since this only works with
   access to the bundled whl files. This is incompatible with the
   frozen nature of packages in PyRun.

 * Added support for setting the OpenSSL path to the Makefile and have
   it look in /usr/local/ssl before reverting to system dirs to make
   it easier to link against more recent builds of OpenSSL.

 * Linking against OpenSSL 1.0.2 now on Mac OS X for the precompiled
   pyrun binaries. You may have to set your shared linker path to
   point to the right OpenSSL version.


install-pyrun Quick Install Enhancements
-

eGenix PyRun includes a shell script called install-pyrun, which
greatly simplifies installation of PyRun. It works much like the
virtualenv shell script used for creating new virtual environments
(except that there's nothing virtual about PyRun environments).

https://downloads.egenix.com/python/install-pyrun

With the script, an eGenix PyRun installation is as simple as running:

./install-pyrun targetdir

This will automatically detect the platform, download and install the
right pyrun version into targetdir.

We have updated this script since the last release:

 * Fixed install-pyrun to work with new PyPI package URL scheme (see

https://bitbucket.org/pypa/pypi/issues/438/backwards-compatible-un-hashed-package).
The
   options --pip-version=latest et al. should now work again.

 * Updated install-pyrun to default to eGenix PyRun 2.2.1 and its
   feature set.

For a complete list of changes, please see the eGenix PyRun Changelog:

http://www.egenix.com/products/python/PyRun/changelog.html



LICENSE

eGenix PyRun is distributed under the eGenix.com Public License 1.1.0
which is an Open Source license similar to the Python license. You can
use eGenix PyRun in both commercial and non-commercial settings
without fee or charge.

Please see our license page for more details:

http://www.egenix.com/products/python/PyRun/license.html

The package comes with full source code.



DOWNLOADS

The download archives and instructions for installing eGenix PyRun can
be found at:

http://www.egenix.com/products/python/PyRun/

As always, we are providing pre-built binaries for all common
platforms: Windows 32/64-bit, Linux 32/64-bit, FreeBSD 32/64-bit, Mac
OS X 32/64-bit. Source code archives are available for installation on
other platforms, such as Solaris, AIX, HP-UX, etc.

___

SUPPORT