Sorting price and discount price (urgent)

2021-06-30 Thread Aritra Ray
I am facing a problem in including the discount_price into consideration
when sorting price through the products. Kindly help me to do so. The below
attached files are filters.py, views.py and  models.py.

Regards,
Aritra

class ProductFilter(django_filters.FilterSet):
sort = OrderingFilter(
choices=(
('price', 'Lowest to Highest'),
('-price', 'Highest to Lowest'),
),
fields={
'price': 'price',
'price':'discount_price'
},
)
price = RangeFilter()
class Meta:
model = Items
fields = ['size', 'category']

class Product(ListView):
model = Items
paginate_by = 6
template_name = 'products.html'
ordering = ["-id"]

def get_queryset(self):
queryset = super().get_queryset()
filter = ProductFilter(self.request.GET, queryset)
return filter.qs

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
queryset = self.get_queryset()
filter = ProductFilter(self.request.GET, queryset)
context["filter"] = filter
return context
class Items(BaseModel):
title = models.CharField(max_length=100, null=True, blank=True)
price = models.FloatField(null=True, blank=True)
discount_price = models.FloatField(max_length=100, blank=True, null=True
)
description = models.TextField(max_length=500)
size = models.CharField(choices=SIZES, default=SIZES[0][0], max_length=
10)
category = models.CharField(choices=CATEGORY, default=CATEGORY[0][0
], max_length=1)
featured = models.BooleanField(default=False)
availability = models.CharField(choices=AVAILABILITY, default=
AVAILABILITY[0][0], max_length=1)
image = ResizedImageField(upload_to="", null=True, blank=True)
slug = models.SlugField(max_length=100)
date_added = models.DateField(default=timezone.now)

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


Re: In django you can either obtain a `csrftoken` from a cookie or the form can generate a nonce `csrftoken`. How does django validate both?

2021-06-30 Thread Antonis Christofides
What if I can copy that cookie (samesite)  in developer tools from 
legitimate-site.com  and create a new cookie for 
malicious-site.com  using developer tools. After I 
do that I make a request. Will it be successful?
I think it would probably work. (This is not a security issue, though, since the 
user agrees. The problem is when malicious-site.com tries to do something to 
legitimate-site.com using the user's credentials without the user knowing.)


Antonis Christofides
+30-6979924665 (mobile)



On 01/07/2021 01.48, Patrice Chaula wrote:
What if I can copy that cookie (samesite)  in developer tools from 
legitimate-site.com  and create a new cookie for 
malicious-site.com  using developer tools. After I 
do that I make a request. Will it be successful?


On Wed, Jun 30, 2021, 3:43 PM Antonis Christofides 
mailto:anto...@antonischristofides.com>> wrote:


Django does not store csrftoken on the server.

Django provides the csrftoken in two places: 1) The cookie; 2) A hidden
form field.

