django-class-based-views

ManyToManyField in Class Based Generic Views and Save Override

我只是一个虾纸丫 提交于 2021-02-11 07:51:55
问题 We have a class-based-generic view that adds an object with a ManyToManyField relationship. We're trying to modify some values on save() override for the relationships created on that ManyToManyField, but it doesn't seem like they ever get created in save(), so we're forced to call a post_save method in get_success_url so the relationships are created. This seems very, very ugly. How do we force the relationships to be created before we leave save()? I've seen this answer on SO, which says to

Django: Display File Name for Uploaded File

爷,独闯天下 提交于 2021-02-10 14:26:49
问题 In my model, I have a defined a FileField which my template displays it as a link. My problem is that the linked file displays the url as the name. What shows on html page is: Uploaded File: ./picture.jpg I've looked on the DjangoDocs regarding file names and a previous S.O. question, but just can't figure it out. How can I: Have it display a different name, not a url. Allow the admin who uploaded the file to give it a name, which would then be viewed on the template. my models.py: class

Create View reverse to DetailView

﹥>﹥吖頭↗ 提交于 2021-02-07 13:30:48
问题 I am trying to reverse from CreateView to DetailView after I have uploaded my Image. I get the same message NoReverseMatch at /photo/image/add Reverse for 'image-view' with arguments '()' and keyword arguments '{'pk': 50}' not found. 0 pattern(s) tried: [] This is my Model for Image from django.db import models from django.contrib.auth.models import User from django.contrib import admin from django.conf import settings from string import join import os class Image(models.Model): title =

Create View reverse to DetailView

江枫思渺然 提交于 2021-02-07 13:30:25
问题 I am trying to reverse from CreateView to DetailView after I have uploaded my Image. I get the same message NoReverseMatch at /photo/image/add Reverse for 'image-view' with arguments '()' and keyword arguments '{'pk': 50}' not found. 0 pattern(s) tried: [] This is my Model for Image from django.db import models from django.contrib.auth.models import User from django.contrib import admin from django.conf import settings from string import join import os class Image(models.Model): title =

Create View reverse to DetailView

半城伤御伤魂 提交于 2021-02-07 13:30:19
问题 I am trying to reverse from CreateView to DetailView after I have uploaded my Image. I get the same message NoReverseMatch at /photo/image/add Reverse for 'image-view' with arguments '()' and keyword arguments '{'pk': 50}' not found. 0 pattern(s) tried: [] This is my Model for Image from django.db import models from django.contrib.auth.models import User from django.contrib import admin from django.conf import settings from string import join import os class Image(models.Model): title =

create custom methods in django class base views

大憨熊 提交于 2021-02-05 05:15:26
问题 I want to use generic class base views using django 1.9 What i am trying to understand that from django.views.generic import CreateView from braces.views import LoginRequiredMixin from .models import Invoice class InvoiceCreateView(LoginRequiredMixin,CreateView): model = Invoice def generate_invoice(self): ... return invoice now i want to bind this custom method to url. How can i achive this? I know using function base view its simple but i want to do this using class base views. Help will be

create custom methods in django class base views

痞子三分冷 提交于 2021-02-05 05:11:12
问题 I want to use generic class base views using django 1.9 What i am trying to understand that from django.views.generic import CreateView from braces.views import LoginRequiredMixin from .models import Invoice class InvoiceCreateView(LoginRequiredMixin,CreateView): model = Invoice def generate_invoice(self): ... return invoice now i want to bind this custom method to url. How can i achive this? I know using function base view its simple but i want to do this using class base views. Help will be

Django CreateUpdateView implementation in the django template

只愿长相守 提交于 2021-01-29 17:59:51
问题 I am very new to django Class based views, trying to integrate it with my existing project. My goal is to use same Class based view to Create and Update student application form. I am trying to integrate CreateUpdateView from the @scubabuddha's answer from the solution. views.py from createupdateview import CreateUpdateView class StudentView(CreateUpdateView): template_name="admission.html" Model = Student form_class = StudentForm def get(self, request, *args, **kwargs): return self.post

Using formsets for my fileupload does not work when doing an update class based view only on create in django

倖福魔咒の 提交于 2021-01-06 03:51:51
问题 I have used as many examples online as I could cobble together in an attempt to get my two simple models to have the ability to do an inline formset allowing me to add many files to a technial drawing. This is not working, I can only add one file for the Create and the update only updates the Technical_Entry model, not a file...which in of itself acts funny. The UI ona create shows one spot to add a file, then save the entire record and its child record. That works. The update, the UI shows

Using formsets for my fileupload does not work when doing an update class based view only on create in django

若如初见. 提交于 2021-01-06 03:50:12
问题 I have used as many examples online as I could cobble together in an attempt to get my two simple models to have the ability to do an inline formset allowing me to add many files to a technial drawing. This is not working, I can only add one file for the Create and the update only updates the Technical_Entry model, not a file...which in of itself acts funny. The UI ona create shows one spot to add a file, then save the entire record and its child record. That works. The update, the UI shows