How to create a business side inventory manager - python

I am creating my first website for a friend using python, flask, and mysql. The goal of the website is to display and sell shoes (like a much simpler/smaller eastbay or nike).
I am at the point where I have created a database of inventory and have added some of the items myself via INSERT commands in the mysql command line. I am new to web development and am wondering what the best way to handle inventory changes would be. For example, my friend would be managing the site's inventory. However, he is not a computer science guy so using mysql is out of the question. I considered creating a tab on the site that only he (admin?) can access. This tab would contain a form that he could easily fill out and when submitted, would add the new item's info to the database.
Is there an easier/better way to do this? I am not familiar with the standard approach for web inventory management. I am also wondering if there is an easy way for him to delete/edit existing inventory items without him having to learn mysql.
Again, I am new so please excuse the lack of knowledge. Any direction would be appreciated, thanks

Basically, you're going to need to create an admin interface that runs those INSERT, UPDATE, and DELETE queries. With Flask, a lot of people will reach for sqlalchemy to handle the data access layer.
If you're not completely sold on Flask, one of Django's major selling points is that you get a basic admin interface for your models, for 'free'. Django is more of an opinionated framework, which may be better if you're just starting out and want to get up and running quickly. Flask is more open-ended, but will also require more from you, both in time and knowledge. I'd highly recommend looking at the Django tutorial, because even if you don't stick with Django it'll give you a good idea of Model-View-Controller (MVC) pattern―which is one of the most common design patterns in web development. Just my 2¢.

Related

How to properly migrate a monolith architecture app to a microservice app in Django

Today I come with this question probably to someone who has large experience in this.
Basically what the title indicates. We have that app and we have to migrate it to microservices.
We didn't find any solid approach (or we felt it like that) about this. What we ended up doing is creating 1 project per microservice (a single functionality related to a module app, in general) but then we had some problems because we already had a database to work with since this is already a functioning app.
We had problems communicating with the existing models, so basically what we did was to point in every settings.py of the projects to the existing DB, and with python3 manage.py inspectdb, we grabbed the existing models. This approach ended up working, but we feel that is not the best approach. We had a lot of problems with circular imports and more.
Is out there good practices about microservices with Django, and how to properly do it, like in most of the cases that we want to create something with the framework?
If someone knows or has something we would really appreciate it!
you can use Django for Microservices. in this case you have only one few apps, and you start every service on own port:
first Django project
pdf generator + views generate small pdf
second Django project.
pdf generator + views generate big pdf (code can inherit other project)
orchestra:
third Django project: Autorization + call big or small pdf generator service
settings
settings.py for first and second is very easy and allows only call from internal ip's. here we don't need middleaware, template, cache, admin and other settings.
settings.py for orchestra is also very easy and used only auth and made call by internal ip ant send response to user. Here we don't need much middlaware, and don't need many other settings.
gains:
All is independent. if one server fall, other can work.
Updates are easy. One small server update is always easy than monolith update.
development is easy: three small teams works on own small projects.
Units testing is easy and fast
For complex business goals the whole system is faster.
pains:
after 100 micro-services it is completely complex to work with that all.
code style from many teams is always different. Don't matter how strict you define styleguide or settings for black-linter.
integrate Testing is difficult - If something not work, it is hard to find where.
Ecosystem Auth/services/messaging is really complex
For easy business goals the whole system is overcomplicated.
summary
Don't matter how much DB you want to use. it can be monolith or many services.
i don't see any problem to import in one Microservice something from other project: it can be model / admin or other staff. it works. probably you need to smart split monolith, but it also easy, for that we have a many experience (my own and in internet or books)

Is there a way to automatically generate a whole system for different users [duplicate]

I have developed Multi-tenant SAAS apps in PHP/Laravel but recently I had a challenge to develop one in Django/Python. I am still learning Django though and I really like Django rest framework (DRF). But I have difficulties to figure out the highlighted areas below, If someone shows some light, I will be good to go:
How to handle subdomains/domains and selecting the right tenant db
How to manage and dynamically handle different database in django
Can multi-tenant apps backend still be managed from Django admin interface
I will be using queues and other apps scalling techniques, need tips and tricks if any
Any example out there
Any challenge experience when developing SAAS through Django
Well...
django-subdomains
There are people who asked in SO questions about dynamic databases in django (including, ahem... me). I'm not entirely sure I understood what you mean by "dynamically handle different database" so I guess just go to the links I just mentioned and pick out the best one for your project. (also - perhaps this is more relevant?)
Check out django-multitenant-schemas and this answer too.
There was a video of the guys behind Disqus (one of the largest django app in the world) explaining how they handle scaling. Here another interesting article on the subject. Also, the legendary SO question Does Django Scale.
(and 6.) Check out this answer
I hope that's detailed enough. I know this might be a disappointing only-links answer, but this is the reality of it - Django is a newer framework, and web development with python is still less common than php. With that in mind, understand that for all the awesomness of django (and it is awesome), with more complex needs there's more you'll have to do yourself.
In this case, you'll have to figure out how to do each part of the way seperatly and then combine it all. You can easily find a way to create a REST django app for example, but then you'll need to figure out how to combine it with another package (such as the above subdomains).
You can find a million examples out there of people doing freaky things with django. It's really powerful (when I learned about dynamic models I was blown away). But the more complex your app, the more you'll need to do yourself.
Pick it up, one step at a time, and come back to SO with specific issues you're having (or the django users google group). Good luck!

