Django project using django-machina as lib
- add your tags in the templates :
{% translate %}
or{% blocktranslate %}
- create a message file :
django-admin makemessages -l fr
wherefr
is the locale name for the message file you want to create, - update message files in
./DJANGO_WITH_MACHINA/{PROJECT_NAME}/locale/{LOCALE}/LC_MESSAGES/*.po
- compile your message files :
django-admin compilemessages
- copy
.envrc.template
into your own.envrc
, then customize it
- check your
pyproject.toml
- exec
make init
- migrate and populate your db
make migrate; make populate_db
make console
from machina.apps.forum_member.models import ForumProfile
…
- your independant apps : stored in
./DJANGO_WITH_MACHINA/main/apps/{APP_NAME}/migrations
- your overridden machina apps : stored with poetry in
/home/{$USER}/.cache/pypoetry/virtualenvs/django-with-machina-{$ID}-py3.10/lib/{PYTHON_VERSION}/site-packages/machina/apps/{APP_NAME}/migrations/
call "abstracted model", then override it
from machina.apps.forum_conversation.abstract_models import AbstractPost
class Post(AbstractPost):
field = models.…
use the method get_model
to get the right version of the model, first the overriden one, then the default machina one.
from machina.core.db.models import get_model
Post = get_model("forum_conversation", "Post")
from machina.core.loading import get_class
forum_view = get_class("forum.views", "ForumView")
urlpatterns = [
path(
"<str:slug>-<int:pk>/",
forum_view.as_view(),
name="group",
),]
from machina.core.loading import get_class
ForumAdmin = get_class("forum.admin", "ForumAdmin")
ForumAdmin.fieldsets += (("Privacy", {"fields": ("kind", "moderators_group", "contributors_group")}),)