Re: Hosting a django/python website/web app

2017-11-03 Thread Tim Chase
On 2017-11-03 09:20, Basilaik wrote:
> I have completed my my website using django/python, and got a
> hosting account with hostgator, i tried uploading it to the cpanel,
> but i dont know how to do the configuration.
> has any one ever hosted a website done with django on cpanel?

While I've not tried hosting a Django app with them, Hostgator was
bought out by EIG and their quality & service tanked.  EIG has a
reputation for buying out excellent hosting businesses, killing the
quality by putting too many customers on shared machines, raising
prices, firing all the good support staff and replacing them with
know-nothings, etc.

Flee.  EIG killed Bluehost, A Small Orange, Hostgator, Site5, and a
multitude of others.

Sincerely,

-tkc who has been burned multiple times by EIG buy-outs




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


Re: Hosting a django/python website/web app

2017-11-03 Thread ADEWALE ADISA
Is Hostigator support django app ?
On Nov 3, 2017 5:34 PM, "Basilaik"  wrote:

I have completed my my website using django/python, and got a hosting
account with hostgator, i tried uploading it to the cpanel, but i dont know
how to do the configuration.
has any one ever hosted a website done with django on cpanel?

-- 
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/7980b2a1-dc81-4b3b-bf80-8ec67eea3ec4%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMGzuy9LLYBgKWN7nxutLrLweugJsRo6egSCKTndjYe5%3DXLXpQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using iPage for email host

2017-11-03 Thread Sören Mindorf
Hi Lucas,

I checked the FAQ from ipage.
You should use startssl for Port 587.

It is described in the Django email instructions.

EMAIL_USE_TLS is needed!

Kind regards,
Soeren


Am 03.11.2017 19:06 schrieb "Lucas McBride" :

