Blog Aggregater using Django

Alright , let’s get to it.

Once you have made your project , app and added it to your settings.py (INSTALLED_APPS)  and urls.py file we’ll begin with working on the app.

Know once inside your app set urlpatterns inside urls.py to 3 functions within views.py. To accept the feed link, to save into models and display the content if a valid link is provided and to show the links the user have entered so far.

screenshot-from-2018-07-08-04-48-47-e1530990376542.png

The “feed” function is used to render the template for the user to input the link which is further passed into the “search” function .screenshot-from-2018-07-08-04-48-25-e1530990889552.png

screenshot-from-2018-07-08-04-49-02.png

Inside the “search” function we check if the user entered a blank text or an invalid link. Else using “feedparser” we extract the data from the feed and using regex we remove those unwanted html tags (<>) to make it look cleaner and finally rendered with the template.

screenshot-from-2018-07-08-04-48-251.png

screenshot-from-2018-07-08-04-55-03.png

 

Since we also need to save the link , if valid , into the models.py file, we make the following class.

screenshot-from-2018-07-08-04-48-54.png

And we come back into views.py , to make our “get” function to display the stored links. We obtain the links from the model using “RequestContext” in the form of a dictionary and then rendered with the template.

screenshot-from-2018-07-08-05-19-04.png

screenshot-from-2018-07-08-04-55-11.png

Now if you’re wondering how I got in the bootstrap files , all you have to do is make a “static” folder inside your app and place your bootstrap folders.

For reference visit my Github repo.

And that’s it!

Fun coding.

Advertisements

How To Setup localhost Of Drupal8 On Windows

To begin with…

What is Drupal?

Drupal is a free and open source content-management framework written in PHP .It is used to make different types of websites and applications .Pretty much like WordPress.

What is the need to create a localhost?

Well….. actually you can test anything on the website itself. But , anything can go wrong .Which may lead to complete lock down of the system for you and maybe for thousands more .And so it’s better to create a branch and mess with that whether you are a beginner or experienced .

Let’s begin….

Begin with:

  • Creating and account on drupal.org and drupallader.org for further support.
  • Install xampp and turn on Apache and MySQL.
    • Apache: Web server software. To run Drupal’s webserver.
    • MySQL: Used to run the database of Drupal.
  • Download drupal8 and extract.

Step 1:

Go to  xampp>htdocs and paste the extracted file . Name the folder drupal8 (remember this name).

Step 2:

Go to your browser and enter

localhost/phpmyadmin

Now set database name as drupal8 and press create. Next click privileges and add a user. The host name should be made local and all privileges must be granted (to prevent future errors) , click go.

Step 3:

Go to your browser and enter,

localhost/drupal8

Select language , next select standard profile , next check requirements (if PHP OPcode isn’t enabled no worries , it’s just to increase performance ) , enter database name (that I’ve told you to be remembered) , username and password. You might get an execution time error, just reload the page .

Error fix:

Goto xampp control panel click on config>php.ini .

Now make the following changes,

max_execution_time = 120

execution

Now stop and again start Apache. Next go to drupal8>sites>default and delete settings.php . Also to go to phpMyAdmin and drop your SQL table. And repeat step 3.

Step 4:

install

Installing of different modules should have begun by know .Let all 40 modules be installed. After installation you have to configure your site. Save and continue.

Step 5:

Next you will see the front page of Drupal,

drupal8shot

And Done!!

Happy Coding..!!

 

Blog at WordPress.com.

Up ↑