Django poll app is a full featured polling app. You have to register in this app to show the polls and to vote. If you already voted you can not vote again. Only the owner of a poll can add poll , edit poll, update poll, delete poll , add choice, update choice, delete choice and end a poll. If a poll is ended it can not be voted. Ended poll only shows user the final result of the poll. There is a search option for polls. Also user can filter polls by name, publish date, and by number of voted. Pagination will work even after applying filter.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
python== 3.5 or up and django==2.0 or up
open terminal and type
git clone https://github.com/devmahmud/Django-poll-app.git
https://github.com/devmahmud/Django-poll-app.git
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
pip install faker
python manage.py shell
import seeder
seeder.seed_all(30)
Here 30 is a number of entry. You can use it as your own
- Get your smtp host details and replace following values in your
settings.py
# Configure email settings
EMAIL_HOST = '<your smtp host>'
EMAIL_PORT = '<smtp port>'
EMAIL_HOST_USER = '<smtp host user>'
EMAIL_HOST_PASSWORD = '<smtp host pass>'
DEFAULT_FROM_EMAIL = '<from email address>'
-
Sign Up for an OpenAI Account:
- Go to OpenAI’s website and sign up for an account if you don't have one.
-
Navigate to API Keys:
- After logging in, go to the API section of your account by visiting OpenAI API Keys.
-
Create a New API Key:
- Click on the "Create new key" button. A new API key will be generated for you.
-
Copy Your API Key:
- Copy the API key to your clipboard. You will need this key to access OpenAI services.
-
Set Up Your Environment:
- Add the API key to your environment variables. You can do this by setting an environment variable in your terminal or adding it to a
.env
file or add in settings.py . For example, you can set it in your.env
file like this:OPENAI_API_KEY=your_api_key_here
- Add the API key to your environment variables. You can do this by setting an environment variable in your terminal or adding it to a
Obtaining OAuth Client ID for Google
-
Go to the Google Cloud Console:
- Navigate to Google Cloud Console.
- Sign in with your Google account.
-
Create a new project:
- Click on the project dropdown menu at the top of the page.
- Click on "New Project" and follow the prompts to create a new project.
-
Enable the Google Identity service:
- In the Google Cloud Console, navigate to "APIs & Services" > "Dashboard."
- Click on "Enable APIs and Services."
- Search for "Google Identity" or "Google+ API" and enable it for your project.
-
Create OAuth consent screen:
- In the Google Cloud Console, navigate to "APIs & Services" > "OAuth consent screen."
- Fill in the required fields (like application name, user support email, etc.).
- Add scopes (permissions) your application requires.
- Save the consent screen information.
-
Create OAuth credentials:
- In the Google Cloud Console, navigate to "APIs & Services" > "Credentials."
- Click on "Create Credentials" > "OAuth client ID."
- Select "Web application" as the application type.
- Enter a name for your OAuth client.
- Add authorized redirect URIs :
http://127.0.0.1:8000/complete/google-oauth2/
- Click "Create."
-
Copy the client ID and client secret:
-
Once the OAuth client is created, you'll see your client ID and client secret.
-
Copy these values and update the following variables in settings.py
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = 'your-client-id' SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = 'your-client-secret'
-
For detailed instructions, refer to Google's documentation on OAuth 2.0.
Obtaining OAuth Client ID for Facebook
-
Create a Facebook App:
- Go to the Facebook Developers website and log in.
- Click on "My Apps" and then "Create App".
- Enter the required information for your app (display name, contact email, etc.) and create the app.
-
Configure Basic Settings:
- In your app dashboard, go to Settings > Basic.
- Add a platform (select Website) and enter your site URL(http://127.0.0.1:8000/complete/facebook/).
- Save your changes.
-
Get App ID and App Secret:
- Update the following settings to your settings file, replacing
'your-facebook-client-id'
and'your-facebook-client-secret'
with your actual LinkedIn app credentials:
SOCIAL_AUTH_FACEBOOK_OAUTH2_KEY = 'your-client-id' SOCIAL_AUTH_FACEBOOK_OAUTH2_SECRET = 'your-client-secret'
- Update the following settings to your settings file, replacing
Obtaining OAuth Client ID for LinkedIn
- Go to the LinkedIn Developer Portal and sign in.
- Click on "Create App" and fill in the required details, such as the app name, description, and logo.
- In the "Authorized Redirect URLs" section, add the callback URL for your Django app. This URL will be like
http://127.0.0.1:8000/complete/linkedin/
. - Save the changes and note down the Client ID and Client Secret provided by LinkedIn.
1. Update the following settings to your settings file, replacing `'your-linkedin-client-id'` and `'your-linkedin-client-secret'` with your actual LinkedIn app credentials:
```python
SOCIAL_AUTH_LINKEDIN_OAUTH2_KEY = 'your-client-id'
SOCIAL_AUTH_LINKEDIN_OAUTH2_SECRET = 'your-client-secret'
```
python manage.py runserver
Then go to http://127.0.0.1:8000 in your browser
Mahmudul alam
Email: expelmahmud@gmail.com