When the browser makes a POST request, then:

 1. It sends back the cookie anyway (that's what cookies do)
 2. It submits the csrftoken as a form field (or as the X-CSRFToken HTTP
header in case of AJAX).

All Django does after that is verify that the token it receives with (2)
is the same as the token it receives with (1).

Why this helps? Because the attack it is designed to mitigate is one where
you visit malicious-site.com  which contains
the following:

https://legitimate-site.com";
>
    
    
    


For this attack to succeed, malicious-site.com 
would need to specify a csrftoken as, say, a hidden form field (which is
possible) AND provide the same token through a cookie. This is not
possible. malicious-site.com  can't set cookies
of another site. The post request may indeed send a csrftoken as a cookie
to legitimate-site.com , but this will be the
csrftoken received the previous time the user visited legitimate-site.com
. It will not be the same as the csrftoken
sent as a hidden field, because malicious-site.com
 can't read cookies of another site, so it
can't possibly read that cookie and set the hidden field to its value.

Antonis Christofides
+30-6979924665 (mobile)




On 30/06/2021 15.14, Patrice Chaula wrote:

In django you can either obtain a `csrftoken` from a cookie. Or the form
can generate a nonce `csrftoken`. How does django validate both and where
are they stored on the server. Are they stored as part of the session?
-- 
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+unsubscr...@googlegroups.com
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/83f3da74-ecbc-4197-9627-0c9ab9e8492fn%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+unsubscr...@googlegroups.com
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/7732c858-fd8c-53de-9a0f-99ae704ae4c6%40antonischristofides.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+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAE%3DG6DY1gG71vdqEUiax%3DQqfuqukC%3Dyi-qo9zKnwyra4i3ujDw%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+unsubscr...@googlegroups.com.
To view this discussion on the web

Re: MODEL CONSTRAINT (based on two dates)

2021-06-30 Thread Simon Charette
Short answer is that you can't; constraints cannot spans across JOINs.

You might be able to use database triggers to emulate though.

Le lundi 28 juin 2021 à 08:08:27 UTC-4, ngal...@gmail.com a écrit :

> I have two models like this
>
> How can I make models constraint based on the dates as shows on image??
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/87cda97d-9fd8-4264-bb37-8d466eec0cb4n%40googlegroups.com.


Re: In django you can either obtain a `csrftoken` from a cookie or the form can generate a nonce `csrftoken`. How does django validate both?

2021-06-30 Thread Patrice Chaula
What if I can copy that cookie (samesite)  in developer tools from
legitimate-site.com and create a new cookie for malicious-site.com using
developer tools. After I do that I make a request. Will it be successful?

On Wed, Jun 30, 2021, 3:43 PM Antonis Christofides <
anto...@antonischristofides.com> wrote:

> Django does not store csrftoken on the server.
>
> Django provides the csrftoken in two places: 1) The cookie; 2) A hidden
> form field.
>
> When the browser makes a POST request, then:
>
>1. It sends back the cookie anyway (that's what cookies do)
>2. It submits the csrftoken as a form field (or as the X-CSRFToken
>HTTP header in case of AJAX).
>
> All Django does after that is verify that the token it receives with (2)
> is the same as the token it receives with (1).
>
> Why this helps? Because the attack it is designed to mitigate is one where
> you visit malicious-site.com which contains the following:
>
> https://legitimate-site.com";
> >
> 
> 
> 
> 
>
> For this attack to succeed, malicious-site.com would need to specify a
> csrftoken as, say, a hidden form field (which is possible) AND provide the
> same token through a cookie. This is not possible. malicious-site.com
> can't set cookies of another site. The post request may indeed send a
> csrftoken as a cookie to legitimate-site.com, but this will be the
> csrftoken received the previous time the user visited legitimate-site.com.
> It will not be the same as the csrftoken sent as a hidden field, because
> malicious-site.com can't read cookies of another site, so it can't
> possibly read that cookie and set the hidden field to its value.
>
> Antonis Christofides
> +30-6979924665 (mobile)
>
>
>
>
> On 30/06/2021 15.14, Patrice Chaula wrote:
>
> In django you can either obtain a `csrftoken` from a cookie. Or the form
> can generate a nonce `csrftoken`. How does django validate both and where
> are they stored on the server. Are they stored as part of the session?
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/83f3da74-ecbc-4197-9627-0c9ab9e8492fn%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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7732c858-fd8c-53de-9a0f-99ae704ae4c6%40antonischristofides.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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAE%3DG6DY1gG71vdqEUiax%3DQqfuqukC%3Dyi-qo9zKnwyra4i3ujDw%40mail.gmail.com.


return json value as char/text instead of json

2021-06-30 Thread Campbell McKilligan
I'm using Concat of some annotated json fields (from 
.values("data__somefield", "data__someotherfield")

The values are being returned as json, so the concatenation ends up with a 
hot mess of double quotes:
"somevalue" "someothervalue"
 
I can see in the query that Django is using the "->" operator to retrieve 
the value from the json which explains the double quotes.

Is there a way to encourage Django to retrieve as text (ie with the "->>" 
operator) - to prevent the double quotations?

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54dd60b9-0c19-469d-b3da-50ffdf2ed427n%40googlegroups.com.


Re: when i am writing {%load static%} rather than getting exectuted it is getting displayed as simple text on htmloutput screen

2021-06-30 Thread Saad Olamilekan
load your static by putting space in between the percent and load and after
static before  percent eg. {% load static %}.

On Wed, Jun 30, 2021, 2:56 PM pritam bhutada  try --->  {% load staticfiles %}
>
> On Wednesday, June 30, 2021 at 9:47:46 AM UTC+5:30 ujjwal...@gmail.com
> wrote:
>
>> Dear all I am facing one problem.
>> When I am writing {%load static%} rather than getting executed it is
>> getting displayed as simple text on the HTML output screen
>>
>> Please provide me the solution.
>>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8ba41bbd-6a9e-4d79-936e-e9ff7ce53dafn%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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP%2BiQEaMoeOxuQdxwg-9y%3D4heq8XCBgdvv1AOM%3DYu7K8bzb8_w%40mail.gmail.com.


Re: when i am writing {%load static%} rather than getting exectuted it is getting displayed as simple text on htmloutput screen

2021-06-30 Thread pritam bhutada
try --->  {% load staticfiles %}

On Wednesday, June 30, 2021 at 9:47:46 AM UTC+5:30 ujjwal...@gmail.com 
wrote:

> Dear all I am facing one problem.
> When I am writing {%load static%} rather than getting executed it is 
> getting displayed as simple text on the HTML output screen
>
> Please provide me the solution.
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8ba41bbd-6a9e-4d79-936e-e9ff7ce53dafn%40googlegroups.com.


Re: In django you can either obtain a `csrftoken` from a cookie or the form can generate a nonce `csrftoken`. How does django validate both?

2021-06-30 Thread Antonis Christofides

Django does not store csrftoken on the server.

Django provides the csrftoken in two places: 1) The cookie; 2) A hidden form 
field.

