What version of django are you using ?

On 14 Apr 2017 1:53 am, "Rohit Chopra" <rohitchopr...@gmail.com> wrote:

> stackoverflow question
> <http://stackoverflow.com/questions/43401681/how-to-style-a-django-formset-for-filefield>
>
>
>
>
> down votefavorite
> <http://stackoverflow.com/questions/43401681/how-to-style-a-django-formset-for-filefield#>
>
> I have this formset.
>
> instance = get_object_or_404(Post, user = request.user, slug = slug )
> files = file.objects.all().filter(Post=instance)FormSet = 
> modelformset_factory(file, fields=('file',), can_delete=True)
> formset=FormSet(request.POST or None, request.FILES or None, queryset=files)
>
> models.py:
>
> class file(models.Model):
>     file = models.FileField(upload_to = upload_location, blank = True, null = 
> True)
>     Post = models.ForeignKey(Post, blank = True, null = True)
>     timestamp = models.DateTimeField(auto_now=False, auto_now_add=True, blank 
> = True, null = True)
>
>     def filename(self):
>         f = self.file.name
>         f1 = f.split('/', 3)[-1]
>         return f1
>
>     def __unicode__(self):
>         return self.file.name
>
>     def __str__(self):
>         return self.file.name
>
> thats how i used it in my template:
>
>  {{ formset.management_form }}
>  {% for form in formset %}
>  {{form.file}}
>  {{form.DELETE.label}}
>  {{form.DELETE}}
>  {% endfor %}
>
> and it shows like this in my browser:
>
> [image: look] <https://i.stack.imgur.com/BWIMk.png>
>
> i tried every this but i could not able to to get rid of currently and i
> literally do not know how to style this. please help me guys.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/372952eb-6a2c-4422-9706-00a1a6dbc444%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/372952eb-6a2c-4422-9706-00a1a6dbc444%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEuG%2BTYvq_uBBqJY5iL69jnyMZbPTRRKsiDE%2BiLaFg_MmzLoww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to