def lecture(request):
template = "main/lecture.html"
return TemplateResponse(request, template, {'getLectures':PostLecture.objects.all()})
<div class="div_table">
<table>
<tbody>
{% for getLecture in getLectures%}
<tr>
<td>1</td>
<td>
<a href="#"> {{ getLecture.title }} </a>
</td>
<td><a href="{% url 'main:problemlist' %}">Задачи по лекции</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="div_table">
<table>
<tbody>
<tr>
<td>1</td>
<td>
<a href="">Понятие асимптотической сложности</a>
</td>
<td><a href="{% url 'main:problemlist' %}">Задачи по лекции</a></td>
</tr>
</tbody>
</table>
</div>
from django.db import models
class Car(models.Model):
name = models.CharField(max_length=255)
price = models.DecimalField(max_digits=5, decimal_places=2)
photo = models.ImageField(upload_to='cars')
Any Car instance will have a photo attribute that you can use to get at the details of the attached photo:
>>> car = Car.objects.get(name="57 Chevy")
>>> car.photo
<ImageFieldFile: chevy.jpg>
>>> car.photo.name
'cars/chevy.jpg'
>>> car.photo.path
'/media/cars/chevy.jpg'
>>> car.photo.url
'http://media.example.com/cars/chevy.jpg'
from django.contrib import admin
from main.models import *
from django.db.models import TextField
from file_picker.wymeditor.widgets import WYMeditorWidget
@admin.register(MainUser)
class MainUserAdmin(admin.ModelAdmin):
list_display = ('username', 'first_name', 'second_name')
class BlogAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug':('title', )}
list_display = ('title', 'time')
formfield_overrides = {TextField: { 'widget': WYMeditorWidget({}) } }
class Media:
js = ('http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js', )
admin.site.register(Blog, BlogAdmin)
class PostLectureAdmin(admin.ModelAdmin):
list_display = ('title')
admin.site.register(PostLecture, PostLectureAdmin)