When the browser makes a POST request, then:

1. It sends back the cookie anyway (that's what cookies do)
2. It submits the csrftoken as a form field (or as the X-CSRFToken HTTP header
   in case of AJAX).

All Django does after that is verify that the token it receives with (2) is the 
same as the token it receives with (1).


Why this helps? Because the attack it is designed to mitigate is one where you 
visit malicious-site.com which contains the following:


https://legitimate-site.com";>
    
    
    



For this attack to succeed, malicious-site.com would need to specify a csrftoken 
as, say, a hidden form field (which is possible) AND provide the same token 
through a cookie. This is not possible. malicious-site.com can't set cookies of 
another site. The post request may indeed send a csrftoken as a cookie to 
legitimate-site.com, but this will be the csrftoken received the previous time 
the user visited legitimate-site.com. It will not be the same as the csrftoken 
sent as a hidden field, because malicious-site.com can't read cookies of another 
site, so it can't possibly read that cookie and set the hidden field to its value.


Antonis Christofides
+30-6979924665 (mobile)




On 30/06/2021 15.14, Patrice Chaula wrote:
In django you can either obtain a `csrftoken` from a cookie. Or the form can 
generate a nonce `csrftoken`. How does django validate both and where are they 
stored on the server. Are they stored as part of the session?

--
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+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/83f3da74-ecbc-4197-9627-0c9ab9e8492fn%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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7732c858-fd8c-53de-9a0f-99ae704ae4c6%40antonischristofides.com.


In django you can either obtain a `csrftoken` from a cookie or the form can generate a nonce `csrftoken`. How does django validate both?

2021-06-30 Thread Patrice Chaula
In django you can either obtain a `csrftoken` from a cookie. Or the form 
can generate a nonce `csrftoken`. How does django validate both and where 
are they stored on the server. Are they stored as part of the session?

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/83f3da74-ecbc-4197-9627-0c9ab9e8492fn%40googlegroups.com.


Re: ImproperlyConfigured:

2021-06-30 Thread Abdoulaye Koumaré
You need to install psycopg2 to use PostgreSQL run the command below from 
your terminal

pip install psycopg2

On Tuesday, 29 June 2021 at 12:35:23 UTC ypa...@sapat.com wrote:

> Watching for file changes with StatReloader
> Exception in thread django-main-thread:
> Traceback (most recent call last):
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/db/backends/postgresql/base.py",
>  
> line 25, in 
> import psycopg2 as Database
> ModuleNotFoundError: No module named 'psycopg2'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner
> self.run()
>   File "/usr/lib64/python3.6/threading.py", line 864, in run
> self._target(*self._args, **self._kwargs)
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 64, in wrapper
> fn(*args, **kwargs)
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>  
> line 110, in inner_run
> autoreload.raise_last_exception()
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 87, in raise_last_exception
> raise _exception[1]
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/core/management/__init__.py",
>  
> line 375, in execute
> autoreload.check_errors(django.setup)()
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 64, in wrapper
> fn(*args, **kwargs)
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/__init__.py",
>  
> line 24, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/apps/registry.py",
>  
> line 114, in populate
> app_config.import_models()
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/apps/config.py",
>  
> line 301, in import_models
> self.models_module = import_module(models_module_name)
>   File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in 
> import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 994, in _gcd_import
>   File "", line 971, in _find_and_load
>   File "", line 955, in 
> _find_and_load_unlocked
>   File "", line 665, in _load_unlocked
>   File "", line 678, in exec_module
>   File "", line 219, in 
> _call_with_frames_removed
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/contrib/auth/models.py",
>  
> line 3, in 
> from django.contrib.auth.base_user import AbstractBaseUser, 
> BaseUserManager
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/contrib/auth/base_user.py",
>  
> line 48, in 
> class AbstractBaseUser(models.Model):
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/db/models/base.py",
>  
> line 122, in __new__
> new_class.add_to_class('_meta', Options(meta, app_label))
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/db/models/base.py",
>  
> line 326, in add_to_class
> value.contribute_to_class(cls, name)
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/db/models/options.py",
>  
> line 207, in contribute_to_class
> self.db_table = truncate_name(self.db_table, 
> connection.ops.max_name_length())
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/utils/connection.py",
>  
> line 15, in __getattr__
> return getattr(self._connections[self._alias], item)
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/utils/connection.py",
>  
> line 62, in __getitem__
> conn = self.create_connection(alias)
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/db/utils.py",
>  
> line 204, in create_connection
> backend = load_backend(db['ENGINE'])
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/db/utils.py",
>  
> line 111, in load_backend
> return import_module('%s.base' % backend_name)
>   File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in 
> import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File 
> "/home/yogesh/mydjango/djangoenv/lib/python3.6/site-packages/django/db/backends/postgresql/base.py",
>  
> line 29, in 
> raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
> django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 
> module: No module named 'psycopg2'
>
>

-- 
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+unsubscr...@googlegroups.

Re: when i am writing {%load static%} rather than getting exectuted it is getting displayed as simple text on htmloutput screen

2021-06-30 Thread shaik sufiyan
Please import os in the settings.py file

On Wed, 30 Jun, 2021, 1:02 pm UJJWAL AGRAWAL, 
wrote:

> Dear patel dhruvish
>
> """
> Django settings for mypro project.
>
> Generated by 'django-admin startproject' using Django 3.2.4.
>
> For more information on this file, see
> https://docs.djangoproject.com/en/3.2/topics/settings/
>
> For the full list of settings and their values, see
> https://docs.djangoproject.com/en/3.2/ref/settings/
> """
>
> from pathlib import Path,os
>
> # Build paths inside the project like this: BASE_DIR / 'subdir'.
> BASE_DIR = Path(__file__).resolve().parent.parent
>
>
> # Quick-start development settings - unsuitable for production
> # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
>
> # SECURITY WARNING: keep the secret key used in production secret!
> SECRET_KEY =
> 'django-insecure-*36^7=gu7_i_c!v6yw8!li0=2kwo9u!8$lgqbznb0i^3p09%m$'
>
> # SECURITY WARNING: don't run with debug turned on in production!
> DEBUG = True
>
> ALLOWED_HOSTS = []
>
>
> # Application definition
>
> INSTALLED_APPS = [
> 'Fotoxplor',
> 'mypro',
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> ]
>
> MIDDLEWARE = [
> 'django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> ]
>
> ROOT_URLCONF = 'mypro.urls'
>
> TEMPLATES = [
> {
> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
> 'DIRS': [os.path.join(BASE_DIR,'templates')],
> 'APP_DIRS': True,
> 'OPTIONS': {
> 'context_processors': [
> 'django.template.context_processors.debug',
> 'django.template.context_processors.request',
> 'django.contrib.auth.context_processors.auth',
> 'django.contrib.messages.context_processors.messages',
> ],
> },
> },
> ]
>
> WSGI_APPLICATION = 'mypro.wsgi.application'
>
>
> # Database
> # https://docs.djangoproject.com/en/3.2/ref/settings/#databases
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3',
> 'NAME': BASE_DIR / 'db.sqlite3',
> }
> }
>
>
> # Password validation
> #
> https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
>
> AUTH_PASSWORD_VALIDATORS = [
> {
> 'NAME':
> 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'
> ,
> },
> {
> 'NAME':
> 'django.contrib.auth.password_validation.MinimumLengthValidator',
> },
> {
> 'NAME':
> 'django.contrib.auth.password_validation.CommonPasswordValidator',
> },
> {
> 'NAME':
> 'django.contrib.auth.password_validation.NumericPasswordValidator',
> },
> ]
>
>
> # Internationalization
> # https://docs.djangoproject.com/en/3.2/topics/i18n/
>
> LANGUAGE_CODE = 'en-us'
>
> TIME_ZONE = 'UTC'
>
> USE_I18N = True
>
> USE_L10N = True
>
> USE_TZ = True
>
>
> # Static files (CSS, JavaScript, Images)
> # https://docs.djangoproject.com/en/3.2/howto/static-files/
>
> STATIC_URL = '/static/'
> STATICFILES_DIRS =[
> os.path.join(BASE_DIR,'templates')
> ]
> STATIC_ROOT = os.path.join(BASE_DIR,'components')
>
> # Default primary key field type
> # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
>
> DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
>
> On Wed, Jun 30, 2021 at 10:54 AM patel dhruvish <
> pateldhruvish612...@gmail.com> wrote:
>
>> You want to add {%load static%} at the top of the code
>>
>> On Wed, Jun 30, 2021, 09:58 patel dhruvish 
>> wrote:
>>
>>> Do you add static code in setting.py and urls.py? Code is here
>>>
>>> Setting.py:-
>>> Project  urls.py:-
>>> Then load static file with format like:-
>>>
>>> STATICFILES_DIRS = [
>>> BASE_DIR / "static",
>>> '/var/www/static/',
>>> ]
>>>
>>>
>>> Project  urls.py:-
>>>
>>> from django.conf import settingsfrom django.conf.urls.static import static
>>>
>>> urlpatterns = [
>>> # ... the rest of your URLconf goes here ...
>>> ]
>>>
>>> + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
>>>
>>> Or
>>>
>>>  + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
>>>
>>>
>>> Then load static file with format like:-
>>>
>>> {% load static %}
>>> 
>>>
>>>
>>>
>>> On Wed, Jun 30, 2021, 09:47 UJJWAL AGRAWAL 
>>> wrote:
>>>
 Dear all I am facing one problem.
 When I am writing {%load static%} rather than getting executed it is
 getting displayed as simple text on the HTML output screen

 Please provide me the solution.

 --
