Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {% extends "base.html" %}
- (% load widget_tweaks %}
- {% block content %}
- <form method="post" enctype="multipart/form-data">
- <h4 style="margin-top: 0">Project Upload</h4>
- {% csrf_token %}
- {% for hidden in form.hidden_fields %}
- {{hidden}}
- {% endfor %}
- {% for field in form.visible_fields %}
- <div class="form-group">
- <label for="{{field.id_for_label}}">{{field.label}}</label>
- {{field}}
- </div>
- {% endfor %}
- <button type="submit">Upload</button>
- </form>
- {% endblock %}
- class html(models.Model):
- project = models.CharField(max_length=50, blank=True)
- version = models.IntegerField(default=0)
- ecms=models.ManyToManyField(ecm, blank=True)
- diff = models.TextField(blank=True)
- PROGRAM_CHOICES = (
- ('Office', 'General office'),
- ('Residential', 'Residential'),
- ('Retail', 'Retail'),
- ('Restaurant', 'Restaurant'),
- ('Grocery', 'Grocery store'),
- ('Medilcal', 'Medilcal office'),
- ('Research', 'R&D or laboratory'),
- ('Hotel', 'Hotel'),
- ('Daycare', 'Daycare'),
- ('K-12', 'Educational,K-12'),
- ('Postsecondary', 'Educational,postsecondary'),
- ('Airport', 'Airport'),
- ('DataCenter','Data Center'),
- ('DistributionCenter','Distribution center,warehouse')
- )
- program = models.CharField(max_length=20, choices=PROGRAM_CHOICES, default='Retail')
- LOCATION_CHOICES = (
- ('Beijing', 'Beijing'),
- ('China', 'China'),
- ('Hong Kong', 'Hong Kong'),
- ('Japan', 'Japan'),
- ('Shanghai', 'Shanghai'),
- ('Shenzhen', 'Shenzhen'),
- ('Taiwan', 'Taiwan'),
- ('USA', 'United States')
- )
- location = models.CharField(max_length=15, choices=LOCATION_CHOICES, default="Hong Kong")
- CERTIFICATE_CHOICES = (
- ('LEED_v3', 'LEED_v3'),
- ('LEED_v4', 'LEED_v4'),
- ('BEAM+', 'BEAM+'),
- ('WELL', 'WELL'),
- ('No certificate','No certificate')
- )
- certificate = models.CharField(max_length=20, choices=CERTIFICATE_CHOICES, default='BEAM+')
- user = models.CharField(max_length=20, default='test')
- html = models.FileField(upload_to=dir_path)
- uploaded_at = models.DateTimeField(auto_now_add=True)
- class ecm(models.Model):
- name = models.CharField(max_length=50, blank=True)
- TARGET_CHOICES = (
- ('Heating', 'Heating'),
- ('Cooling', 'Cooling'),
- ('Fan', 'Fan'),
- ('Lighting', 'Lighting'),
- ('Equipment', 'Equipment'),
- ('Renewable','Renewable Energy'),
- ('Hot Water','Hot Water System'),
- ('Others', 'Others'),
- )
- target=models.CharField(max_length=20, choices=TARGET_CHOICES, default='Others')
- description = models.TextField(blank=True)
- link=models.URLField(blank=True)
- def __str__(self):
- return self.name
- def model_form_upload(request):
- if request.method == 'POST':
- if form.is_valid():
- newhtml = form.save()
- newhtml.save()
- else:
- form = DocumentForm()
- return render(request, 'model_form_upload.html', {'form': form})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement