# how to avoid circular imports in helpers.py

**URL:** <https://forum.djangoproject.com/t/how-to-avoid-circular-imports-in-helpers-py/29786>\
**Category:** Mystery Errors\
**Created:** [April 3, 2024, 4:05pm UTC](https://forum.djangoproject.com/t/how-to-avoid-circular-imports-in-helpers-py/29786 "2024-04-03T16:05:25Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 3, 2024, 8:51pm UTC](https://forum.djangoproject.com/t/how-to-avoid-circular-imports-in-helpers-py/29786/3 "2024-04-03T20:51:08Z")

</div>

Ok, so there are a couple points here worth making.

First:

> [@nickabbey](#):
>
> I’ve been counciled that it’s not such a big deal to use the string represenation in the model relationship definitions

Not only is it “not a big deal”, but it’s [documented as existing for this specific reason](https://docs.djangoproject.com/en/5.0/ref/models/fields/#django.db.models.ForeignKey). That hardly makes it a “hacky workaround”.

The other, more opinionated topic is the very existance of this “helpers.py” file. Even though you have chosen a different name, you’re effectively talking about something usually referred to as a “services” layer.

It’s interesting to me that we’ve had at least three separate discussion threads on this basic topic in the past week or so.

I suggest you see the threads (and the links contained within them) at:

- [Django Design Pattern for Large complex web app](https://forum.djangoproject.com/t/django-design-pattern-for-large-complex-web-app/29680)
- [How to improve the structure of my django project?](https://forum.djangoproject.com/t/how-to-improve-the-structure-of-my-django-project/5927)

(among others)

Reader’s Digest version: If I were coding this, there wouldn’t be a “helper” file. As far as I’m concerned, the logic belongs elsewhere - either the views.py or the models.py as appropriate.

---

_[View the full topic](https://forum.djangoproject.com/t/how-to-avoid-circular-imports-in-helpers-py/29786)._