Python Advice for Project: Taking input and writing to existing PDF?? WebApp?

I am somewhat of a beginner at Python and I am currently starting some brainstorming and planning for a project to simplify the tedious task of filling out a product order form for a friend's business. I am wanting to create a program with an interface that takes in input and writes to an already existing pdf form of the physical order form. I would also like to implement being able to then email that form to another coworker and having accessible information of previous orders from the current customer ordering.
I am most curious about how to write to an already existing pdf form and just fill in the blanks, potentially using a PDF Reader? Also, for product catalog data and customer order history, would using dictionaries suffice or would it be better to use some python database?
I know I could figure out how to individually do each of those tasks but I don't know how to tie it all together properly to distribute it, either making a WebApp or an executable file from the script and just use tkinter or another GUI library for the interface, or if there is a more obvious and convenient option?
If I were to do a WebApp, what would be my best option, I've seen options such as Anvil, Flask, Django, and I just don't know what would be best for what I'm trying to accomplish.
I know this is a longshot and vague but any advice or guidance in the right direction would be much appreciated!
I'd go with a web app here. Personally, I prefer Django, and I don't think that it would be too difficult to learn it well enough for your purposes!
Regarding saving product catalog data and customer order history: I would definitely recommend using a database for your backend, which Django helps you do! Database integration is almost ridiculously easy using Django.
Here's some resources for the specific things you asked about:
Django vs. Flask
Working with HTML forms (Django) (this will help with taking user input)
filling an existing PDF form in Python (this will help with using user input to fill out the pdfs)
How to send email attachments in Python? (this will help you email your coworker the filled out pdf)
If you need more help/guidance, definitely feel free to follow up!

Recreating Google Sheets functionality

I just need pointers on where to begin. I have some experience with Python, but nothing to brag about.
My end goal is to create a website that will allow multiple users to access it from different computers to fill the table with simple data, very simillar to what Google Sheets alows, and then printing it on a single sheet of paper. Idealy I want my programm to intelegently determine the width of rows and columns so that the table would look decently and would fill the page accordingly.
Right now all I need is some pointers on where to begin. Like can I use SQL to create these tables and have online fuctionality for users to access and fill the spreadsheet, and how to go about printing it.
I know this is very noob question, but I can't seem to find anything relevant here on by just using google.
Thank you.
I don't think this is a very good StackOverflow question because it is very broad and not programming specific. You are asking how to start a new software project which in my opinion belongs more in the software engineering meta: https://softwareengineering.stackexchange.com/
Anyhow, how I would take on such a project:
First I would define my project scope. What is the functionality of the end-product? What must it be able to do and what not? Who are the end-users using the product and what do they expect? These are so called functional requirements.
In which way does the product deliver value? Is it fast, modifiable, distributed... These are so called non-functional requirements.
Develop a basic software architecture based on the previous requirements using patterns and tactics and identify the different subsystems. On the top of my hat I would divide it in a frontend component using a web application, backend component in your favourite language and a database component for persistence.
Research possible languages frameworks for each component, decide and start coding!
For the 4th step I suggest you have a look at Python Django which includes all of this stuff out-of-the-box.

How to generate basic CRUD functionality in python given a database tables

I want to develop a desktop application using python with basic crud operation. Is there any library in python that can generate a code for CRUD functionality and user interface given a database table.
Hopefully, this won't be the best option you end up with, but, in the tradition of using web-interfaces for desktop applications, you could always try django. I would particularLY take a look at the inspectdb command, which will generate the ORM code for you.
The advantage is that it won't require that much code to get off the ground, and if you just want to use it from the desktop, you don't need a webserver; you can use the provided test server. The bundled admin site is easy to get off the ground, and flexible up to a point; past which people seem to invest a lot of time battling it (probably a testimony to how helpful it is at first).
There are many disadvantages, not the least of which is the possibility of having to use html/javascript/css when you want to start customizing a lot.
If it were me, I would consider borrowing django's ORM, but then again, I'm already familiar with it.
Having said that, I like working with it, it's usable outside the framework, and it will give you mysql, postgres, or sqlite support. You could also hook up the django admin site to your models and have a web-based editor.
There are surely other ORMs and code generators out there too (I hope some python gurus will point some out, I'm kind of curious).
If you want something really small and simple, I like the Autumn ORM.
If you use the Django ORM, you can use the automatically-generated Django admin interface, which is really nice. It's basically a web-based GUI for browsing and editing records in your database.
If you think you will need advanced SQL features, SQLAlchemy is a good way to go. I suspect for a desktop application, Django or Autumn would be better.
There are other Python ORMs, such as Storm. Do a Google search on "python ORM". See also the discussion on this web site: What are some good Python ORM solutions?

Categories

Resources