Tuesday, March 31, 2020

Re: Multiple Image Field in a model

This is how exactly you could solve it. Multiple FIle Upload

On Monday, September 26, 2011 at 7:32:51 PM UTC+5:30, NavaTux wrote:
Hi all,

       I have a filed(ImageField) in my model.Also I want to have
multiple ImageFields.How to have more than one ImageFields only in
django model.Is there any need to derive that ImageField as a seperate
new model which holds as a foreign key of another one?

This is my model:

class Report(models.Model):
    name = models.CharField(max_length=1024)
    data = models.TextField()
    image = models.ImageField(upload_to=settings.IMAGE_UPLOAD_PATH,
blank=True, null=True)

I need to display atleast 4 imagefields for this model object?

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/34bcc2f5-0a5e-4aff-85b2-78fb7cdc0c10%40googlegroups.com.

Re: CSS doesnt work deployed on Pythonanywhere

Thanks for the heads up. Will check and update the status if found.

Regards.

On Tue, Mar 31, 2020 at 2:24 PM Motaz Hejaze <trapperx.1@gmail.com> wrote:
I remember that in pythonanywhere you need to tell the platform where you app folder is and where your static folder is ... 

You can do that from your account control panel i think ..

On Tue, 31 Mar 2020, 11:07 pm Alexis Soko, <alexissoko@gmail.com> wrote:
Hi. thanks for the answer.

Yes I have an app/static/css folder with the app.css file  and {% load static %} at the beginning of the html.

On Tue, Mar 31, 2020 at 1:48 PM Aly_34_04 MR_34_04 <allaberdi16yazhanow@gmail.com> wrote:
did you load css on your static files?

On Tuesday, March 31, 2020 at 10:54:59 PM UTC+3, Alexis Soko wrote:
Really simple stuff. webpage navbar looks propper locally. But when deployed the navbar loses font and goes vertical. Checked Django and bootstrap installed versions on both,
Any thoughts? This is my first project on Django.

Thanks for your help.
Alexis.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/68b20efc-b30f-4964-ba56-ff0dd2e7a6b9%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPVXFAQY%2BOTVoG30xBXb%3Deqm_kGkD9W1i7S-HQ472DtSrCx3kw%40mail.gmail.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHV4E-fM6ZNnmhzHzC4eAJK9AaS2LKGgg%3DpxagUGDadn%3DLR9Og%40mail.gmail.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPVXFAQYFq0M69xjctDBA7bvWVoqB1%3DQYsui%2B8xvTSWDyfQkfw%40mail.gmail.com.

Re: CSS doesnt work deployed on Pythonanywhere

I remember that in pythonanywhere you need to tell the platform where you app folder is and where your static folder is ... 

You can do that from your account control panel i think ..

On Tue, 31 Mar 2020, 11:07 pm Alexis Soko, <alexissoko@gmail.com> wrote:
Hi. thanks for the answer.

Yes I have an app/static/css folder with the app.css file  and {% load static %} at the beginning of the html.

On Tue, Mar 31, 2020 at 1:48 PM Aly_34_04 MR_34_04 <allaberdi16yazhanow@gmail.com> wrote:
did you load css on your static files?

On Tuesday, March 31, 2020 at 10:54:59 PM UTC+3, Alexis Soko wrote:
Really simple stuff. webpage navbar looks propper locally. But when deployed the navbar loses font and goes vertical. Checked Django and bootstrap installed versions on both,
Any thoughts? This is my first project on Django.

Thanks for your help.
Alexis.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/68b20efc-b30f-4964-ba56-ff0dd2e7a6b9%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPVXFAQY%2BOTVoG30xBXb%3Deqm_kGkD9W1i7S-HQ472DtSrCx3kw%40mail.gmail.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHV4E-fM6ZNnmhzHzC4eAJK9AaS2LKGgg%3DpxagUGDadn%3DLR9Og%40mail.gmail.com.

Re: CSS doesnt work deployed on Pythonanywhere

Hi. thanks for the answer.

Yes I have an app/static/css folder with the app.css file  and {% load static %} at the beginning of the html.

On Tue, Mar 31, 2020 at 1:48 PM Aly_34_04 MR_34_04 <allaberdi16yazhanow@gmail.com> wrote:
did you load css on your static files?

On Tuesday, March 31, 2020 at 10:54:59 PM UTC+3, Alexis Soko wrote:
Really simple stuff. webpage navbar looks propper locally. But when deployed the navbar loses font and goes vertical. Checked Django and bootstrap installed versions on both,
Any thoughts? This is my first project on Django.