> Does anyone have any experience using iPage as an email host?
>
> I've tried using the instructions
>  on the Django Docs
> for setting up email hosts:
>
> EMAIL_HOST = 'smtp.ipage.com'
> EMAIL_HOST_USER = 'info@be-a.rocks'
> EMAIL_HOST_PASSWORD = ''
> EMAIL_PORT = 143
>
> But I just get a SMTPConnectError
>
> (-1, b'[CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE 
> UNSELECT STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.')
>
>
> iPage really does not have any useful support for this so I was wondering
> if anyone here has had to use iPage with Django that can help me out!
>
>
> Thanks!
>
> Lucas
>
> --
> 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/f72af4e2-80f2-4653-9819-fd360dd632af%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALFRwjjUH6ze60ej7dKR9jMLtPvgSjfjpFS%3DAKuDhxcqjahULA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using iPage for email host

2017-11-03 Thread Sören Mindorf
Hi Lucas,

i don't know this provider, maybe there is something not correct.
Did you try to deliver an email via telnet to see what is going wrong?


https://mediatemple.net/community/products/dv/204404584/sending-or-viewing-emails-using-telnet

But remember to use port 587.

Kind regards,
Soeren


Am 03.11.2017 21:12 schrieb "Lucas McBride" :

Hi Soeren!

Thanks for responding!

I tried using the new port and it is now a new error. There is a
SMTPRecipientsRefused error:

{'mcbride.luc...@gmail.com': (451, b'Temporary local problem - please
try later')}


Any idea what this means?

Thanks again!
Lucas





On Friday, November 3, 2017 at 2:44:09 PM UTC-4, Sören Mindorf wrote:

> Hey Lucas,
>
> you tried the imap Port not the smtp port.
> Dovecot is an imap service not smtp!
>
> Try port 587 this should be the right post to deliver emails as client.
>
> Kind Regards,
> Soeren
>
> Am 03.11.2017 19:06 schrieb "Lucas McBride" :
>
> Does anyone have any experience using iPage as an email host?
>
> I've tried using the instructions
>  on the Django Docs
> for setting up email hosts:
>
> EMAIL_HOST = 'smtp.ipage.com'
> EMAIL_HOST_USER = 'info@be-a.rocks'
> EMAIL_HOST_PASSWORD = ''
> EMAIL_PORT = 143
>
> But I just get a SMTPConnectError
>
> (-1, b'[CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE 
> UNSELECT STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.')
>
>
> iPage really does not have any useful support for this so I was wondering
> if anyone here has had to use iPage with Django that can help me out!
>
>
> Thanks!
>
> Lucas
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
>
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/django-users/f72af4e2-80f2-4653-9819-fd360dd632af%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/
msgid/django-users/93d5c054-cc51-43ba-ba8a-01f6131e8208%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALFRwjh1fkfR%2BSPhWejXvca5qKf1osZRF9gXQDZWdTvyPN9-uQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Using iPage for email host

2017-11-03 Thread Lucas McBride
Does anyone have any experience using iPage for an email host with Django?

I've tried using the instructions 
 on the Django Docs 
to send emails but it doesn't seem to work:

EMAIL_HOST = 'smtp.ipage.com'
EMAIL_HOST_USER = 'info@be-a.rocks'
EMAIL_HOST_PASSWORD = ''
EMAIL_PORT = 143

Using these settings I just get an SMTPConnectError:

(-1, b'[CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE 
UNSELECT STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.')


Does anyone know what is going on? Or what I have to do differently? 

I used this method for a Gmail account and it worked fine, but with iPage 
it seems to be different. 

Thanks!

Lucas

-- 
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/321c9060-5cba-495b-9266-d0d3ff1f6b2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using iPage for email host

2017-11-03 Thread Lucas McBride
Hi Soeren!

Thanks for responding!

I tried using the new port and it is now a new error. There is a 
SMTPRecipientsRefused error:

{'mcbride.luc...@gmail.com': (451, b'Temporary local problem - please try 
later')}


Any idea what this means?

Thanks again!
Lucas





On Friday, November 3, 2017 at 2:44:09 PM UTC-4, Sören Mindorf wrote:
>
> Hey Lucas, 
>
> you tried the imap Port not the smtp port. 
> Dovecot is an imap service not smtp! 
>
> Try port 587 this should be the right post to deliver emails as client. 
>
> Kind Regards, 
> Soeren
>
> Am 03.11.2017 19:06 schrieb "Lucas McBride"  >:
>
> Does anyone have any experience using iPage as an email host?
>
> I've tried using the instructions 
>  on the Django Docs 
> for setting up email hosts: 
>
> EMAIL_HOST = 'smtp.ipage.com'
> EMAIL_HOST_USER = 'info@be-a.rocks'
> EMAIL_HOST_PASSWORD = ''
> EMAIL_PORT = 143
>
> But I just get a SMTPConnectError
>
> (-1, b'[CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE 
> UNSELECT STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.')
>
>
> iPage really does not have any useful support for this so I was wondering 
> if anyone here has had to use iPage with Django that can help me out!
>
>
> Thanks!
>
> Lucas
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@googlegroups.com .
> To post to this group, send email to django...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/f72af4e2-80f2-4653-9819-fd360dd632af%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/93d5c054-cc51-43ba-ba8a-01f6131e8208%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using iPage for email host

2017-11-03 Thread Sören Mindorf
Hey Lucas,

you tried the imap Port not the smtp port.
Dovecot is an imap service not smtp!

Try port 587 this should be the right post to deliver emails as client.

Kind Regards,
Soeren

Am 03.11.2017 19:06 schrieb "Lucas McBride" :

Does anyone have any experience using iPage as an email host?

I've tried using the instructions
 on the Django Docs
for setting up email hosts:

EMAIL_HOST = 'smtp.ipage.com'
EMAIL_HOST_USER = 'info@be-a.rocks'
EMAIL_HOST_PASSWORD = ''
EMAIL_PORT = 143

But I just get a SMTPConnectError

(-1, b'[CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID
ENABLE IDLE UNSELECT STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.')


iPage really does not have any useful support for this so I was wondering
if anyone here has had to use iPage with Django that can help me out!


Thanks!

Lucas

-- 
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/f72af4e2-80f2-4653-9819-fd360dd632af%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALFRwjg4RMBGrSdunM8ur%2BZQgo76nXrio1jnzStGbUHtxpAxMg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Using iPage for email host

2017-11-03 Thread Lucas McBride
Does anyone have any experience using iPage as an email host?

I've tried using the instructions 
 on the Django Docs 
for setting up email hosts: 

EMAIL_HOST = 'smtp.ipage.com'
EMAIL_HOST_USER = 'info@be-a.rocks'
EMAIL_HOST_PASSWORD = ''
EMAIL_PORT = 143

But I just get a SMTPConnectError

(-1, b'[CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE 
UNSELECT STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.')


iPage really does not have any useful support for this so I was wondering 
if anyone here has had to use iPage with Django that can help me out!


Thanks!

Lucas

-- 
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/f72af4e2-80f2-4653-9819-fd360dd632af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-11-03 Thread fábio andrews rocha marques
I'm using python code to verify the fields. I'm doing it on a View. But 
with javascript maybe I can solve this issue where i don't need to reload 
the page. But if i do that, can i do things like check the database to see 
if it already contains some value? Or store something on request.session 
for later?

On Thursday, November 2, 2017 at 6:43:18 PM UTC-3, James Schneider wrote:
>
>
>
> On Thu, Nov 2, 2017 at 12:57 PM, fábio andrews rocha marques <
> fabioandrews...@gmail.com > wrote:
>
>> To use django forms is to use the django Form class and it's components 
>> on a view? How will this solve the issue? If i use the components, don't i 
>> have to re-render the page when a user makes an error on the form?
>>
>>
> Are you submitting and rendering the information entirely via JavaScript? 
> That would be the only case where you may get errant messages on the same 
> page where the user submitted the form. You'll need to examine your JS 
> workflow, as that is not a Django issue.  
>
> You'll integrate the form usage within your view. The Django tutorial 
> covers this using both function-based views and class-based views. You 
> should do this even when submitting the information via AJAX/JS, but the 
> page doesn't necessarily need to be redirected because your JS will handle 
> re-rendering the page properly. I'd recommend the Django Rest Framework 
> package in that case. 
>
> -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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f089a104-ed0e-4ae0-9567-668e4422fb57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Hosting a django/python website/web app

2017-11-03 Thread Basilaik
I have completed my my website using django/python, and got a hosting 
account with hostgator, i tried uploading it to the cpanel, but i dont know 
how to do the configuration.
has any one ever hosted a website done with django on cpanel?

-- 
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/7980b2a1-dc81-4b3b-bf80-8ec67eea3ec4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unable to use custom StaticFilesStorage

2017-11-03 Thread James Schneider
On Wed, Nov 1, 2017 at 11:35 AM, Stodge  wrote:

> I'm trying to add an extra directory for each app that will contain
> Javascript/CSS files. I created a custom storage.py in my app containing a
> copy of the code from Django's AppDirectoriesFinder class, but I changed
> source_dir from "static" to "catalog". I'll include the Django code with
> the modified source_dir so no-one has to check the source code:
>
> class AppCatalogStorage(FileSystemStorage):
> """
> A file system storage backend that takes an app module and works
> for the ``catalog`` directory of it.
> """
> prefix = None
> source_dir = 'catalog'  <--- changed, was 'static'
>
>
> def __init__(self, app, *args, **kwargs):
> """
> Returns a static file storage if available in the given app.
> """
> # app is the actual app module
> mod = import_module(app)
> mod_path = os.path.dirname(upath(mod.__file__))
> location = os.path.join(mod_path, self.source_dir)
> super(AppCatalogStorage, self).__init__(location, *args, **kwargs)
>
>
>
> I added this to my settings file:
>
> STATICFILES_STORAGE = (
>
> 'myapp.storage.AppCatalogStorage',
> 'django.contrib.staticfiles.storage.StaticFilesStorage'
> )
>
>
> My understanding here is that I can then do:
>
> (Assuming my app name is fred)
>
> fred/catalog/js/someJavascript.js
> fred/catalog/css/someStylesheet.css
>
>
> I also assumed they would then be accessible as:
>
> /static/fred/js/someJavascript.js
> /static/fred/css/someStylesheet.css
>
>
> However, neither file is available at the expected URL. Did I
> misunderstand something?
>
>
Quite honestly, instead of doing all of this work, why not just
amend STATICFILES_DIRS with the location of your extra folder? Or just use
the designated 'static/app_name' location for your JS files? Seems like a
ton of trouble now and in the future to try and implement your own file
structure. A symlink from catalog -> static/fred would also have the same
effect if you are on a Linux system.

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


executing python script in html button

2017-11-03 Thread Rizal M.
I have custom python script for twitter sentiment analysis, let's call it 
sentiment.py
it has two inputs, topic query and number of tweets.

this is the full code

import sys
import csv
import tweepy
import matplotlib.pyplot as plt

from collections import Counter
from aylienapiclient import textapi

if sys.version_info[0] < 3:
   input = raw_input()

## Twitter credentials
consumer_key = "xxx"
consumer_secret = "xxx"
access_token = "xxx"
access_token_secret = "xxx"

## AYLIEN credentials
application_id = "xxx"
application_key = "xxx"

## set up an instance of Tweepy
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)

## set up an instance of the AYLIEN Text API
client = textapi.Client(application_id, application_key)

## search Twitter for something that interests you
query = input("topic? \n")
number = input("number of tweets? \n")

results = api.search(
   lang="en",
   q=query + " -rt",
   count=number,
   result_type="recent"
)

print("--- Gathered Tweets \n")

## open a csv file to store the Tweets and their sentiment
file_name = 'Sentiment_Analysis_of_{}_Tweets_About_{}.csv'.format(number, query)

with open(file_name, 'w', newline='') as csvfile:
   csv_writer = csv.DictWriter(
   f=csvfile,
   fieldnames=["Tweet", "Sentiment"]
   )
   csv_writer.writeheader()

   print("--- Opened a CSV file to store the results of your sentiment 
analysis... \n")

## tidy up the Tweets and send each to the AYLIEN Text API
   for c, result in enumerate(results, start=1):
   tweet = result.text
   tidy_tweet = tweet.strip().encode('ascii', 'ignore')

   if len(tweet) == 0:
   print('Empty Tweet')
   continue

   response = client.Sentiment({'text': tidy_tweet})
   csv_writer.writerow({
   'Tweet': response['text'],
   'Sentiment': response['polarity']
   })

   print("Analyzed Tweet {}".format(c))

## count the data in the Sentiment column of the CSV file
with open(file_name, 'r') as data:
   counter = Counter()
   for row in csv.DictReader(data):
   counter[row['Sentiment']] += 1

   positive = counter['positive']
   negative = counter['negative']
   neutral = counter['neutral']

## declare the variables for the pie chart, using the Counter variables for 
"sizes"
colors = ['limegreen', 'dodgerblue', 'darkorchid']
sizes = [positive, negative, neutral]
labels = 'Positif', 'Negatif', 'Netral'
explode = (0.1, 0, 0)

## use matplotlib to plot the chart
plt.pie(
x=sizes,
shadow=False,
colors=colors,
labels=labels,
startangle=90,
explode=explode,
autopct='%1.0f%%'
)
plt.axis('equal')
plt.title("Sentiment of {} Tweets about {}".format(number, query))
plt.show()


how to execute that file in html web page.
let's say in the web page, there are two input texts, topic and number, and 
when I press the submit button, it executes the python script.

I'm new to this Django so please explain it with detail,

-- 
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/85d79e02-e517-45ea-a639-29856f1f5c65%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Hello all, try to make dropdown in form

2017-11-03 Thread JP
Hello all,
any help would be appreciated, I think this is basic stuff but can find how 
to do it online

So I made the class and the form and the view
every thing works but the background color of the drop down menu in the 
form is black and txt is grey (white when mouse is over). I don t think I 
have change default option, I really dont think these are default color.

How can I put white back ground and back text??
I follow this great tutorial and am trying to change a text field in the 
form and put drop down instead

https://www.youtube.com/watch?v=v5FWAxi5QqQ=33=PL6gx4Cwl9DGBlmzzFcLgDhKTTfNLfX1IK

here is some code:

product_type = models.CharField(max_length=100, choices = 
product_categories)




{{ field.errors }}

{{ field.label_tag }}
{{ field }}
...


Thanks for the 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5bc0a18c-f2cf-4163-ae7d-4c0578605199%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


ManytoMany field in Django admin not appearing

2017-11-03 Thread Paul
 

I have a Product model, an Image Model and a Category Model.

A Product can have multiple Images(Foreign Key) and a Product can be in 
multiple Categories a Category can contain multiple Products.

A Category can have multiple subcategories(key to itself).


class Category(MetaData): 
 parent = models.ForeignKey('self', blank=True, null=True, verbose_name='parent 
category', on_delete=models.CASCADE) 

class ProductMetaData): 
  categories = models.ManyToManyField(Category) 

class ProductImage(models.Model):  
  product = models.ForeignKey(Product, related_name='image', on_delete=
models.CASCADE)



In Product Django Admin: 

class ProductDocumentInline(admin.TabularInline): 
 model = ProductDocument class ProductAdmin(MetaData):
 inlines = [ProductImageInline]
 fieldsets = (
 ('Product Data', {
 'fields': ('name', 'short_description', 'description')
 }),
 ('SEO', {
 'classes': ('collapse',),
 'fields': ('meta_title', 'meta_description', 'slug', 'canonical')
 }),
 ('MetaData', {
 'classes': ('collapse',),
 'fields': (('created_at', 'created_by'), ('updated_at', 'updated_by'))
 }),
 )
 readonly_fields = ('created_at', 'updated_at', 'created_by', 'updated_by')
 list_display = ('name', 'updated_at')
 ordering = ('-updated_at',)
 search_fields = ('name',)


admin.site.register(Product, ProductAdmin)
admin.site.register(ProductImage)



Issues:

   1. 
   
   If I don't customize fieldsets (grouped, ordered) the Categories appear 
   like default in the middle of the form. If there are customized as in my 
   example they don't appear.
   2. 
   
   If they don't appear Products without Categories can be created and I 
   don't want that. I want a product to have at least one category.
   3. 
   
   Now the inline Images appear below all Product fields. 
   
I want the Categories to appear first, then normal fields for 
Product(grouped,ordered), Images inline and at the end the SEO and metadata 
fields. How can this be done ?

-- 
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/37bf83ae-cdca-4c73-8ace-747386513e53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: return jwt token as json

2017-11-03 Thread Jani Tiainen
According to pyjwt docs it can be either datetime object or number (unix
epoch)

https://pyjwt.readthedocs.io/en/latest/usage.html#expiration-time-claim-exp


3.11.2017 9.37 "James Schneider"  kirjoitti:

>
>
> On Oct 31, 2017 4:36 AM, "Rakhee Menon"  wrote:
>
>
>
> class Login(APIView):
>
>def post(self, request, *args, **kwargs):
>import ipdb;ipdb.set_trace()
>username = request.POST.get('username')
>password = request.POST.get('password')
>user = Person.objects.get(username=username, password=password)
> #user = user[0]
>#import ipdb;ipdb.set_trace()
>if user:
>payload = {
>'id': user.pk,
>'username': user.username,
>'staff': user.email,
>'exp': datetime.utcnow()
>
>
> I think that datetime.utcnow() returns a datetime object, not a string,
> and I don't think it can be serialized directly. You should try converting
> that object to a string in the right format. As a test, substitute a static
> string containing a date and time in whatever format you need. I'm not in
> front of an interpreter so I can't test, but this seems to back up my
> theory:
>
> https://code-maven.com/serialize-datetime-object-as-json-in-python
>
> -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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CA%2Be%2BciUy4yT%2BMsjAdH9pJXfhC4kBkSW832dbuZjq
> qLKCaKn5fQ%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/CAHn91od3H3XYL5opHAg6tuSjTXwRtZ3fO7mfD0%3DAH_vtOYz0jA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: return jwt token as json

2017-11-03 Thread James Schneider
   if user:
   payload = {
   'id': user.pk,
   'username': user.username,
   'staff': user.email,
   'exp': datetime.utcnow()


I think that datetime.utcnow() returns a datetime object, not a string, and
I don't think it can be serialized directly. You should try converting that
object to a string in the right format. As a test, substitute a static
string containing a date and time in whatever format you need. I'm not in
front of an interpreter so I can't test, but this seems to back up my
theory:

https://code-maven.com/serialize-datetime-object-as-json-in-python


Forgot to mention, you may also want to take a look at the built-in JSON
encoder, which handles datetime objects:

https://docs.djangoproject.com/en/1.11/topics/serialization/#djangojsonencoder

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


Re: return jwt token as json

2017-11-03 Thread James Schneider
On Oct 31, 2017 4:36 AM, "Rakhee Menon"  wrote:



class Login(APIView):

   def post(self, request, *args, **kwargs):
   import ipdb;ipdb.set_trace()
   username = request.POST.get('username')
   password = request.POST.get('password')
   user = Person.objects.get(username=username, password=password)
#user = user[0]
   #import ipdb;ipdb.set_trace()
   if user:
   payload = {
   'id': user.pk,
   'username': user.username,
   'staff': user.email,
   'exp': datetime.utcnow()


I think that datetime.utcnow() returns a datetime object, not a string, and
I don't think it can be serialized directly. You should try converting that
object to a string in the right format. As a test, substitute a static
string containing a date and time in whatever format you need. I'm not in
front of an interpreter so I can't test, but this seems to back up my
theory:

https://code-maven.com/serialize-datetime-object-as-json-in-python

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