Basic concept
You render the meta tags by including a meta.html parial template in your view templates. This template will only render meta tags if it can find a meta object in the context, so you can safely include it in your base template to have it render on all your pages.
The meta.html template expects to find a dict or object called meta in the template context. In that dict or object, it will expect to find any of the following keys/attributes:
sudo yum install python34-devel
which python3
строка авторизации, футер, боковой сладер
# echo "127.0.0.1 shop_slug.localhost" >> /etc/hosts
server {
listen 27796;
server_name myurl.com;
root /home/ucwsri/webapps/static_media_ucwsri_nginx;
location / {
autoindex on;
}
location ^~ /protected/ {
internal;
}
response = HttpResponse()
url = "/protected/some-file.pdf"
response['X-Accel-Redirect'] = url
return response
cd projects/site
virtualenv virtalenv --no-site-packages
. virtualenv/bin/activate
pip install -r requirements.txt
pip freeze
pip freeze > requirements.txt
как-то так лучше "разворачивать" def add_slide(request):
slide_form = SlideForm()
image_slide_form = ImageSlideForm()
return render(request, "add_slide.html",
{'slide_form': slide_form,
'image_slide_form': image_slide_form})
<form>
{% csrf_token %}
{{ slide_form.as_p }}
{{ image_slide_form.as_p }}
<button type="submit">submit</button>
</form>
db_table =
- ето для натягивания джанго на уже существующую бд, структуру которой нельзя менятьclass Article(models.Model):
title = models.CharField(max_length=200)
text = models.TextField()
created = models.DateTimeField()
likes = models.IntegerField(default=0)
category = models.ForeignKey(Category)
def __str__(self): return self.title
class ArticleAdmin(admin.ModelAdmin):
fields = ['category', 'title', 'text', 'created']
likes = models.PositiveIntegerField(default=0, editable=False)
Один вариант вижу кастомизировать менеджер модели и сравнивать текущий дейтайм с указанным.нормальное решение.
class MyModel(Model):
# .....
objects = Manager()
ready_for_pub = CustomManager()