Thanks for your help.
Alexis.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/68b20efc-b30f-4964-ba56-ff0dd2e7a6b9%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPVXFAQY%2BOTVoG30xBXb%3Deqm_kGkD9W1i7S-HQ472DtSrCx3kw%40mail.gmail.com.

Re: CSS doesnt work deployed on Pythonanywhere

did you load css on your static files?

On Tuesday, March 31, 2020 at 10:54:59 PM UTC+3, Alexis Soko wrote:
Really simple stuff. webpage navbar looks propper locally. But when deployed the navbar loses font and goes vertical. Checked Django and bootstrap installed versions on both,
Any thoughts? This is my first project on Django.

Thanks for your help.
Alexis.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/68b20efc-b30f-4964-ba56-ff0dd2e7a6b9%40googlegroups.com.

Template Variables

I am writing a simple web app, and I am struggling to access my variable attributes in one of my templates. The get_object_or_404 method returns my customized 404 error from my content_detail.html file: "No content is available." 

Here are my files:

archive/archive/urls.py:

from django.contrib import admin
from django.urls import include, path
from django.views.generic import RedirectView
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    path('posts/', include('posts.urls')),
    path('admin/', admin.site.urls),
    path('', RedirectView.as_view(url='posts/', permanent=True)),] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

archive/posts/urls.py:

from django.urls import path

from . import views

app_name = 'posts'

urlpatterns = [
    path('', views.index, name='index'),
    path('<int:pk>/', views.ContentDetailView.as_view(), name='content-detail'),
]

archive/posts/models.py:

import datetime

from django.db import models
from django.utils import timezone
import uuid

class Content(models.Model):
    content_head = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

    class Meta:
        verbose_name_plural='contents'

    def __str__(self):
        return self.content_head

    def get_absolute_url(self):
        return reverse('detail', args=[str(self.id)])

class ContentInstance(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    content = models.ForeignKey(Content, on_delete=models.SET_NULL, null=True)
    content_body = models.TextField()

    def __str__(self):
        return f'{self.id}, {self.content.pub_date}'

archive/posts/views.py:

from django.shortcuts import render, get_object_or_404

from .models import Content, ContentInstance
from django.views import generic

def index(request):
    archive_list = Content.objects.order_by('-pub_date')[:5]
    context = {'archive_list': archive_list}
    return render(request, 'posts/index.html', context)

class ContentDetailView(generic.DetailView):
    model = Content

def content_detail_view(request, primary_key):    
    content = get_object_or_404(Content, pk=primary_key)
    return render(request, 'posts/detail.html', context={'content':content})

archive/posts/templates/posts/index.html:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Title</title>
</head>
<body>
  <h1>Heading</h1>
     {% if archive_list %}
     <ul>
      {% for content in archive_list %}
        <li><a href="/posts/{{ content.id }}/">{{ content.content_head }}</a>({{ content.pub_date }})</li>
      {% endfor %}
      </ul>
      {% else %}
      <p>No content is available.</p>
      {% endif %}
</body>
</html>

archive/posts/templates/posts/content_detail.html:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Title</title>
</head>
<body>
  <h1>Heading</h1>
     <ul>
     {% if content %}
       {% for contentinstance in content.contentinstance_set.all %}
        <li>{{ content.pub_date }}</li>
       <li>{{content.content_body}}</li>
       {% endfor %}
     {% else %}
     <li>No content is available</li> 
     {% endif %}
     </ul>
</body>
</html>

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b86505fd-b149-48fd-a01f-b3938cb2b880%40googlegroups.com.

Re: Django authentication micro service Rest API utilization

Read about jwt token refresh and interceptors in spa

On Tue, 31 Mar 2020, 11:00 pm crack studio, <sajjadkhanafridi58@gmail.com> wrote:
Hello Everyone,

I want to implement and integrate different, separately Django service. 
Suppose I have these two different projects.

1. Authentication rest API ( user can register, login, email verification, create JWT token on login, refresh token, etc)
2. Frontend Project: This is the project with one application:
  • userapp: This app is responsible for providing HTML templates e.g registers a new user, login user, etc using authentication rest API. Currently, i have a local database to store and verify the token. Suppose, when a user logged in. The authentication API will provide me a jwt token and this token will be stored in my local database. For the first time when a user logged in, I have the user id, so I can use this id to check the user token (expiry date). But the problem is that how i keep the user identity until the user signout? What strategy and what functionality of Django should be used to keep track of the current user information because of on this identity I can check the token lifetime? 
I need help and suggestion!

Thanks

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c37cbb43-5871-436e-86c7-d4d2ad887f4b%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPjsHcF8X4OPdVjFewfT125Yd2D78avi481PwiGxkSF0z27nFA%40mail.gmail.com.