django-forms

Django - ModelForm: Add a field not belonging to the model

久未见 提交于 2021-02-07 14:29:19
问题 Note: Using django-crispy-forms library for my form. If you have a solution to my problem that involves not using the cripsy_forms library, I accept it all the same. Not trying to be picky just need a solution / work around. Thanks In my form's Meta class I set the model, Driftwood , and it's fields I want to in the form, but I also want to add another field. One that does not belong the the referenced model. This field I want to add is an image. The reason for this field is to build another

Django admin site: how to create a single page for global settings?

﹥>﹥吖頭↗ 提交于 2021-02-07 13:52:21
问题 I would like to create a single page in the admin site of django where I can change some global variables of the website (title of the website, items in the navigation menu, etc). At the moment I have them coded as context processors but I would like to make them editable. Something similar to what happens in WordPress. Is this possible? I can store the data in the databse, but can I have a link in the admin site that goes straight to the first document record and doesnt allow the creation of

Django admin site: how to create a single page for global settings?

Deadly 提交于 2021-02-07 13:51:41
问题 I would like to create a single page in the admin site of django where I can change some global variables of the website (title of the website, items in the navigation menu, etc). At the moment I have them coded as context processors but I would like to make them editable. Something similar to what happens in WordPress. Is this possible? I can store the data in the databse, but can I have a link in the admin site that goes straight to the first document record and doesnt allow the creation of

InlineFormSet with queryset of different model

旧巷老猫 提交于 2021-02-07 10:24:27
问题 What we're trying to do is populate a list of inline forms with initial values using some queryset of a different model. We have products, metrics (some category or type or rating), and a rating, which stores the actual rating and ties metrics to products. class Product(models.Model): name = models.CharField(max_length=100) price = models.IntegerField(max_length=6) class Metric(models.Model): name = models.CharField(max_length=80) description = models.TextField() class Rating(models.Model)

InlineFormSet with queryset of different model

给你一囗甜甜゛ 提交于 2021-02-07 10:22:32
问题 What we're trying to do is populate a list of inline forms with initial values using some queryset of a different model. We have products, metrics (some category or type or rating), and a rating, which stores the actual rating and ties metrics to products. class Product(models.Model): name = models.CharField(max_length=100) price = models.IntegerField(max_length=6) class Metric(models.Model): name = models.CharField(max_length=80) description = models.TextField() class Rating(models.Model)

InlineFormSet with queryset of different model

依然范特西╮ 提交于 2021-02-07 10:22:30
问题 What we're trying to do is populate a list of inline forms with initial values using some queryset of a different model. We have products, metrics (some category or type or rating), and a rating, which stores the actual rating and ties metrics to products. class Product(models.Model): name = models.CharField(max_length=100) price = models.IntegerField(max_length=6) class Metric(models.Model): name = models.CharField(max_length=80) description = models.TextField() class Rating(models.Model)

InlineFormSet with queryset of different model

旧城冷巷雨未停 提交于 2021-02-07 10:21:04
问题 What we're trying to do is populate a list of inline forms with initial values using some queryset of a different model. We have products, metrics (some category or type or rating), and a rating, which stores the actual rating and ties metrics to products. class Product(models.Model): name = models.CharField(max_length=100) price = models.IntegerField(max_length=6) class Metric(models.Model): name = models.CharField(max_length=80) description = models.TextField() class Rating(models.Model)

How do I add custom CSS to crispy forms?

我怕爱的太早我们不能终老 提交于 2021-02-07 09:08:32
问题 I'm trying to create a responsive form for my website with the help of crispy forms.I'm not using bootstrap and I want to add custom CSS to the crispy form to match my whole website. HTML: <form method='POST' action=''>{% csrf_token %} {{ form|crispy }} <input type='submit' value='Sign Up' /> </form> using inspect element it shows: <form method='POST' action=''><input type='hidden' name='csrfmiddlewaretoken' value='GLJMxnnDz1MGNFC46pjoofSlo6JMCD1IXu7X3n7LsRbQfdS38SYHJMs9IAXddcck' /> <div id=

Django how to enter multiple records on one form

冷暖自知 提交于 2021-02-07 08:00:27
问题 I am writing a calendar app with the following models: class CalendarHour(models.Model): ''' Each day there are many events, e.g. at 10 am, the framer orders material, etc. ''' day_id = models.ForeignKey(CalendarDay) time = models.TimeField() work = models.TextField() def __unicode__(self): return 'work that took place at {work_time}'.format(work_time = self.time) class CalendarDay(models.Model): ''' Each project has so many daily logs. But, each daily log belongs to only one project

Django how to enter multiple records on one form

心已入冬 提交于 2021-02-07 07:58:22
问题 I am writing a calendar app with the following models: class CalendarHour(models.Model): ''' Each day there are many events, e.g. at 10 am, the framer orders material, etc. ''' day_id = models.ForeignKey(CalendarDay) time = models.TimeField() work = models.TextField() def __unicode__(self): return 'work that took place at {work_time}'.format(work_time = self.time) class CalendarDay(models.Model): ''' Each project has so many daily logs. But, each daily log belongs to only one project