I have a form where users submit protein sequences that are stored in the
user_submission model. In Django admin, I have added a custom list display
naming_algorithm (like below). It takes the obj. sequence and runs an
external script and displays the output in HTML. It works locally well.
When I try to use it on the production server it shows nginx 502 Bad
Gateway. FYI: I use nginx and uWSGI for deployment. Please let me know if
you need any other information.


class UserSubmissionAdmin(admin.ModelAdmin):

    list_display = (
        'submittersname',
        'accession_url',
        'naming_algorithm',
    )

   def naming_algorithm(self, obj):
        if ">" in str(obj.sequence).split('\n')[0]:
            obj.sequence = '\n'.join(
                str(obj.sequence).split('\n')[1:])
        return format_html('<a
href="/run_naming_algorithm/?fulltextarea={0}&submission_id={1}"
target="_blank">Naming Algorithm</a>'.format(obj.sequence, obj.id))

I have a few questions

1) In the production server if I change DEBUG=True the above function works
and displays the expected result. If I change it to DEBUG=False nginx
reports 502 Bad Gateway. I changed this to see a detailed traceback error.
Why this happens and how to approach the problem and fix it. Any pointers
will help.

2) As you can see in the screenshot, I am passing the protein sequence
through the URL. It seems to me there must be a better way to do it. I am
unaware of it. Do you have any suggestions or alternative ways or
source material to read?

Thank you
Kannan

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADiZb_dZLMPPr_guLvJQOGC7RLncjMwuNaQm8WhAXy--Td3DTg%40mail.gmail.com.

Reply via email to