django-templates

Django CMS and Rosetta: Can't get template messages translated

萝らか妹 提交于 2019-12-13 16:52:32
问题 Is there any know issue about using Django CMS and Django Rosetta together. I cant get the "static" template messages translated although it appears correctly translated in the Rosetta interface. All the dynamic content is correctly translated. Only the one I´ve set up around the `{% trans 'blabla' %} does not work. 回答1: Gotcha! Just add in settings.py LOCALE_PATHS = (BASE_DIR + "/locale/",) It worked for me. 来源: https://stackoverflow.com/questions/24439031/django-cms-and-rosetta-cant-get

Django pass variable into template

萝らか妹 提交于 2019-12-13 16:40:33
问题 Hi thank you for helping, I'm poor in coding. To point: I'm doing a Django project that pass data form data-base to front-end; but right now i can't even pass anything views of Django into templates, I suspect i'm passing the wrong variable types; please do comment on your thought. This is my code on views.py: from django.shortcuts import render def index (requset): return render(requset,'myapp/index.html') # link to be able open frountend def testdex(requset): text = "hello world" context ={

Django templates: How to access a form field equal to a variable value?

余生长醉 提交于 2019-12-13 14:31:37
问题 Imagine a following use case: I have a dictionary of report templates. Each report template has an ID and a name. It looks more or less like this: reports = [ { 'ID' : 'A1', 'NAME' : 'special report 1 for department A', ... (other fields irrelevant to the question's matter) }, { 'ID' : 'X9', 'NAME' : 'special report 9 for department X', ... (other fields irrelevant to the question's matter) }, ] Access to and visibility of the reports are to be stored in a database. I created a form with

Page not found (404)

不想你离开。 提交于 2019-12-13 12:28:20
问题 Error: Request Method: GET Request URL: http://192.168.100.10/accounts/profile/ Using the URLconf defined in urls, Django tried these URL patterns, in this order: ^collect/ ^member/ ^accounts/login/$ ^ ^$ ^ ^contact/$ ^ ^privacy-statement/$ ^logout/$ [name='logout'] ^data-admin/doc/ ^accounts/password/reset/$ ^accounts/password/reset/done/$ ^accounts/password/reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$ ^accounts/password/done/$ ^media/(?P<path>.*)$ The current URL, accounts/profile/, didn

Jquery code for Django REST framework pagination

时光总嘲笑我的痴心妄想 提交于 2019-12-13 08:47:02
问题 I have this json with pagination from Django REST framework but I don't know how to use it. {"count": 18, "next": "http://127.0.0.1:8000/ajax/list/?page=6&format=json", "previous": "http://127.0.0.1:8000/ajax/list/?page=4&format=json", "results": [{"subject": "fd", "date": "2014-06-20", "time_start": "3:36 AM"}, {"subject": "fdf", "date": "2014-06-14", "time_start": "3:38 AM"}]} http url http://127.0.0.1:8000/ajax/list/?page=5&format=json django urls.py url(r'^ajax/list/$', AuthorListAll1.as

Django formset only adding one form

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 08:15:35
问题 OK, so this is my first time using formsets. I am trying to create a table that I can dynamically add rows to and fill out each row, then submit and have Django put them all in the database. Every time I submit it only adds the first form. File views.py: @main_context_wrapper def bacteriaForm2(request,context): if not request.user.is_authenticated(): #If user isn't authenticated, then just redirect to login return HttpResponseRedirect('/login/') BacteriaFormSet = formset_factory(BacteriaForm)

Select users from list and add to post request

浪尽此生 提交于 2019-12-13 08:08:47
问题 I have a list of users that all have a checkbox next to them. All the users that are selected should be added to the array and then sent to the database via the Django post request. Here is a picture of that: The Button at the bottom is the submit button. models: class UserProfile(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) color = models.CharField(max_length=25, default="", blank=True) class Studyplan(models.Model): name = models.CharField(max_length=100, null

How to post a array to views.py

雨燕双飞 提交于 2019-12-13 07:56:37
问题 I am using for loop in my template and for different id of each record i am using arrays {% for item in product %} <div class="register_div"> <p><label for="id[{{ item.id }}]">{{ item.Name }} </label> <input type="text" name="custom[{{item.id}}]"/></p> </div> {% endfor %} Now when in my views i want to save this data to my database.But firstly i checked that whether my array return something or not.So i just try print that as. q = upload_form.data['custom[]'] or q = upload_form.data['custom']

MEDIA_ROOT Django do not find images

守給你的承諾、 提交于 2019-12-13 07:12:26
问题 I want to display *.png images on my template but can`t ! All other page's stuff renders well (bootstrap on http path, css from local files). I waste few hours trying to set path but no effect. Seems I tried all I could invent. Please help. please see project tree settings.py ... import os '''path settings for django==1.8''' # BASE_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) TEMPLATE_DIRS = ( #'/Users

How to handle nested template variables?

杀马特。学长 韩版系。学妹 提交于 2019-12-13 06:55:33
问题 I currently have an embedded <iframe> that has a hard wired static url: <iframe src="{% static 'docs/ver600/technical-reference-guide/_build/html/index.html' %}" frameborder="0" class="full-screen"></iframe> I would like replace parts of the static string with variables. For example, the "technical-reference-guide" is just a document name variable. Obviously, just embedding a template variable doesn't work: <iframe src="{% static 'docs/ver600/{{ doc_name }}/_build/html/index.html' %}"