>>>

Re: when i am writing {%load static%} rather than getting exectuted it is getting displayed as simple text on htmloutput screen

2021-06-30 Thread jasdeep singh

{% load static %}

Give space in % and load

On Wed, Jun 30, 2021, 9:47 AM UJJWAL AGRAWAL  wrote:

> Dear all I am facing one problem.
> When I am writing {%load static%} rather than getting executed it is
> getting displayed as simple text on the HTML output screen
>
> Please provide me the solution.
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALQ%3D5fyZPWiBGnY6VJB1_C6Rb1Ls4dfsGfTef%2BBSqi1BXKHtfw%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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAqe3eWWwbRoRUR4s%2BW8%3DLfExSJZBH-ZrJCPCoWW01D5vR9s%2Bg%40mail.gmail.com.


Re: when i am writing {%load static%} rather than getting exectuted it is getting displayed as simple text on htmloutput screen

2021-06-30 Thread UJJWAL AGRAWAL
Dear patel DHRUVISH urls.py code is:


from django.urls import path

from . import views

urlpatterns = [
path('',views.home, name='home'),
]


On Wed, Jun 30, 2021 at 1:01 PM UJJWAL AGRAWAL 
wrote:

> Dear patel dhruvish
>
> """
> Django settings for mypro project.
>
> Generated by 'django-admin startproject' using Django 3.2.4.
>
> For more information on this file, see
> https://docs.djangoproject.com/en/3.2/topics/settings/
>
> For the full list of settings and their values, see
> https://docs.djangoproject.com/en/3.2/ref/settings/
> """
>
> from pathlib import Path,os
>
> # Build paths inside the project like this: BASE_DIR / 'subdir'.
> BASE_DIR = Path(__file__).resolve().parent.parent
>
>
> # Quick-start development settings - unsuitable for production
> # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
>
> # SECURITY WARNING: keep the secret key used in production secret!
> SECRET_KEY =
> 'django-insecure-*36^7=gu7_i_c!v6yw8!li0=2kwo9u!8$lgqbznb0i^3p09%m$'
>
> # SECURITY WARNING: don't run with debug turned on in production!
> DEBUG = True
>
> ALLOWED_HOSTS = []
>
>
> # Application definition
>
> INSTALLED_APPS = [
> 'Fotoxplor',
> 'mypro',
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> ]
>
> MIDDLEWARE = [
> 'django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> ]
>
> ROOT_URLCONF = 'mypro.urls'
>
> TEMPLATES = [
> {
> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
> 'DIRS': [os.path.join(BASE_DIR,'templates')],
> 'APP_DIRS': True,
> 'OPTIONS': {
> 'context_processors': [
> 'django.template.context_processors.debug',
> 'django.template.context_processors.request',
> 'django.contrib.auth.context_processors.auth',
> 'django.contrib.messages.context_processors.messages',
> ],
> },
> },
> ]
>
> WSGI_APPLICATION = 'mypro.wsgi.application'
>
>
> # Database
> # https://docs.djangoproject.com/en/3.2/ref/settings/#databases
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3',
> 'NAME': BASE_DIR / 'db.sqlite3',
> }
> }
>
>
> # Password validation
> #
> https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
>
> AUTH_PASSWORD_VALIDATORS = [
> {
> 'NAME':
> 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'
> ,
> },
> {
> 'NAME':
> 'django.contrib.auth.password_validation.MinimumLengthValidator',
> },
> {
> 'NAME':
> 'django.contrib.auth.password_validation.CommonPasswordValidator',
> },
> {
> 'NAME':
> 'django.contrib.auth.password_validation.NumericPasswordValidator',
> },
> ]
>
>
> # Internationalization
> # https://docs.djangoproject.com/en/3.2/topics/i18n/
>
> LANGUAGE_CODE = 'en-us'
>
> TIME_ZONE = 'UTC'
>
> USE_I18N = True
>
> USE_L10N = True
>
> USE_TZ = True
>
>
> # Static files (CSS, JavaScript, Images)
> # https://docs.djangoproject.com/en/3.2/howto/static-files/
>
> STATIC_URL = '/static/'
> STATICFILES_DIRS =[
> os.path.join(BASE_DIR,'templates')
> ]
> STATIC_ROOT = os.path.join(BASE_DIR,'components')
>
> # Default primary key field type
> # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
>
> DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
>
> On Wed, Jun 30, 2021 at 10:54 AM patel dhruvish <
> pateldhruvish612...@gmail.com> wrote:
>
>> You want to add {%load static%} at the top of the code
>>
>> On Wed, Jun 30, 2021, 09:58 patel dhruvish 
>> wrote:
>>
>>> Do you add static code in setting.py and urls.py? Code is here
>>>
>>> Setting.py:-
>>> Project  urls.py:-
>>> Then load static file with format like:-
>>>
>>> STATICFILES_DIRS = [
>>> BASE_DIR / "static",
>>> '/var/www/static/',
>>> ]
>>>
>>>
>>> Project  urls.py:-
>>>
>>> from django.conf import settingsfrom django.conf.urls.static import static
>>>
>>> urlpatterns = [
>>> # ... the rest of your URLconf goes here ...
>>> ]
>>>
>>> + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
>>>
>>> Or
>>>
>>>  + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
>>>
>>>
>>> Then load static file with format like:-
>>>
>>> {% load static %}
>>> 
>>>
>>>
>>>
>>> On Wed, Jun 30, 2021, 09:47 UJJWAL AGRAWAL 
>>> wrote:
>>>
 Dear all I am facing one problem.
 When I am writing {%load static%} rather than getting executed it is
 getting di

