How to connect a completed Vue.js app (frontend) to Django (backend) - python

I'm currently doing a school project that tasks us to create a functioning web application (with database) for our university. Our application is an intranet-based activities logging system.
During our first term, we finished our frontend via Vue.js / Vuetify. It has complete routers (and multiple pages), functioning buttons and data-tables (and fake authentication).
Now, we need to connect it to the backend. We chose python django REST API as our research found that it would be faster to implement (our deadline is in 2 weeks tops). My question is how to (or if it's possible) to connect our vue.js application to django so that it can fetch login authentication and database queries to our SQL (postgreSQL).
We were using the Vue CLI during the building of our frontend.
Thank you!

You don't have to worry about integration much. This is a simple REST API and a Frontend framework.
You can find many tutorials online for the same and set it up from scratch, but keeping your deadlines in mind. I think you should use this boilerplate to start with: https://github.com/gtalarico/django-vue-template

Related

Should a background process be part of Django project?

I'm trying to build a web app which provide an interface to do some queries upon data extracted from another public API server.
To complete the queries in real time, I would have to prefetch the data from the public API server.
So I think it is reasonable to separate the app deal with query input(there is still some logic here, so only javascript wouldn't be enough) from the app which runs in background and builds the database which could possibly answer the query in real time.
Then what comes to my mind is does this background app really have to be a part of Django project? It runs almost without interacting with any Django component. Except for the database which is also accessible by a Django app and some signals maybe(when to start/stop collecting data, but this could probably also decided internally).
What would a be good design choice for my situation?

Using Django for communication between APIS?

I am new in the world of programming. I know a little python and I am learning Django. I understand that Django is very useful for webpages backend.
But I don't just want a website or an webapp. What I want is to centralize all the operations of my company by communicating through APIS different applications such as CRM (customer relationship management), SQL database, bulk mail software, etc.
For example, I want that when I perform an action in my CRM software (sales), it activates a scrapy script that I am creating, which scrapes certain pages, and then stores information in my SQL database.
Can I centralize all of this through Django as if it were a central base that connects all my scripts and the communications between APIs?
Yes. I would try doing any POST request to your Django server. In this code try doing a POST request to any other server. This should be all you need to get started building your central base.
Django has the ability to do what you are looking for. A good starting point for you if you choose to pursue would be DRF. Django REST framework is a powerful and flexible toolkit for building Web APIs.
However, I think you should also weigh the cost of maintaining and developing your own IPaaS (Integration Platform as a Service) with utilizing and conforming to some self-hosted / cloud-hosted IPaaS providers.
Some providers that accomplish what you may be trying to do can be found here.

How can I do Server Side Rendering of reactJS app with Python/Django as backend?

I have created the reactjs app using create-react-app and have used react-route-dom for routing. I have used Python/Django Rest Framework for the backend.I have used this tutorial to connect React with Django-
https://www.techiediaries.com/create-react-app-django/
Now I am facing issues like I can't post every page with the different previews and titles on social media platforms. Also, I have read the CSR(Client Side Rendering) is not good for SEO.
I think it would be better for you to create small NodeJS/Express server just as a web server for your React app. It will live separately on your REST API for which you can keep Phyton.
If I may recommend create-react-app is perfect for client side apps, but try to look into Next.js for server side rendered apps.

How to do socket programming in a django app

I have a Django web application which shows a website to display some data. So, this application consists of the html pages and views to display this data which i am storing in a SQLite DB.
At the end of the day a third party needs to connect to this web application and upload binary data over to the application. What is the best way to host this service, as an independent python web server or part of Django application or how else ?
Any suggestions would be appreciated !
If the uploading doesn't occur too often, why not just create a Django POST/PUT view for the job that simply accepts the file over HTTP? With the information you've provided, I cannot see why this simple solution wouldn't be up to the task.

Using Django minus the web server

I'm writing a syndication client, with the aim being to have a client for devices, and a web site that has the same functionality. I shall develop the website using Django - this is already decided; the client shall be written in python with both a CLI and a PyQt4 GUI. I have been writing the clinet first, and it's fairly database-heavy, as everything is cached to enable it to be read while offline.
It struck me today that it would make sense to use Django models for my application, to reduce the repetition of effort between the client and the website. My question is how easy it is to seperate this, and how much of Django I will need in my client to use Django's models. AFAIK I should not need to run the server, but what else is needed? I had an idea of generating the same html for my client as the website, but showing it withing Qt widgets rather than serving pages for a browser.
Has anyone tried this sort of thing before? I'm starting on this already, but it would be good to get a warning of potential dead-ends or things that will create a maintainance nightmare...
Read up on standalone Django scripts and you'll be on your path to victory. Basically all you're really doing is referencing the Django settings.py (which Django expects) and then using models without web views or urls.
If all you're really interested in is using Django's ORM to manage your models and database interaction, you might want to consider using SQLAlchemy instead.
You'll still have to run the Django app as a web server, but you can restrict it to serve to only localhost or something. And sure, you can use QtWebKit as the client.

Categories