File tree 1 file changed +50
-0
lines changed
1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Django Requirements
2
+
3
+ When generating api-documentation for django projects it will likely complain that django is not configured during the generation process.
4
+
5
+
6
+ ## Create a file called ` pymdgen_init.py `
7
+
8
+ This should be created in the same place as all the other source code files.
9
+
10
+ ``` py
11
+ import logging
12
+
13
+ logger = logging.getLogger(" django" )
14
+
15
+ try :
16
+
17
+ # This is to be included in doc *.md files that
18
+ # render api documentation for django models
19
+ # requiring django environment to be setup (app configure etc.)
20
+ #
21
+ # There appears to be no good check on whether this has happened
22
+ # yet or not, in the case of setup being called again an
23
+ # exception will be raised that we catch and ignore
24
+
25
+ import django
26
+
27
+ django.setup()
28
+
29
+ except Exception as exc:
30
+
31
+ logger.error(f " exception during django-setup for pymdgen: { exc} " )
32
+
33
+
34
+ ```
35
+
36
+ ## Attach it to pymdgen doc files that generate django code
37
+
38
+ Any md file that calls ` pydmgen ` on django code needs to also call ` pymdgen ` on this new module.
39
+
40
+ So for example
41
+
42
+ ```
43
+ {pymdgen:my_django_app.module}
44
+ ```
45
+
46
+ becomes
47
+
48
+ ```
49
+ {pymdgen:my_django_app.pymdgen_init}{pymdgen:my_django_app.module}
50
+ ```
You can’t perform that action at this time.
0 commit comments