Re: when i am writing {%load static%} rather than getting exectuted it is getting displayed as simple text on htmloutput screen

2021-06-30 Thread UJJWAL AGRAWAL
Dear patel dhruvish

"""
Django settings for mypro project.

Generated by 'django-admin startproject' using Django 3.2.4.

For more information on this file, see
https://docs.djangoproject.com/en/3.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""

from pathlib import Path,os

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY =
'django-insecure-*36^7=gu7_i_c!v6yw8!li0=2kwo9u!8$lgqbznb0i^3p09%m$'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'Fotoxplor',
'mypro',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'mypro.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR,'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'mypro.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}


# Password validation
#
https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME':
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME':
'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME':
'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME':
'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/

STATIC_URL = '/static/'
STATICFILES_DIRS =[
os.path.join(BASE_DIR,'templates')
]
STATIC_ROOT = os.path.join(BASE_DIR,'components')

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

On Wed, Jun 30, 2021 at 10:54 AM patel dhruvish <
pateldhruvish612...@gmail.com> wrote:

> You want to add {%load static%} at the top of the code
>
> On Wed, Jun 30, 2021, 09:58 patel dhruvish 
> wrote:
>
>> Do you add static code in setting.py and urls.py? Code is here
>>
>> Setting.py:-
>> Project  urls.py:-
>> Then load static file with format like:-
>>
>> STATICFILES_DIRS = [
>> BASE_DIR / "static",
>> '/var/www/static/',
>> ]
>>
>>
>> Project  urls.py:-
>>
>> from django.conf import settingsfrom django.conf.urls.static import static
>>
>> urlpatterns = [
>> # ... the rest of your URLconf goes here ...
>> ]
>>
>> + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
>>
>> Or
>>
>>  + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
>>
>>
>> Then load static file with format like:-
>>
>> {% load static %}
>> 
>>
>>
>>
>> On Wed, Jun 30, 2021, 09:47 UJJWAL AGRAWAL 
>> wrote:
>>
>>> Dear all I am facing one problem.
>>> When I am writing {%load static%} rather than getting executed it is
>>> getting displayed as simple text on the HTML output screen
>>>
>>> Please provide me the solution.
>>>
>>> --
>>> 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+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CALQ%3D5fyZPWiBGnY6VJB1_C6Rb1Ls4dfsGfTef%2BBSqi1BXKHtfw%40mail.gma

Re: when i am writing {%load static%} rather than getting exectuted it is getting displayed as simple text on htmloutput screen

2021-06-30 Thread UJJWAL AGRAWAL
Dear Patel Druvish ,
I have tried with that one

Its showing such kind of error when trying to css file

Failed to load resource: the server responded with a status of 404 (Not
Found)
extension.js:24 onMessage extension
ial.js:450 Clean the cache of the scraper (new onComplete event)
style.css'%%7D:1 Failed to load resource: the server responded with a
status of 404 (Not Found)
The attempt to bind "/static/%7B%static%20'styles/style.css'%%7D" in the
workspace failed as this URI is malformed.

HTML CODE{%load static%}






Fotoxplor



Welcome to Fotoxplor


Fotoxplor










Fotoxplor



About us
Services
News

Contact



Call us: 00-56 445 678 33











Photocateogry 
Choose your Photocateogry:


  
  
  
  
  





On Wed, Jun 30, 2021 at 9:58 AM patel dhruvish <
pateldhruvish612...@gmail.com> wrote:

> Do you add static code in setting.py and urls.py? Code is here
>
> Setting.py:-
> Project  urls.py:-
> Then load static file with format like:-
>
> STATICFILES_DIRS = [
> BASE_DIR / "static",
> '/var/www/static/',
> ]
>
>
> Project  urls.py:-
>
> from django.conf import settingsfrom django.conf.urls.static import static
>
> urlpatterns = [
> # ... the rest of your URLconf goes here ...
> ]
>
> + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
>
> Or
>
>  + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
>
>
> Then load static file with format like:-
>
> {% load static %}
> 
>
>
>
> On Wed, Jun 30, 2021, 09:47 UJJWAL AGRAWAL  wrote:
>
>> Dear all I am facing one problem.
>> When I am writing {%load static%} rather than getting executed it is
>> getting displayed as simple text on the HTML output screen
>>
>> Please provide me the solution.
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CALQ%3D5fyZPWiBGnY6VJB1_C6Rb1Ls4dfsGfTef%2BBSqi1BXKHtfw%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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANMvxF0juEz51Pua5PRAR8uNjKPsSGVkZUnDYjTTtve7hfObag%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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALQ%3D5fwh338p62K759MHec2AKP-_R4H%3DKN8ZdEs3axhopJL2GQ%40mail.gmail.com.