Python Manage.Py - python

I am very New to Python web development ,so got confuse while learning ,when we create new Project with the command --django-admin startProject 'ProjectName'
It Created a project folder in my drive and then we create application in it suppose with the name of "calculator", we start working in it ,
but after some more requirement we have to create a new different Project with the Name of the Hrms so the question arise for this again we have to run the same command django-admin startProject 'ProjectName' and then we have to create application in it or we can create in it?

One project may have many application in it & you can create app using below code.
django-admin startapp my_new_app.
Also you can reuse same app in multiple projects.
For Hrm you should create new app instead of new project.
Example : One ERP projects may have many apps like hrm, sales, purchase, inventory etc.. & we can reuse same apps into another ERP projects also if needed.
Hope above clarifications works for you.

Project and apps and different see this
django-admin startproject mydjangoproject creates the project for you,
What you want to do is to create an app hrms and caculator can be apps living under umbrella of one project that is mydjangoproject
You should create apps here by django-admin startapp hrms and django-admin startapp calculator and add it to settings.py in your project folder
INSTALLED_APPS = [ #otherapps here
'hrms',
'calculator']

Start project and start app are very different commands. With the first one you create a project which will have a base structure to work on. The second command is used to create apps which you could classify as controllers. Each app will live in a folder where you will program the business logic and bind endpoints.

The app would be a new module in your project, let's say it would be a management system with human resources, financial modules, etc., so you would create an app for each of them to better organize, but nothing prevents creating everything in one app.Create a project only if it is something different.

Related

Django Populating New Project With Directories From Old

New to Django and I created a project with Django 3.0 based on a tutorial, then created Project 2 based on a second tutorial, following the steps.
But when I use the command django-admin startproject project2_project it populates project2's folder with all of the directories/files from project 1, and everything else on my Desktop.
When I run the server, I get Project 1's website. Have looked in the Django docs and on here but can't find any answers to this. Also, when I enter the virtual environment pipenv shell it says I am on my desktop: (Desktop) bash-3.2$ This might have something to do with it?

Virtualenv for Django dev, better to be at Project or App level?

With Django,
Is it better to have a virtualenv created at project level.
Or,
is it better to have a virtualenv per app within a single project?
All the apps installed (INSTALLED_APPS) within a single project run under the same python process, so it's going to be one virtualenv for all apps.
If you have an app that requires a specific python environment and the others really aren't able to run in that environment (for example, if one app requires python3 and another requires python2), then you would have to run the problem app in its own Django application server instance.
Since normally you would have nginx or Apache in front of your Django instance, you could have multiple Django instances appear to be one server. But it's a situation you'd want to avoid.

Apps location in Django using pinax

Maybe this is a silly question, but I'm new to all of this and I could use some help. I recently just started a new django project using pinax. Specifically, it's the pinax accounts project for user sign-ins. When I look at my project folder, it doesn't include any apps. I've noticed that all of my apps are stored in virtualenv/Lib/site-packages...
Why is it that the apps for my project are stored here? Does it make more sense to move them into my actual project folder instead of working out of the virtual machine folder? So I guess my question is: when working in a virtual machine, are all apps, etc stored in the virtual machine folder as apposed to the project folder? And why?

Modules not found in django

I want to make an application in django with two apps named apps and data.the "data" apps is placed within "apps".I had entered 'apps.data' in the Installed apps in "settings.py".when I run the devserver i got this error "no modules named apps.data".Any one please help me.
what is the reason for nesting "data" app in "apps"? it is uncommon to nest one app inside of another when there are only two apps (unless you have some great reason to). suggestions:
create an apps app, and create a data model for it;
create an apps app, and a data app; (link them however through the models)
the answer to your problem is probably file structure, but your basic requirements for what you're asking is detailed in your app requirements.
Long story short.. what application are you trying to create?

Why does django-startproject (by lincoln loop) create app in conf/local?

I have tested django-startproject (https://github.com/lincolnloop/django-startproject). I have read their doc and Lincoln Loop best practice, but many of their choices are still unclear for me (the way they organize their folders, etc.).
Especially, I am quite confused by the way their bin/manage.py behave.
When I execute python bin/manage.py startapp Test, it creates the app, but instead of putting it in my project (or in apps), the directory is created in conf/local.
Is this the wanted behaviour ?
That's because django's manage.py is by default located at the root of the project, and by default the startapp function(which is not created by the lincolnloop guys) places the apps in the current folder (where manage.py is located). this is from the official docs:
startapp [destination]
django-admin.py startapp
Creates a Django app directory structure for the given app name in the current directory or the given destination.
you can explicitly specify where to place the app with the destination parameter.

Categories