MicroService related issue

144 views
Skip to first unread message

shiva singh

unread,
Oct 11, 2024, 5:01:48 AMOct 11
to django...@googlegroups.com
Hello
  I am currently working on a microservices project using Django and have encountered an issue.  
 i am facing issue when create microservice project using django i am created 2 difrent django project in one common folder and one project name is authentication and second project name is repairmodule and when i access authentication project's model class in repairmodule models class and when i run makemigrations i am getting this error:
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\BSInfosys\RepairAnything\repairmodule\repair\models.py", line 2, in <module>
    from authentication.authenticate.models import User, RepairManProfile
ModuleNotFoundError: No module named 'authentication'
this is my directory Structure:
RepairAnything/
├── authentication/
│   ├── manage.py
│   ├── authentication/
│   │   ├── __init__.py
│   │   ├── asgi.py
│   │   ├── settings.py
│   │   ├── urls.py
│   │   ├── wsgi.py
│   │   └── __pycache__/
│   └── authenticate/
│       ├── __init__.py
│       ├── admin.py
│       ├── apps.py
│       ├── migrations/
│       │   └── __init__.py
│       ├── models.py
│       ├── serializers.py
│       ├── tests.py
│       ├── urls.py
│       └── views.py
├── env/                   # Your virtual environment
├── repairmodule/
│   ├── manage.py
│   ├── repair/
│   │   ├── __init__.py
│   │   └── models.py
│   └── repairmodule/
│       ├── __init__.py
│       ├── asgi.py
│       ├── settings.py
│       ├── urls.py
│       ├── wsgi.py
│       └── __pycache__/
├── db.sqlite3            # Database file
├── .env                  # Environment variables file
├── .gitignore            # Git ignore file
└── README.md             # Project README file

I would appreciate your guidance on how to resolve this issue. If you need any additional information, please let me know.

Thank you for your time and assistance!

Best regards,

Sreedhar p

unread,
Oct 11, 2024, 5:15:06 AMOct 11
to django...@googlegroups.com

1.I think its not using good authenticate, because authenticate is like function which provides authentication to the user by taking username and password and authenticate  is an part of authentication frsmework try to change that names
2.mention custom apps in settings.py file in installed apps
3.try like
from authenticate.models import #modelnames


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEsRHMWn1PSmBcD%3Db6jLqYwnCD-FsVtgvKXuAe8kybRo%2BmEQDg%40mail.gmail.com.

Sreedhar p

unread,
Oct 11, 2024, 5:16:03 AMOct 11
to django...@googlegroups.com

Ensure models order it was crucial for one by one creation

Abdul Qoyyuum Haji Abdul Kadir

unread,
Oct 12, 2024, 9:02:50 AM (13 days ago) Oct 12
to django...@googlegroups.com
Since you made 2 django projects, you should keep them separate as 2 django projects. Don't merge them into one folder. The right way to do this is to package your authentication app and import that into the other project. See this document on making your authentication app as a reusable app:  Advanced tutorial: How to write reusable apps | Django documentation | Django (djangoproject.com)

Once it's installed as a django app into the RepairAnything project, you can then use authentication API into your repairmodule app. And that's how microservices are usually designed. 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEsRHMWn1PSmBcD%3Db6jLqYwnCD-FsVtgvKXuAe8kybRo%2BmEQDg%40mail.gmail.com.


--
Abdul Qoyyuum Bin Haji Abdul Kadir
Nickname: Q

Konstantinos Dimitropoulos

unread,
Oct 13, 2024, 8:19:05 PM (12 days ago) Oct 13
to django...@googlegroups.com
Hello, why don't you create a project with two apps? Authenticate and repaire

--

Sunday Ajayi

unread,
Oct 14, 2024, 2:35:27 AM (12 days ago) Oct 14
to django...@googlegroups.com
Hi 

You can email me so we can schedule a call to review it.

Regards



Francis

unread,
Oct 20, 2024, 3:14:56 PM (5 days ago) Oct 20
to django...@googlegroups.com

you cannot import models from another django project.


shiva singh

unread,
Oct 23, 2024, 2:22:42 AM (3 days ago) Oct 23
to django...@googlegroups.com
Hello thank you for reply when we connect on vc can you give any time 
thanks again for your reply

shiva singh

unread,
Oct 23, 2024, 2:25:50 AM (3 days ago) Oct 23
to django...@googlegroups.com
hello thank you for your reply.
i am new to use microservice with django can you give any project demo link or project demo for reference witch is atleast use 3 small project in with microservice
thank you again for your reply

shiva singh

unread,
Oct 23, 2024, 2:26:12 AM (3 days ago) Oct 23
to django...@googlegroups.com

Hello Sreedhar,

Thank you for your reply and feedback regarding the naming conventions in my Django project.

To clarify, authentication is the name of my Django project, and authenticate is the name of the app within that project. I chose these names to reflect their respective purposes. Are you suggesting that I should change both the project and app names to avoid confusion with the authentication functions in the framework?

I appreciate your suggestions about mentioning custom apps in the settings.py file and adjusting the import statements. I will certainly ensure that the apps are correctly listed in INSTALLED_APPS and will consider your advice on import practices.

Thank you again for your insights!

Best regards,

Abdul Qoyyuum Haji Abdul Kadir

unread,
Oct 23, 2024, 3:03:38 AM (3 days ago) Oct 23
to django...@googlegroups.com
Hi Shiva,


The simpler version is to have one core Django project that doesn't have anything. Then create a 2nd Django project with an app (e.g. a Polls app). When the Polls app is done, package it in such a way that it can be installed in another Django project (resource reference here:Advanced tutorial: How to write reusable apps | Django documentation | Django)

Repeat for X number of services/apps that you want to build, package them, then install them into the core Django project.

The more complicated version is to have each service run their own technology stack (doesn't have to be Django). But the end goal is that each service must be able to communicate with each other through a means of API calls, webhook events or even through PubSub.

Reply all
Reply to author
Forward
0 new messages