Skip to content

Forum in maintenance, we will back soon 🙂

Considering Options...
 
Notifications
Clear all

Considering Options for Django API Project

7 Posts
4 Users
0 Reactions
416 Views
(@sidh)
Posts: 7
Active Member
Topic starter
 

Hi Hasan,

I wanted to let you know that I successfully created a background image removal API in Django, following your tutorial on YouTube: https://www.youtube.com/watch?v=HNu6FgWGcYM&t=430s

However, I've encountered a challenge. The Django project size exceeds 25MB, making it difficult to upload to GitHub. I'm currently exploring two options to address this issue:

  1. Converting Django API to Flask: I'm considering converting the Django API to a Flask API, which might reduce the project size and make it easier to manage and upload.

  2. Exploring Django API Hosting: Alternatively, I'm looking into Django API hosting services. Do you have any recommendations for reliable hosting platforms?

Additionally, I recently purchased Hostinger's premium web hosting plan. I'm wondering if Hostinger supports hosting API projects. If you have any insights on this, I would greatly appreciate your advice.

Thank you.

 
Posted : 10/29/2023 9:09 am
Topic Tags
Hasan Aboul Hasan
(@admin)
Posts: 1276
Member Admin
 

Hi friend, why 25 MB. if you have some files or models. exclude them. then push to github. but anyway, you need a hosting service.

I didn't test Hostinger before. but there are many affordable services where you can get started, like Digital Ocean, Contabo, Kinsta...

 

 
Posted : 10/29/2023 12:56 pm
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@sidh Django is an all in one package with little need for add on modules. Flask on the other hand provides a minimal framework and provides add on modules to provide you functional needs. Below is what ChatGPT 4 gives me for converting from Django to Flask:

 

Converting a Django project to Flask involves several steps since they are two different frameworks with different structures and designs. Here are some general steps you can follow:

1. **Setup Flask Application**: Create a new Flask application. You can do this by installing Flask using pip:

```
pip install flask
```

Then, create a new file (for example, `app.py`) and set up a basic Flask application:

```python
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
return 'Hello, World!'

if __name__ == '__main__':
app.run()
```

2. **Migrate Models**: Django uses an ORM (Object-Relational Mapping) for database operations, while Flask uses SQLAlchemy. You will need to convert Django models to SQLAlchemy models.

3. **Migrate Views**: In Django, views are functions that take a web request and return a web response. In Flask, views are functions that are mapped to one or more route URLs.

4. **Migrate Templates**: Django uses its own template engine, while Flask uses Jinja2. You will need to convert Django templates to Jinja2 templates.

5. **Migrate Forms**: If your Django application uses Django forms, you'll need to replace them with WTForms (or another Flask-compatible form library).

6. **Migrate URL Routing**: Django uses a central `urls.py` file for URL routing, while Flask handles URL routing in the view by using decorators.

7. **Migrate Middleware**: If you're using Django middleware, you'll need to find a Flask equivalent or rewrite the middleware as a Flask extension.

8. **Migrate Static Files**: Flask and Django handle static files differently. You'll need to move your static files to the appropriate place in your Flask project and update your templates accordingly.

9. **Migrate Tests**: If you have tests written for your Django app, you'll need to rewrite them for your Flask app using a library like `unittest` or `pytest`.

Remember that Django and Flask have different philosophies and are designed for different kinds of projects. Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design, while Flask is a micro web framework for Python based on Werkzeug, Jinja 2 and good intentions. It might not always be feasible or advisable to port an application from one to the other without considering the implications and the benefits.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 10/30/2023 3:58 pm
(@sidh)
Posts: 7
Active Member
Topic starter
 

@ssadvisor Thankyou😊

 
Posted : 11/02/2023 7:46 pm
(@sidh)
Posts: 7
Active Member
Topic starter
 

@admin The model has 168MB which is responsible for the image background removal. i cannot exclude the model from uploading it to the git

 
Posted : 11/02/2023 7:49 pm
(@Anonymous 4525)
Posts: 1
New Member Guest
 

Hey!

 
Posted : 11/02/2023 7:57 pm
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@alexda21 did you want something or are you just spamming this post?

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 11/02/2023 8:02 pm
Share:
[the_ad_group id="312"]