programming:django
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| programming:django [2019/03/22 15:17] – clemix | programming:django [2019/04/24 16:22] (current) – [Static files] clemix | ||
|---|---|---|---|
| Line 133: | Line 133: | ||
| </ | </ | ||
| - | ==== Mixed in for django_tables2 ==== | + | Run this command to store static files in proper folder: |
| + | <code bash> | ||
| + | python manage.py collectstatic | ||
| + | </ | ||
| + | ==== django_tables2 ==== | ||
| + | === Mixedin | ||
| <code python> | <code python> | ||
| Line 153: | Line 158: | ||
| </ | </ | ||
| - | To make links of a value https:// | + | === Custom tables.Column === |
| + | <code python> | ||
| + | class AgeColumn(tables.Column): | ||
| + | def render(self, | ||
| + | diff = record.age() | ||
| + | color = '' | ||
| + | if (diff.seconds > 60 * 60 ): | ||
| + | color = ' | ||
| + | else: | ||
| + | color = ' | ||
| + | return format_html('< | ||
| + | |||
| + | class InstanceTable(tables.Table): | ||
| + | age = AgeColumn() | ||
| + | opt = tables.LinkColumn(' | ||
| + | class Meta: | ||
| + | model = Instance | ||
| + | template_name = ' | ||
| + | </ | ||
| + | |||
| + | To make links of a value https:// | ||
| ==== Update database ==== | ==== Update database ==== | ||
| Change the model file accordingly. [[https:// | Change the model file accordingly. [[https:// | ||
| Line 161: | Line 186: | ||
| python manage.py migrate | python manage.py migrate | ||
| </ | </ | ||
| + | |||
| + | ==== Bootstrap ==== | ||
| + | https:// | ||
programming/django.1553264229.txt.gz · Last modified: by clemix
