These are chat archives for django/django

17th
Apr 2017
Anish Shrestha
@annshress
Apr 17 2017 07:19
adding permission to a url namespace
Any idea how?
rather than applying decorator to each view within that namespace
Kaushal Kumar
@kaushal087
Apr 17 2017 08:57
I have developed django project ( which has media/static files ) and when I run manage.py runserver everything works perfectly. I have deployed on nginx server with unicorn. But each time it gives unexpected error. Some media files and static files are loading. Some error goes in the log file others don't. How can I debug django on nginx gunicorn? I am also running binary package using command Please suggest a good method to debug django + nginx + gunicorn + MySql.
I have used this: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
to deploy on nginx.
Requirements:
appdirs==1.4.3
Django==1.10.5
django-timedeltafield==0.7.10
gunicorn==19.7.1
MySQL-python==1.2.5
oauthlib==2.0.2
olefile==0.44
packaging==16.8
Pillow==4.0.0
PyJWT==1.4.2
pyparsing==2.2.0
python-openid==2.2.5
python-social-auth==0.3.6
requests==2.13.0
requests-oauthlib==0.8.0
six==1.10.0
social-auth-app-django==1.1.0
social-auth-core==1.2.0
Kaushal Kumar
@kaushal087
Apr 17 2017 09:04
I am looking for a debugger using which I can debug django project running on nginx.
MBijman
@MBijman
Apr 17 2017 09:45
look into /var/log/nginx/error.log
Kaushal Kumar
@kaushal087
Apr 17 2017 09:58
@MBijman that doesn't log everything. I have setup nginx error log and I have also setup django LOGGING .. but many a times log is not created.
will pdb work with django-nginx?
MBijman
@MBijman
Apr 17 2017 09:58
/var/log/nginx/access.log has succesfull calls
mysql should have another log under /var/log/mysql/error.log
no because nginx is just the reverse proxy
gunicorn is the runner so you can do somthing there but I have never done that
here is a discussion about your problem
Marcdup1
@Marcdup1
Apr 17 2017 16:10

Hi, Im trying to use https://github.com/jmcnamara/XlsxWriter to create excel files and download them. I have the following:

        book = xlsxwriter.Workbook(output)
        sheet = book.add_worksheet()
        sheet.write('A1', 'Hello')

        book.close()

        response = HttpResponse(book, content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
        response['Content-Disposition'] = 'attachment; filename=foo.xlsx'

        return response

This downloads the file but in the file I have <xlsxwriter.workbook.Workbook object at 0x10e3e0be0> and not Hello

Gaurav Dabhade
@gauravdabhade24_twitter
Apr 17 2017 16:58
hi guys
anyone familiar with django-guardian?
Cristian Samaniego
@chrisRubiano
Apr 17 2017 18:13
hello, i have some data from a form which i will send through an API, but before sending it i want to format that data, what is the best practice for that?
Cristian Samaniego
@chrisRubiano
Apr 17 2017 18:44
i think i'll override the clean method for my form
Florian Dahlitz
@DahlitzFlorian
Apr 17 2017 18:51
Hello guys! I learn Django w/ the sample project "polls-application" from the django-documentation https://docs.djangoproject.com/en/1.11/intro/tutorial01/
and there is one question I have which is not mentioned in the tutorial: I have a Question model and a Choice model and both are related to each other (so every question has choices and every choice has a question). How can I get all questions which have at least one choice (so that questions w/o choices are not displayed later)? Thanks for you help
here is my current get_queryset()-method:
def get_queryset(self):
        """
        Return the last five published questions (Not including those 
        set to be published in the future)
        """
        # the filter says that it only returns those w/ the pub_date
        # less or equal to timezone.now() (earlier or now)
        return Question.objects.filter(
            pub_date__lte=timezone.now()
        ).order_by('-pub_date')[:5]
Eduardo Calvachi
@edu222
Apr 17 2017 20:13
Hi django peeps!
Philip Eckert
@pae4557
Apr 17 2017 20:16
Anybody have experience migrating from Sqlite3 to postgres?
Florian Dahlitz
@DahlitzFlorian
Apr 17 2017 20:23
@pae4557 https://docs.djangoproject.com/en/1.11/topics/install/#database-installation and https://docs.djangoproject.com/en/1.11/ref/databases/#postgresql-notes seem to be great starting points. At some point there are information about the migration you want
Philip Eckert
@pae4557
Apr 17 2017 21:05
@DahlitzFlorian Thanks!
Florian Dahlitz
@DahlitzFlorian
Apr 17 2017 22:08
Any cool project ideas for django? So apps that are really helpful?