django-templates

Django Photologue Upload Photo Example

泄露秘密 提交于 2019-12-11 04:38:52
问题 I've installed Django-Photologue and I can upload files and create galleries in my Django admin site. I've been searching the documentation below for examples on how to create a photo upload form so my users can create a gallery on my site but can't find a simple example to get me started. I've also setup their example application but it wasn't very helpful in terms of how to upload and create Galleries by POSTing from Views/Templates. Docs: https://django-photologue.readthedocs.org/en/2.7/

Getting model filters to show count of active values

梦想与她 提交于 2019-12-11 04:35:08
问题 I have 2 models that are connected. Model 1 is userprofiles and model 2 is events each user can have multiple events... each event can be active or deactivated. I have a for loop in the template showing all the userprofiles... but I also want to show how many active events each user has. today = datetime.now().strftime('%Y-%m-%d') perm = Permission.objects.get(codename='chef_user') user_profiles = User.objects.filter(profile__user_profile_active='y').filter(is_active=True).filter(Q(groups_

Django : Create custom object list in the view and pass it to template to loop over

北城以北 提交于 2019-12-11 04:24:51
问题 I want to create a custom object list in the view and pass it to the template. In the template I want to loop over the list and display the information. My models are class CustomUser(AbstractUser): def __str__(self): return self.email class Post(models.Model): author = models.ForeignKey(CustomUser,on_delete=models.CASCADE,) text = models.TextField() created_date = models.DateTimeField(default=timezone.now) published_date = models.DateTimeField(blank=True, null=True) post_url = models

How to use django template syntax in static files

放肆的年华 提交于 2019-12-11 04:14:35
问题 There is a lot of documentation available in including static files in Django templates. However, I cannot find anything on how to use Django template syntax in static files. I had an html file that included javascript between tags like this: var nodes = JSON.parse('{{nodes|safe}}'); I now moved all the javascript to a static .js file which I'm serving. It is included in the HTML file like this: <script src="{% static 'citator/analysis.js' %}" type="text/javascript"></script> Everything runs

building django template files with xslt

时间秒杀一切 提交于 2019-12-11 04:12:01
问题 I have about 4,000 html documents that i am trying to convert into django templates using xslt. The problem that I am having is that xslt is escaping the '{' curly braces for template variables, when I try to include a template variable inside of an attribute tag; my xslt file looks like this: <xsl:template match="p"> <p> <xsl:attribute name="nid"><xsl:value-of select="$node_id"/></xsl:attribute> <xsl:apply-templates select="*|node()"/> </p> <span> {% get_comment_count for thing '<xsl:value

How to render formset in template django and create vertical table?

爱⌒轻易说出口 提交于 2019-12-11 03:58:10
问题 How to create this table used formset and extra=3? Table: | my name first column | second column | third column | fourth column | | formset1.field1.label | formset1.field1 | formset2.field1 | formset3.field1 | | formset1.field2.label | formset1.field2 | formset2.field2 | formset3.field2 | | formset1.field3.label | formset1.field3 | formset2.field3 | formset3.field3 | | formset1.field4.label | formset1.field4 | formset2.field4 | formset3.field4 | In view I create standard formset: def my_view

showing the model values of specific user django

瘦欲@ 提交于 2019-12-11 03:43:24
问题 I want to show the data of a user which he has entered. This is my model class IgaiaContent(models.Model): CONTENT_CHANNELS = ( ('YouTube','Youtube'), ('FaceBook','FaceBook'), ('Flickr','Flickr'), ('Instagram','Instagram'), ) content_name = models.CharField(max_length=255, primary_key=True) content_type = models.CharField(max_length=255,null=True) content_source = models.CharField(max_length=255,null=True, choices=CONTENT_CHANNELS) content_location = models.CharField(max_length=255,null=True)

I am using django tables 2 and trying to export my table following the official documentation

余生颓废 提交于 2019-12-11 03:37:30
问题 I have followed the official documentation of django tables 2 but it is not working I dont know why views.py from django.shortcuts import render from django_tables2 import RequestConfig from django.template.response import TemplateResponse from .models import Customer from .tables import CustomerTable from .tables import TableView from django_tables2.export.export import TableExport def user_profile(request): table= CustomerTable(Customer.objects.all()) RequestConfig(request,paginate={'per

Django template filter queryset

点点圈 提交于 2019-12-11 02:55:41
问题 I'm new in django. I has a django application where stores products categorized by 'X' and 'Y'. views.py ... class CartListView(ListView): template_name = 'checkout/list.html' context_object_name = 'product_list' def get_queryset(self): return Product.objects.filter(category__slug='X') | Product.objects.filter(category__slug='Y') def get_context_data(self, **kwargs): context = super(CartListView, self).get_context_data(**kwargs) context['minicurso'] = get_object_or_404(Category, slug='X')

Django REST Browsable API Template Change

倖福魔咒の 提交于 2019-12-11 02:48:57
问题 I want to customize the Django REST Framework Browsable API template (simply to change the branding to a different name and link). I have read the documentation on how to achieve this and did the following initially in the following path: hints(project)->hints1(app)->templates->rest_framework->api.html api.html: {% extends "rest_framework/base.html" %} {% block title %} Handy Dev Hints - API {% endblock %} {% block branding %} <span> <a class='navbar-brand' rel="nofollow" href="{% url 'html'