reg: Django custom middleware

2024-01-24 Thread 'Amitesh Sahay' via Django users
Hi All,
I have written a custom Django middleware to do retries and catch exception if 
there is any connection related issues between two servers. Below is the code 
snippet.
from requests.adapters import Retry, RetryError, HTTPAdapter, MaxRetryError, 
ConnectTimeoutError, ProtocolError, ResponseErrorfrom requests.sessions import 
Sessionfrom django.http import HttpResponseServerError

class RetryCal:    def __init__(self, get_response):        self.get_response = 
get_response
    @staticmethod    def process_request(request):        try:            
session = Session()            retries = Retry(total=5, backoff_factor=2, 
status_forcelist=[500, 502, 503, 504])            session.mount('https://', 
HTTPAdapter(max_retries=retries))            request.retry_session = session
        except Exception as e:            raise e
    def __call__(self, request):        RetryCal.process_request(request)       
 try:            response = self.get_response(request)            return 
response
        except (ProtocolError, OSError) as err:            raise 
ConnectionError(err, request)
        except MaxRetryError as e:            if isinstance(e.reson, 
ConnectTimeoutError):                return HttpResponseServerError("Connection 
timeout error...")            if isinstance(e.reson, ResponseError):            
    raise RetryError(e, request=request)
            raise ConnectionError(e, request)

Below is the placement of the custom middleware
'django.middleware.security.SecurityMiddleware','django.contrib.sessions.middleware.SessionMiddleware',
# custom retry middleware.'integ.api_retry_custom_middleware.RetryCal',
below this custom middleware I do have other default one's as well.
The problem is I am not sure if this is working. I have an access token, In 
that I added some garbage characters and tried to hit my endpoint. I did see an 
exception as seen below
Internal Server Error: /api/acct/[24/Jan/2024 14:23:39] "GET /api/acct/ 
HTTP/1.1" 500 5348
But I can see this error even if I comment out my custom middleware. My purpose 
is to create the custom middleware and if there is any API request from any 
Django App the request should go first through the custom middleware. That is 
my thought. But I am not sure if the middleware is working. Or maybe the 
placement if the custom middleware is not proper. I have been working with 
Django for a while now but written the custom middleware for the first time.
Please suggest.




Regards,
Amitesh

-- 
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/304829749.259529.1706099335383%40mail.yahoo.com.


Re: Help to implement join query in django orm

2022-07-25 Thread 'Amitesh Sahay' via Django users
10. How to perform join operations in django ORM? — Django ORM Cookbook 2.0 
documentation (agiliq.com)



Try this 

On Monday, 25 July, 2022 at 01:18:44 pm IST, Mihir Patel 
 wrote:  
 
 is anyone having login issue? , i am unable to authenticate a user in my 
website
On Sun, Jul 24, 2022 at 10:37 PM Jitendra kumar Patra 
 wrote:

Ping me 7008080545
On Fri, 22 Jul, 2022, 12:16 Avi shah,  wrote:

I have two tables Tbl 1 & Tbl 2 
I need to connect the two tables using a join 

Thanks and regards, Avi shah 

-- 
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/CALa7AFNmoep5MT3MwoYn1ZF0S%3DENPUdVAO-_3EmVyAzCub_Jkg%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/CAOAROf%3DgMPbSQ37f81A0rpRr7NgiUFF8ZyTsF8bZ-KG9Sgh%3DkA%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/CAC10kRFL%3D1a6T0-DG%3DZTsBugJa2_iFf-itHjSwAc9-2vHOnB7g%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/1973455060.1368718.1658735565276%40mail.yahoo.com.


Re: Nested json in django rest framework

2022-06-05 Thread 'Amitesh Sahay' via Django users
PROBABLY, Pandas would help you


Regards,
Amitesh Sahay91-750 797 8619 

On Monday, 6 June, 2022, 10:12:07 am IST, Koushik Romel 
 wrote:  
 
 Thanks for your time I've learnt something new from your message and I solved 
the problem yesterday itself it was my mistake I added the wrong model to 
serializer

On Sunday, 5 June 2022 at 23:15:47 UTC+5:30 Kasper Laudrup wrote:

On 05/06/2022 07.06, Koushik Romel wrote:
> I want those #One and #Two to be in curly braces {} and not as square 
> bracket [] , and Thanks in advance

A good start would be to understand what the difference between square 
brackets and curly braces is. The JSON format is very simple:

https://en.wikipedia.org/wiki/JSON#Syntax

So you actually want to convert your array to an object with anonymous 
properties/members. That doesn't really make any sense and wouldn't be 
valid JSON.

Of course you could write a dirty hack and do it anyway but I seriously 
doubt that's really what you want.

Hope that helps.

Kind regards,

Kasper Laudrup



-- 
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/1e14a36d-0960-4083-a208-9396340c3912n%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/1811603093.5998539.1654492659105%40mail.yahoo.com.


Re: Django project

2022-05-12 Thread 'Amitesh Sahay' via Django users
Yes, plz make a list of features that you want to have in ur web app, and then 
read django official doc to understand the working for each feature that u 
want. That's the way to go ahead, coz what u r asking is very generic 


Sent from Yahoo Mail on Android 
 
  On Thu, 12 May 2022 at 22:44, Tanni Seriki wrote:   
Please groups am working on a school projectThe project is to send a SMS to a 
lecturer when his/her period wants to starts.The SMS will contain the venue, 
time and date...Is there a way this can be accomplished by django

-- 
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/CALWCJq0Qe4NRBaU_HZ-%3DsUki2-bVCcBEuBhxtSt%2BxA%2BU4APdiA%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/1540855466.1953087.1652376787208%40mail.yahoo.com.


Re: python manage.py magrate gives the below error with SQL SERVER (Please help)

2021-08-10 Thread 'Amitesh Sahay' via Django users
check your database table though some UI. make sure that the " polls_question" 
is not there  

On Tuesday, 10 August, 2021, 07:20:42 pm IST, Vikram Gajjala 
 wrote:  
 
 SQL Server 2019Python  3.9.6pip  21.2.3python -m django --version 3.2.6
asgiref              3.4.1astroid              2.6.6colorama             
0.4.4Django               3.2.6django-mssql-backend 2.8.1django-pyodbc        
1.1.3django-tastypie      0.14.3isort                5.9.3lazy-object-proxy    
1.6.0mccabe               0.6.1pip                  21.2.3pylint               
2.9.6pyodbc               4.0.31python-dateutil      2.8.2python-mimeparse     
1.6.0pytz                 2021.1setuptools           56.0.0six                  
1.16.0sqlparse             0.4.1toml                 0.10.2wrapt                
1.12.1

(mysite) C:\Python_Vik\mysite\myfirstsite>python manage.py migrateOperations to 
perform:  Apply all migrations: admin, auth, contenttypes, polls, 
sessionsRunning migrations:  Applying polls.0004_choice_question...Traceback 
(most recent call last):  File 
"C:\Python_Vik\mysite\lib\site-packages\django\db\backends\utils.py", line 82, 
in _execute    return self.cursor.execute(sql)  File 
"C:\Python_Vik\mysite\lib\site-packages\sql_server\pyodbc\base.py", line 553, 
in execute    return self.cursor.execute(sql, params)pyodbc.ProgrammingError: 
('42S01', "[42S01] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]There 
is already an object named 'polls_question' in the database. (2714) 
(SQLExecDirectW)")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):  File 
"C:\Python_Vik\mysite\myfirstsite\manage.py", line 22, in     main()  
File "C:\Python_Vik\mysite\myfirstsite\manage.py", line 18, in main    
execute_from_command_line(sys.argv)  File 
"C:\Python_Vik\mysite\lib\site-packages\django\core\management\__init__.py", 
line 419, in execute_from_command_line    utility.execute()  File 
"C:\Python_Vik\mysite\lib\site-packages\django\core\management\__init__.py", 
line 413, in execute    self.fetch_command(subcommand).run_from_argv(self.argv) 
 File "C:\Python_Vik\mysite\lib\site-packages\django\core\management\base.py", 
line 354, in run_from_argv    self.execute(*args, **cmd_options)  File 
"C:\Python_Vik\mysite\lib\site-packages\django\core\management\base.py", line 
398, in execute    output = self.handle(*args, **options)  File 
"C:\Python_Vik\mysite\lib\site-packages\django\core\management\base.py", line 
89, in wrapped    res = handle_func(*args, **kwargs)  File 
"C:\Python_Vik\mysite\lib\site-packages\django\core\management\commands\migrate.py",
 line 244, in handle    post_migrate_state = executor.migrate(  File 
"C:\Python_Vik\mysite\lib\site-packages\django\db\migrations\executor.py", line 
117, in migrate    state = self._migrate_all_forwards(state, plan, full_plan, 
fake=fake, fake_initial=fake_initial)  File 
"C:\Python_Vik\mysite\lib\site-packages\django\db\migrations\executor.py", line 
147, in _migrate_all_forwards    state = self.apply_migration(state, migration, 
fake=fake, fake_initial=fake_initial)  File 
"C:\Python_Vik\mysite\lib\site-packages\django\db\migrations\executor.py", line 
227, in apply_migration    state = migration.apply(state, schema_editor)  File 
"C:\Python_Vik\mysite\lib\site-packages\django\db\migrations\migration.py", 
line 126, in apply    operation.database_forwards(self.app_label, 
schema_editor, old_state, project_state)  File 
"C:\Python_Vik\mysite\lib\site-packages\django\db\migrations\operations\models.py",
 line 92, in database_forwards    schema_editor.create_model(model)  File 
"C:\Python_Vik\mysite\lib\site-packages\sql_server\pyodbc\schema.py", line 809, 
in create_model    self.execute(sql, params or None)  File 
"C:\Python_Vik\mysite\lib\site-packages\sql_server\pyodbc\schema.py", line 872, 
in execute    cursor.execute(sql, params)  File 
"C:\Python_Vik\mysite\lib\site-packages\django\db\backends\utils.py", line 98, 
in execute    return super().execute(sql, params)  File 
"C:\Python_Vik\mysite\lib\site-packages\django\db\backends\utils.py", line 66, 
in execute    return self._execute_with_wrappers(sql, params, many=False, 
executor=self._execute)  File 
"C:\Python_Vik\mysite\lib\site-packages\django\db\backends\utils.py", line 75, 
in _execute_with_wrappers    return executor(sql, params, many, context)  File 
"C:\Python_Vik\mysite\lib\site-packages\django\db\backends\utils.py", line 84, 
in _execute    return self.cursor.execute(sql, params)  File 
"C:\Python_Vik\mysite\lib\site-packages\django\db\utils.py", line 90, in 
__exit__    raise dj_exc_value.with_traceback(traceback) from exc_value  File 
"C:\Python_Vik\mysite\lib\site-packages\django\db\backends\utils.py", line 82, 
in _execute    return self.cursor.execute(sql)  File 
"C:\Python_Vik\mysite\lib\site-packages\sql_server\pyodbc\base.py", line 553, 
in execute    return self.cursor.execute(sql, 
params)django.db.utils.ProgrammingError: 

Re: Loading csv data in database

2021-04-30 Thread 'Amitesh Sahay' via Django users
try the below way. Its simple
Writing custom django-admin commands | Django documentation | Django


| 
| 
|  | 
Writing custom django-admin commands | Django documentation | Django


 |

 |

 |






Regards,
Amitesh 

On Friday, 30 April, 2021, 08:28:07 pm IST, Derek  
wrote:  
 
 Someone has an example of doing just this:
https://arshovon.com/blog/django-custom-command/

On Thursday, 29 April 2021 at 19:39:36 UTC+2 Ryan Nowakowski wrote:

Typically you would write a custom management command for this kind of thing:

https://docs.djangoproject.com/en/3.2/howto/custom-management-commands/

On April 29, 2021 11:05:29 AM CDT, 'Muhammad Asim Khaskheli' via Django users 
 wrote:

Hi,
I wanted to ask how to load CSV data into the model. What steps do we have to 
follow?
I have made this function but how exactly to run this code because, python 
manage.py load data won't work. 

def import_data():
 with open('sample-dataset.csv') as f:
 reader = csv.reader(f)
 for row in reader:
 if row[0] != 'user_id':
 _, created = Funnel.objects.get_or_create(
 user_id=row[0],
 event=row[1],
 timestamp=row[2],
 session_id=row[3]
 )
Now, how to run this script?








-- 
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/137aee79-07e6-40e1-badd-671ae3b0c87cn%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/852196364.883280.1619794997850%40mail.yahoo.com.


Re: Django Rest Framework & How to Learn it ?

2021-04-12 Thread 'Amitesh Sahay' via Django users
As per my experience, start with user authentication system in DRF. How you can 
create a registration , login and logout system. When I started I stuck there. 
I am working on a Employee management system. If u want you can contribute and 
learn, even I am in the learning phase of DRF. 

Sent from Yahoo Mail on Android 
 
  On Mon, 12 Apr 2021 at 18:35, Aniket 
Balkhande wrote:   Dear Community Members,   
     I am Aniket, I have given 2 interviews this week, one for Django Developer 
and the other for React Developer with Django REST Framework.  In both 
interviews I was asked about DRF questions a lot apart from other stuff.        
 So, my question is how to learn the django rest framework & from where can I 
start ?.  Sorry it is not a technical question. But I thought It will be more 
beneficial for me rather than asking on all other platforms. 
I will appreciate your thoughts on this.
kind regards,Aniket 

-- 
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/CANPrwf-90047itRfWmWQjKL--AWw1UJ4-Te0yVE6K7ffg%3D8BJA%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/613345810.829119.1618232998315%40mail.yahoo.com.


Re: Try to connect Redis Channel in Django Chat Project

2021-04-09 Thread 'Amitesh Sahay' via Django users
plz ping the REDIS server from Django server, also try to telnet
ping telnet  PORT on which redis is running


Regards,
Amitesh  

On Friday, 9 April, 2021, 02:40:57 pm IST, Andréas Kühne 
 wrote:  
 
 You need to make sure that you have a redis server running and that you have 
the correct connection in django settings for the channels setup.
See more 
here:https://channels.readthedocs.io/en/stable/topics/channel_layers.html?highlight=redis#redis-channel-layer

Regards,
Andréas

Den fre 9 apr. 2021 kl 00:38 skrev Kylex Isasi Tech :

How to fix this error

-- 
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/CAM-He%3DHkAaA3CCUzmp%2BSxA-SQ%2BA9NnJRVQRqwTJB8o%2B8fPbxbA%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/CAK4qSCeqFRaT1XSHszG_k_EKcKDtZAE_8ZHUJGUx4e-qUppk9w%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/340312426.199733.1617966934242%40mail.yahoo.com.


Re: reg: DRF login API

2021-04-08 Thread 'Amitesh Sahay' via Django users
HI, 
-a xxx.x...@.com --> username
After I entered 
python.exe -m httpie -a xxx.x...@.com POST 127.0.0.1:8000/apii/login/ 
'Authorization: Token 
db058f23ecc70f4fa3de4ac69a04dc48bb7579a63aea1ad3d038ce59b1511890'

It prompted for the password, I entered, that is when I got the output


Regards,
Amitesh  

On Thursday, 8 April, 2021, 08:00:27 pm IST, RANGA BHARATH JINKA 
 wrote:  
 
 Hi,
Try providing a username and password. Check if it is working or not
On Thu, Apr 8, 2021 at 7:26 PM 'Amitesh Sahay' via Django users 
 wrote:

Hey Ranga,
Below is the new output
python.exe -m httpie -a xxx.x...@.com POST 127.0.0.1:8000/apii/login/ 
'Authorization: Token 
db058f23ecc70f4fa3de4ac69a04dc48bb7579a63aea1ad3d038ce59b1511890'
http: password for xxx.x...@.com@127.0.0.1:8000: "this asked for the 
password, so I entered and hit return key. Below is the output"
HTTP/1.1 400 Bad RequestAllow: POST, OPTIONSContent-Length: 79Content-Type: 
application/jsonDate: Thu, 08 Apr 2021 13:49:29 GMTReferrer-Policy: 
same-originServer: WSGIServer/0.2 CPython/3.6.8Vary: Accept, 
CookieX-Content-Type-Options: nosniffX-Frame-Options: DENY
{    "password": [        "This field is required."    ],    "username": [      
  "This field is required."    ]}
The above output is little surprising and interesting. I am using custom User 
model, where email is used in place of username and happens to be the unique 
constraint. SO I really do not understand the above output. If you need more 
data, do let me know.


Regards,
Amitesh 
On Thursday, 8 April, 2021, 06:44:54 pm IST, RANGA BHARATH JINKA 
 wrote:  
 
 Hi, You have to specify the POST method in the commandhttp -a USERNAME POST 
https://api.github.com/repos/httpie/httpie/issues/83/comments body='HTTPie is 
awesome! :heart:' All the best
On Thu, Apr 8, 2021 at 6:18 PM 'Amitesh Sahay' via Django users 
 wrote:

HI,
I have created a simple login API through django rest framework. Below is the 
code snippet:
from django.contrib.auth import login
from rest_framework.generics import ListCreateAPIView
from rest_framework import status
from rest_framework.response import Response
from rest_framework.authtoken.serializers import AuthTokenSerializer
from rest_framework.permissions import IsAuthenticated, IsAdminUser, AllowAny
from knox.views import LoginView as KLView
from knox.models import AuthToken
from .serializers import RegistrationSerializers
from .models import NewEmployeeProfile
class loginAPIView(KLView):
permission_classes = [AllowAny]

def post(self, request, format=None):
serializer = AuthTokenSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
user = serializer.validated_data['user']
login(request, user)
return super(loginAPIView, self).post(request, format=None) URLS.pyfrom 
django.urls import pathfrom knox import views as knox_viewsfrom .views import 
UserRegisterView, loginAPIView

urlpatterns = [    path('register/', UserRegisterView.as_view(), 
name='register'),    path('login/', loginAPIView.as_view(), name='login'),    ]

Now when I do a POST request in postman with the email and the password. It 
throws error:
{    "detail": "Invalid token."}
Note:: Since I am using knox to generate token. So, when I do a new 
registration I get token as well. See sample below:
{    "status": "OK",    "message": {        "email": "test.t...@test.com",      
  "first_name": "est",        "last_name": "Sah",        "employee_code": 
"6124368",        "contact": "7500078619",        "dob": null    },    "token": 
"db058f23ecc70f4fa3de4ac69a04dc48bb7579a63aea1ad3d038ce59b1511890"
I tried both, password and token to authenticate, but I am getting the same 
error. In the cmd prompt where the dev server is running, I am seeing below 
message
[08/Apr/2021 15:26:33] "POST /apii/login/ HTTP/1.1" 403 
27Forbidden: /apii/login/In the postman raw body, I am 
inserting below json data
{    "email": "test.t...@test.com",    "password": 
"db058f23ecc70f4fa3de4ac69a04dc48bb7579a63aea1ad3d038ce59b1511890"}

Below is the settings.py content for DRF
REST_FRAMEWORK = {    'DEFAULT_AUTHENTICATION_CLASSES': [        
#'rest_framework.authentication.TokenAuthentication',        
'rest_framework.authentication.SessionAuthentication',        
'knox.auth.TokenAuthentication',    ],}


httpie output
python.exe -m httpie 127.0.0.1:8000/apii/login/ 'Authorization: Token 
db058f23ecc70f4fa3de4ac69a04dc48bb7579a63aea1ad3d038ce59b1511890'
HTTP/1.1 405 Method Not AllowedAllow: POST, OPTIONSContent-Length: 
40Content-Type: application/jsonDate: Thu, 08 Apr 2021 11:52:31 
GMTReferrer-Policy: same-originServe

Re: reg: DRF login API

2021-04-08 Thread 'Amitesh Sahay' via Django users
Hey Ranga,
Below is the new output
python.exe -m httpie -a xxx.x...@.com POST 127.0.0.1:8000/apii/login/ 
'Authorization: Token 
db058f23ecc70f4fa3de4ac69a04dc48bb7579a63aea1ad3d038ce59b1511890'
http: password for xxx.x...@.com@127.0.0.1:8000: "this asked for the 
password, so I entered and hit return key. Below is the output"
HTTP/1.1 400 Bad RequestAllow: POST, OPTIONSContent-Length: 79Content-Type: 
application/jsonDate: Thu, 08 Apr 2021 13:49:29 GMTReferrer-Policy: 
same-originServer: WSGIServer/0.2 CPython/3.6.8Vary: Accept, 
CookieX-Content-Type-Options: nosniffX-Frame-Options: DENY
{    "password": [        "This field is required."    ],    "username": [      
  "This field is required."    ]}
The above output is little surprising and interesting. I am using custom User 
model, where email is used in place of username and happens to be the unique 
constraint. SO I really do not understand the above output. If you need more 
data, do let me know.


Regards,
Amitesh 
On Thursday, 8 April, 2021, 06:44:54 pm IST, RANGA BHARATH JINKA 
 wrote:  
 
 Hi, You have to specify the POST method in the commandhttp -a USERNAME POST 
https://api.github.com/repos/httpie/httpie/issues/83/comments body='HTTPie is 
awesome! :heart:' All the best
On Thu, Apr 8, 2021 at 6:18 PM 'Amitesh Sahay' via Django users 
 wrote:

HI,
I have created a simple login API through django rest framework. Below is the 
code snippet:
from django.contrib.auth import login
from rest_framework.generics import ListCreateAPIView
from rest_framework import status
from rest_framework.response import Response
from rest_framework.authtoken.serializers import AuthTokenSerializer
from rest_framework.permissions import IsAuthenticated, IsAdminUser, AllowAny
from knox.views import LoginView as KLView
from knox.models import AuthToken
from .serializers import RegistrationSerializers
from .models import NewEmployeeProfile
class loginAPIView(KLView):
permission_classes = [AllowAny]

def post(self, request, format=None):
serializer = AuthTokenSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
user = serializer.validated_data['user']
login(request, user)
return super(loginAPIView, self).post(request, format=None) URLS.pyfrom 
django.urls import pathfrom knox import views as knox_viewsfrom .views import 
UserRegisterView, loginAPIView

urlpatterns = [    path('register/', UserRegisterView.as_view(), 
name='register'),    path('login/', loginAPIView.as_view(), name='login'),    ]

Now when I do a POST request in postman with the email and the password. It 
throws error:
{    "detail": "Invalid token."}
Note:: Since I am using knox to generate token. So, when I do a new 
registration I get token as well. See sample below:
{    "status": "OK",    "message": {        "email": "test.t...@test.com",      
  "first_name": "est",        "last_name": "Sah",        "employee_code": 
"6124368",        "contact": "7500078619",        "dob": null    },    "token": 
"db058f23ecc70f4fa3de4ac69a04dc48bb7579a63aea1ad3d038ce59b1511890"
I tried both, password and token to authenticate, but I am getting the same 
error. In the cmd prompt where the dev server is running, I am seeing below 
message
[08/Apr/2021 15:26:33] "POST /apii/login/ HTTP/1.1" 403 
27Forbidden: /apii/login/In the postman raw body, I am 
inserting below json data
{    "email": "test.t...@test.com",    "password": 
"db058f23ecc70f4fa3de4ac69a04dc48bb7579a63aea1ad3d038ce59b1511890"}

Below is the settings.py content for DRF
REST_FRAMEWORK = {    'DEFAULT_AUTHENTICATION_CLASSES': [        
#'rest_framework.authentication.TokenAuthentication',        
'rest_framework.authentication.SessionAuthentication',        
'knox.auth.TokenAuthentication',    ],}


httpie output
python.exe -m httpie 127.0.0.1:8000/apii/login/ 'Authorization: Token 
db058f23ecc70f4fa3de4ac69a04dc48bb7579a63aea1ad3d038ce59b1511890'
HTTP/1.1 405 Method Not AllowedAllow: POST, OPTIONSContent-Length: 
40Content-Type: application/jsonDate: Thu, 08 Apr 2021 11:52:31 
GMTReferrer-Policy: same-originServer: WSGIServer/0.2 CPython/3.6.8Vary: 
Accept, CookieX-Content-Type-Options: nosniffX-Frame-Options: DENY
{    "detail": "Method \"GET\" not allowed."}

urlpatterns = [ path('register/', UserRegisterView.as_view(), name='register'), 
path('login/', loginAPIView.as_view(), name='login'), ]Not sure if I am doing 
it the right way, please suggest. Thank you


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receivi

reg: DRF login API

2021-04-08 Thread 'Amitesh Sahay' via Django users
HI,
I have created a simple login API through django rest framework. Below is the 
code snippet:
from django.contrib.auth import login
from rest_framework.generics import ListCreateAPIView
from rest_framework import status
from rest_framework.response import Response
from rest_framework.authtoken.serializers import AuthTokenSerializer
from rest_framework.permissions import IsAuthenticated, IsAdminUser, AllowAny
from knox.views import LoginView as KLView
from knox.models import AuthToken
from .serializers import RegistrationSerializers
from .models import NewEmployeeProfile
class loginAPIView(KLView):
permission_classes = [AllowAny]

def post(self, request, format=None):
serializer = AuthTokenSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
user = serializer.validated_data['user']
login(request, user)
return super(loginAPIView, self).post(request, format=None) URLS.pyfrom 
django.urls import pathfrom knox import views as knox_viewsfrom .views import 
UserRegisterView, loginAPIView

urlpatterns = [    path('register/', UserRegisterView.as_view(), 
name='register'),    path('login/', loginAPIView.as_view(), name='login'),    ]

Now when I do a POST request in postman with the email and the password. It 
throws error:
{    "detail": "Invalid token."}
Note:: Since I am using knox to generate token. So, when I do a new 
registration I get token as well. See sample below:
{    "status": "OK",    "message": {        "email": "test.t...@test.com",      
  "first_name": "est",        "last_name": "Sah",        "employee_code": 
"6124368",        "contact": "7500078619",        "dob": null    },    "token": 
"db058f23ecc70f4fa3de4ac69a04dc48bb7579a63aea1ad3d038ce59b1511890"
I tried both, password and token to authenticate, but I am getting the same 
error. In the cmd prompt where the dev server is running, I am seeing below 
message
[08/Apr/2021 15:26:33] "POST /apii/login/ HTTP/1.1" 403 
27Forbidden: /apii/login/In the postman raw body, I am 
inserting below json data
{    "email": "test.t...@test.com",    "password": 
"db058f23ecc70f4fa3de4ac69a04dc48bb7579a63aea1ad3d038ce59b1511890"}

Below is the settings.py content for DRF
REST_FRAMEWORK = {    'DEFAULT_AUTHENTICATION_CLASSES': [        
#'rest_framework.authentication.TokenAuthentication',        
'rest_framework.authentication.SessionAuthentication',        
'knox.auth.TokenAuthentication',    ],}


httpie output
python.exe -m httpie 127.0.0.1:8000/apii/login/ 'Authorization: Token 
db058f23ecc70f4fa3de4ac69a04dc48bb7579a63aea1ad3d038ce59b1511890'
HTTP/1.1 405 Method Not AllowedAllow: POST, OPTIONSContent-Length: 
40Content-Type: application/jsonDate: Thu, 08 Apr 2021 11:52:31 
GMTReferrer-Policy: same-originServer: WSGIServer/0.2 CPython/3.6.8Vary: 
Accept, CookieX-Content-Type-Options: nosniffX-Frame-Options: DENY
{    "detail": "Method \"GET\" not allowed."}

urlpatterns = [ path('register/', UserRegisterView.as_view(), name='register'), 
path('login/', loginAPIView.as_view(), name='login'), ]Not sure if I am doing 
it the right way, please suggest. Thank you

-- 
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/2028966691.640551.1617886057684%40mail.yahoo.com.


Re: MultiValueDictKeyError at /Oreo/SignIn/ ('username', None)

2021-04-03 Thread 'Amitesh Sahay' via Django users
Nidhi,
Please give details about your views. Which view do you think is causing the 
issue. Give more details .


Regards,
Amitesh  

On Sunday, 4 April, 2021, 09:34:56 am IST, Nidhi Vadodariya 
 wrote:  
 
 This is not a solution of my error Kindly regards 
Nidhi vadodariya
On Sun, 4 Apr 2021, 4:19 am Kasper Laudrup,  wrote:

On 03/04/2021 22.37, Nidhi Vadodariya wrote:
> hey anyone can please help me i am getting this error while creating a
> user by form
> 

https://betterprogramming.pub/how-to-ask-questions-about-programming-dcd948fcd2bd

Kind regards,

Kasper Laudrup

-- 
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/d549d7c2-b341-2ccf-46b7-82076b569397%40stacktrace.dk.



-- 
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/CAP1eD-rtypbsu1jor2d%3DnNU7tahJEdM%2BoMwUukNuDzKMkD_86w%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/1751539254.194909.1617512662277%40mail.yahoo.com.


Re: ListView , Need Help !

2021-04-03 Thread 'Amitesh Sahay' via Django users
This is related to front-end coding mi amigo


Regards,
Amitesh 

On Sunday, 4 April, 2021, 07:59:53 am IST, Ryan Nowakowski 
 wrote:  
 
 Take a look at CSS to change how your blog posts are laid out.

On April 3, 2021 4:19:49 PM CDT, Mustafa Burhani  
wrote:
When i create blog post they are aligned vertical i want align be horizontal 
how i can do ?


For Example :            #  Vertical Post            # Vertical Post            
#  Vertical Post            # Vertical Post

I want be :
# horizontal Post # horizontal Post # horizontal Post # horizontal Post

I hope if you understand me 




-- 
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/53B9E421-4459-4437-BE76-B485A17D1C93%40fattuba.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/1714866023.2573794.1617512474859%40mail.yahoo.com.


Re: Custom User Model

2021-04-03 Thread 'Amitesh Sahay' via Django users
Hello Manuel, 
Try the below. Recently I have worked on custom user model:
class AccountManager(BaseUserManager):
def create_superuser(self, email, password, **extra_fields):
extra_fields.setdefault('is_staff', True)
extra_fields.setdefault('is_superuser', True)
extra_fields.setdefault('is_active', True)

if extra_fields.get('is_staff') is not True:
raise ValueError(_('Superuser must have is_staff=True.'))
if extra_fields.get('is_superuser') is not True:
raise ValueError(_('Superuser must have is_superuser=True.'))
return self.create_user(email, password, **extra_fields)

def create_user(self, email, password, **extra_fields):
extra_fields.setdefault('is_staff', False)
extra_fields.setdefault('is_superuser', False)
if not email:
raise ValueError(_('Enter the email before proceeding'))

email = self.normalize_email(email)
user = self.model(email=email, password=password, **extra_fields)
user.set_password(password)
user.save()
return user
see if these changes make any difference.


Regards,
Amitesh  

On Saturday, 3 April, 2021, 10:24:52 pm IST, Manuel Buri 
 wrote:  
 
 Hi, 

I have a custom user model (see below) with inheritance from AbstractBaseUser 
and PermissionMixin. Therefore I have not only the auth_group, 
auth_group_permissions and auth_permissions tables but also those for my custom 
user model called 'Account'.
Currently I have the following problem: I cannot add groups to the custom user 
model group but I can add to auth_group. Also in django admin looking at the 
custom user table I can see the auth_group... which is weird... I think I have 
done an error or missed something while setting it up... thank you very much 
for your help.
from django.db import modelsfrom django.contrib.auth.models import 
AbstractBaseUser, BaseUserManager, PermissionsMixinfrom 
django.contrib.auth.models import Userfrom organization.models import 
Organization
class MyAccountManager(BaseUserManager):
 def create_user(self, email, first_name, last_name, password=None): if not 
email: raise ValueError('Users must have an email address') if not first_name: 
raise ValueError('Users must have a first name') if not last_name: raise 
ValueError('Users must have a last name')
 user = self.model( email=self.normalize_email(email), first_name=first_name, 
last_name=last_name ) user.set_password(password) user.save(using=self._db) 
return user
 def create_superuser(self, email, first_name, last_name ,password): user = 
self.create_user( email=self.normalize_email(email), password=password, 
first_name=first_name, last_name=last_name ) user.is_admin = True user.is_staff 
= True user.is_superuser = True user.save(using=self._db) return user

class Account(AbstractBaseUser, PermissionsMixin): email  = 
models.EmailField(verbose_name="email", max_length=60, unique=True) # username  
= models.CharField(max_length=30, unique=True) # TODO: for production do not 
allow null field first_name = models.CharField(verbose_name="first_name", 
max_length=40) last_name  = models.CharField(verbose_name="last_name", 
max_length=40) full_name  = models.CharField(verbose_name="full_name", 
max_length=80) # 1 Employee has 1 Organization, but 1 Organization has many 
employees organization = models.ForeignKey(Organization, 
on_delete=models.CASCADE, null=True) date_joined = 
models.DateTimeField(verbose_name='date joined', auto_now_add=True) last_login 
= models.DateTimeField(verbose_name='last login', auto_now=True) is_admin = 
models.BooleanField(default=False) is_active = 
models.BooleanField(default=True) is_staff = models.BooleanField(default=False) 
is_superuser = models.BooleanField(default=False)

 USERNAME_FIELD = "email" REQUIRED_FIELDS = ["first_name", "last_name",]
 objects = MyAccountManager()
 def __str__(self): return self.email
 # For checking permissions. to keep it simple all admin have ALL permissions 
def has_perm(self, perm, obj=None): return self.is_admin
 # Does this user have permission to view this app? (ALWAYS YES FOR SIMPLICITY) 
def has_module_perms(self, app_label): return True



-- 
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/38882988-f54d-4830-9cbd-9b9ad49349c0n%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/1261334457.2585167.1617512381261%40mail.yahoo.com.


[no subject]

2021-04-02 Thread 'Amitesh Sahay' via Django users
Plz share ur exact question.
Thanks

Sent from Yahoo Mail on Android 
 
  On Fri, 2 Apr 2021 at 15:41, Richard Dushime wrote:   
dear developers i am requesting for help  
i am  new  and i wanted to start contributing on a project  but i have failed 
on how to start i have seen one project ideas but i am not seeing a mentor 
contacts  please i need a help 
thank you


-- 
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/CAJCm56Kf9mxV7jxErjFBspBaQKBDPoUPGQkWRjSmO3h%2Btmdw0w%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/1620072665.2307971.1617358458146%40mail.yahoo.com.


reg: Django vs DRF

2021-03-26 Thread 'Amitesh Sahay' via Django users
I have a basic question.From all the tutorials and document that I have gone 
through for DRF, my understanding is that Token authentication is used to 
access the REST APIs.
So, my question is, does DRF have such a user creation system, or is it only 
done through the Django User model, i.e. The way we have a Django user model, 
which is used to register/create a new user in a database and login with their 
registered account.?
I hope my query is clear. 
Regards,
Amitesh

-- 
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/866964018.493665.1616745114708%40mail.yahoo.com.


Re: python manage.py runserver can not use newly compiled sqlite3 lib on CentOS 7

2021-01-20 Thread 'Amitesh Sahay' via Django users
Please read the release notes of the Django version you are using. It will be a 
life saver as well.


Regards,
Amitesh  

On Wednesday, 20 January, 2021, 07:35:14 pm IST, Amitesh Sahay 
 wrote:  
 
 So, this seems to be a version compatibility issue, a a work around you can 
use some other database(mysql, oracle, etc). This cud save ur day and time as 
well.


Regards,
Amitesh 
On Wednesday, 20 January, 2021, 07:32:59 pm IST, panfei  
wrote:  
 
 I have tried, it works in Python 3.6 environment. but I still want to find a 
way (maybe a workaround) to solve this problem.

'Amitesh Sahay' via Django users  于2021年1月20日周三 
下午9:48写道:

Try older version of Python interpreter and see if that works. May be  consider 
using 3.6


Regards,
Amitesh  

On Wednesday, 20 January, 2021, 05:55:32 pm IST, panfei  
wrote:  
 
 I found that, it may not be a Django-related issue, It's more likely a Python 
level issue, but do anyone know how to avoid this problem?:
(venv) [felix@localhost blueprint]$ python
Python 3.9.1 (default, Jan 20 2021, 14:32:50) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> conn = sqlite3.connect(':memory:')
>>> conn.create_function('f', 2, lambda *args: None, deterministic=True)
Traceback (most recent call last):
  File "", line 1, in 
sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher
>>> sqlite3.sqlite_version
'3.34.0'
>>> sqlite3.version
'2.6.0'
>>> 


panfei  于2021年1月20日周三 下午8:03写道:


System environment:
Cent OS 7
Sqlite3 3.34.0 (Compile from source)Python 3.9.1 (Compile from source)
Django 3.1.5 (Pip install)


1. Compile sqlite3:./configure 
--prefix=/home/felix/.local/sqlite/sqlite-3.34.0make && make install
2. Add sqlite3 lib to lib search path:
export LD_LIBRARY_PATH=/home/felix/.local/sqlite/default/libexport 
LD_RUN_PATH=/home/felix/.local/sqlite/default/lib
3. Compile Python 
3.9.1C_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/ 
CPLUS_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/ 
LD_RUN_PATH=/home/felix/.local/sqlite/default/lib ./configure 
--prefix=/home/felix/.local/python/python-3.9.1 --enable-optimizationsmake && 
make install
4. Create a venv and install django and start a demo projectcd /tmp
/home/felix/.local/python/python-3.9.1/bin/python3 -m venv venvsource 
venv/bin/activatepip install djangodjagno-admin startproject democd demo
4 Check sqlite3 lib version (seems to be OK, sqlite_version is 3.34.0)
(venv) [felix@localhost blueprint]$ python manage.py shell
Python 3.9.0 (default, Jan 20 2021, 12:53:25) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.34.0'
>>> sqlite3.version
'2.6.0'
>>> 

5. Run the demo project (cannot find the new sqlite version ? strange.):(venv) 
[felix@localhost blueprint]$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
 line 219, in ensure_connection
    self.connect()
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/asyncio.py",
 line 26, in inner
    return func(*args, **kwargs)
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
 line 200, in connect
    self.connection = self.get_new_connection(conn_params)
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/asyncio.py",
 line 26, in inner
    return func(*args, **kwargs)
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/sqlite3/base.py",
 line 215, in get_new_connection
    create_deterministic_function('django_date_extract', 2, 
_sqlite_datetime_extract)
sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/felix/.local/python/python-3.9.0/lib/python3.9/threading.py", 
line 950, in _bootstrap_inner
    self.run()
  File "/home/felix/.local/python/python-3.9.0/lib/python3.9/threading.py", 
line 888, in run
    self._target(*self._args, **self._kwargs)
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/autoreload.py",
 line 53, in wrapper
    fn(*args, **kwargs)
  File 
"/home/felix/PycharmProjects/blue

Re: python manage.py runserver can not use newly compiled sqlite3 lib on CentOS 7

2021-01-20 Thread 'Amitesh Sahay' via Django users
So, this seems to be a version compatibility issue, a a work around you can use 
some other database(mysql, oracle, etc). This cud save ur day and time as well.


Regards,
Amitesh 
On Wednesday, 20 January, 2021, 07:32:59 pm IST, panfei  
wrote:  
 
 I have tried, it works in Python 3.6 environment. but I still want to find a 
way (maybe a workaround) to solve this problem.

'Amitesh Sahay' via Django users  于2021年1月20日周三 
下午9:48写道:

Try older version of Python interpreter and see if that works. May be  consider 
using 3.6


Regards,
Amitesh  

On Wednesday, 20 January, 2021, 05:55:32 pm IST, panfei  
wrote:  
 
 I found that, it may not be a Django-related issue, It's more likely a Python 
level issue, but do anyone know how to avoid this problem?:
(venv) [felix@localhost blueprint]$ python
Python 3.9.1 (default, Jan 20 2021, 14:32:50) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> conn = sqlite3.connect(':memory:')
>>> conn.create_function('f', 2, lambda *args: None, deterministic=True)
Traceback (most recent call last):
  File "", line 1, in 
sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher
>>> sqlite3.sqlite_version
'3.34.0'
>>> sqlite3.version
'2.6.0'
>>> 


panfei  于2021年1月20日周三 下午8:03写道:


System environment:
Cent OS 7
Sqlite3 3.34.0 (Compile from source)Python 3.9.1 (Compile from source)
Django 3.1.5 (Pip install)


1. Compile sqlite3:./configure 
--prefix=/home/felix/.local/sqlite/sqlite-3.34.0make && make install
2. Add sqlite3 lib to lib search path:
export LD_LIBRARY_PATH=/home/felix/.local/sqlite/default/libexport 
LD_RUN_PATH=/home/felix/.local/sqlite/default/lib
3. Compile Python 
3.9.1C_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/ 
CPLUS_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/ 
LD_RUN_PATH=/home/felix/.local/sqlite/default/lib ./configure 
--prefix=/home/felix/.local/python/python-3.9.1 --enable-optimizationsmake && 
make install
4. Create a venv and install django and start a demo projectcd /tmp
/home/felix/.local/python/python-3.9.1/bin/python3 -m venv venvsource 
venv/bin/activatepip install djangodjagno-admin startproject democd demo
4 Check sqlite3 lib version (seems to be OK, sqlite_version is 3.34.0)
(venv) [felix@localhost blueprint]$ python manage.py shell
Python 3.9.0 (default, Jan 20 2021, 12:53:25) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.34.0'
>>> sqlite3.version
'2.6.0'
>>> 

5. Run the demo project (cannot find the new sqlite version ? strange.):(venv) 
[felix@localhost blueprint]$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
 line 219, in ensure_connection
    self.connect()
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/asyncio.py",
 line 26, in inner
    return func(*args, **kwargs)
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
 line 200, in connect
    self.connection = self.get_new_connection(conn_params)
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/asyncio.py",
 line 26, in inner
    return func(*args, **kwargs)
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/sqlite3/base.py",
 line 215, in get_new_connection
    create_deterministic_function('django_date_extract', 2, 
_sqlite_datetime_extract)
sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/felix/.local/python/python-3.9.0/lib/python3.9/threading.py", 
line 950, in _bootstrap_inner
    self.run()
  File "/home/felix/.local/python/python-3.9.0/lib/python3.9/threading.py", 
line 888, in run
    self._target(*self._args, **self._kwargs)
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/autoreload.py",
 line 53, in wrapper
    fn(*args, **kwargs)
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/core/management/commands/runserver.py",
 line 121, in inner_run
    self.check_migrations()
  File 
"/home/felix/PycharmProjects/blueprint/venv/l

Re: python manage.py runserver can not use newly compiled sqlite3 lib on CentOS 7

2021-01-20 Thread 'Amitesh Sahay' via Django users
Try older version of Python interpreter and see if that works. May be  consider 
using 3.6


Regards,
Amitesh  

On Wednesday, 20 January, 2021, 05:55:32 pm IST, panfei  
wrote:  
 
 I found that, it may not be a Django-related issue, It's more likely a Python 
level issue, but do anyone know how to avoid this problem?:
(venv) [felix@localhost blueprint]$ python
Python 3.9.1 (default, Jan 20 2021, 14:32:50) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> conn = sqlite3.connect(':memory:')
>>> conn.create_function('f', 2, lambda *args: None, deterministic=True)
Traceback (most recent call last):
  File "", line 1, in 
sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher
>>> sqlite3.sqlite_version
'3.34.0'
>>> sqlite3.version
'2.6.0'
>>> 


panfei  于2021年1月20日周三 下午8:03写道:


System environment:
Cent OS 7
Sqlite3 3.34.0 (Compile from source)Python 3.9.1 (Compile from source)
Django 3.1.5 (Pip install)


1. Compile sqlite3:./configure 
--prefix=/home/felix/.local/sqlite/sqlite-3.34.0make && make install
2. Add sqlite3 lib to lib search path:
export LD_LIBRARY_PATH=/home/felix/.local/sqlite/default/libexport 
LD_RUN_PATH=/home/felix/.local/sqlite/default/lib
3. Compile Python 
3.9.1C_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/ 
CPLUS_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/ 
LD_RUN_PATH=/home/felix/.local/sqlite/default/lib ./configure 
--prefix=/home/felix/.local/python/python-3.9.1 --enable-optimizationsmake && 
make install
4. Create a venv and install django and start a demo projectcd /tmp
/home/felix/.local/python/python-3.9.1/bin/python3 -m venv venvsource 
venv/bin/activatepip install djangodjagno-admin startproject democd demo
4 Check sqlite3 lib version (seems to be OK, sqlite_version is 3.34.0)
(venv) [felix@localhost blueprint]$ python manage.py shell
Python 3.9.0 (default, Jan 20 2021, 12:53:25) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.34.0'
>>> sqlite3.version
'2.6.0'
>>> 

5. Run the demo project (cannot find the new sqlite version ? strange.):(venv) 
[felix@localhost blueprint]$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
 line 219, in ensure_connection
    self.connect()
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/asyncio.py",
 line 26, in inner
    return func(*args, **kwargs)
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
 line 200, in connect
    self.connection = self.get_new_connection(conn_params)
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/asyncio.py",
 line 26, in inner
    return func(*args, **kwargs)
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/sqlite3/base.py",
 line 215, in get_new_connection
    create_deterministic_function('django_date_extract', 2, 
_sqlite_datetime_extract)
sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/felix/.local/python/python-3.9.0/lib/python3.9/threading.py", 
line 950, in _bootstrap_inner
    self.run()
  File "/home/felix/.local/python/python-3.9.0/lib/python3.9/threading.py", 
line 888, in run
    self._target(*self._args, **self._kwargs)
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/autoreload.py",
 line 53, in wrapper
    fn(*args, **kwargs)
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/core/management/commands/runserver.py",
 line 121, in inner_run
    self.check_migrations()
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/core/management/base.py",
 line 459, in check_migrations
    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/migrations/executor.py",
 line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/migrations/loader.py",
 line 53, in __init__
    self.build_graph()
  File 
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/migrations/loader.py",
 line 216, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File 

Re: UserManager creation for AbstractUserModel extended MyUser

2021-01-09 Thread 'Amitesh Sahay' via Django users
Did you happen to remove the private method "def _create_user" from your 
models.py?


Regards,
Amitesh  

On Saturday, 9 January, 2021, 08:08:16 pm IST, Vishesh Mangla 
 wrote:  
 
 Oops I guess, my bad messaging style made you miss the last few pieces of my 
messages. Thanks, but that problem is resolved as written in my previous 
message with the working code. Now I require help with the Migrations problem.

On Saturday, January 9, 2021 at 8:00:55 PM UTC+5:30 Amitesh Sahay wrote:

Hello Vishesh, 
Below is from my models.py:
models.py-from django.contrib.auth.base_user import BaseUserManager
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
from django.utils.translation import gettext_lazy as _


class AccountManager(BaseUserManager):
def create_superuser(self, email, password, **extra_fields):
extra_fields.setdefault('is_staff', True)
extra_fields.setdefault('is_superuser', True)
extra_fields.setdefault('is_active', True)

if extra_fields.get('is_staff') is not True:
raise ValueError(_('Superuser must have is_staff=True.'))
if extra_fields.get('is_superuser') is not True:
raise ValueError(_('Superuser must have is_superuser=True.'))
return self.create_user(email, password, **extra_fields)

def create_user(self, email, password, **extra_fields):
if not email:
raise ValueError(_('Enter the email before proceeding'))

email = self.normalize_email(email)
user = self.model(email=email, password=password, **extra_fields)
user.set_password(password)
user.save()
return user


class Shop(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(unique=True)
shop_name = models.CharField(max_length=150)
contact = models.CharField(max_length=10)
State = models.CharField(max_length=100)
district = models.CharField(max_length=100)
location = models.CharField(max_length=100)
is_staff = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)
date_joined = models.DateTimeField(auto_now_add=True)
last_login = models.DateTimeField(null=True)

objects = AccountManager()

USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['shop_name', 'contact', 'is_staff']

def __str__(self):
return str(self.shop_name)
See if that helps you out.


Regards,
Amitesh 

On Saturday, 9 January, 2021, 07:39:18 pm IST, Vishesh Mangla 
 wrote:  
 
 I did paste my `models.py` with the help the help of a dpaste link. 
```class UserManager( BaseUserManager):def _create_user(self, PAN_ID, 
password=None, **extra_fields):"""Creates and saves a User with 
the given email, date ofbirth and password."""if not 
PAN_ID:raise ValueError('Users must have an email address')
extra_fields['email'] = self.normalize_email(extra_fields["email"])user 
= self.model(PAN_ID=PAN_ID, **extra_fields)
user.set_password(password)user.save(using=self._db)
return userdef create_user(self, PAN_ID, password=None, **extra_fields):
extra_fields.setdefault('is_staff', False)
extra_fields.setdefault('is_superuser', False)return 
self._create_user(PAN_ID, password, **extra_fields)def 
create_superuser(self, PAN_ID, password=None, **extra_fields):
extra_fields.setdefault('is_staff', True)
extra_fields.setdefault('is_superuser', True)
if extra_fields.get('is_staff') is not True:raise 
ValueError('Superuser must have is_staff=True.')if 
extra_fields.get('is_superuser') is not True:raise 
ValueError('Superuser must have is_superuser=True.')
return self._create_user(PAN_ID, password, **extra_fields)

```   The following code worked. I used 
https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html
 and the source code from 
https://github.com/django/django/blob/master/django/contrib/auth/models.py.   
Can I get help in the migrations and creating groups? Code is in the dpaste s.
On Saturday, January 9, 2021 at 7:11:23 PM UTC+5:30 Amitesh Sahay wrote:

Could you please paste your models.py

Sent from Yahoo Mail on Android 
 


  On Sat, 9 Jan 2021 at 18:36, Vishesh Mangla wrote:  

https://dpaste.org/Zz5Z

(venv) PS C:\Users\Dell\OneDrive\Desktop\djangodev\mass> python manage.py 
createsuperuser
PAN ID: 6785
Email: s@g
Error: Enter a valid email address.
Email: s...@gmail.com
Name: fjghg
Type: fg
Error: Value 'fg' is not a valid choice.
Type: ADM
Holding: 568
Password: 
Password (again):
This password is too short. It must contain at least 8 characters.
Bypass password validation and create user anyway? [y/N]: y
Traceback (most recent call last):
  File "manage.py", line 22, in 
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File 

Re: UserManager creation for AbstractUserModel extended MyUser

2021-01-09 Thread 'Amitesh Sahay' via Django users
Hello Vishesh, 
Below is from my models.py:
models.py-from django.contrib.auth.base_user import BaseUserManager
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
from django.utils.translation import gettext_lazy as _


class AccountManager(BaseUserManager):
def create_superuser(self, email, password, **extra_fields):
extra_fields.setdefault('is_staff', True)
extra_fields.setdefault('is_superuser', True)
extra_fields.setdefault('is_active', True)

if extra_fields.get('is_staff') is not True:
raise ValueError(_('Superuser must have is_staff=True.'))
if extra_fields.get('is_superuser') is not True:
raise ValueError(_('Superuser must have is_superuser=True.'))
return self.create_user(email, password, **extra_fields)

def create_user(self, email, password, **extra_fields):
if not email:
raise ValueError(_('Enter the email before proceeding'))

email = self.normalize_email(email)
user = self.model(email=email, password=password, **extra_fields)
user.set_password(password)
user.save()
return user


class Shop(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(unique=True)
shop_name = models.CharField(max_length=150)
contact = models.CharField(max_length=10)
State = models.CharField(max_length=100)
district = models.CharField(max_length=100)
location = models.CharField(max_length=100)
is_staff = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)
date_joined = models.DateTimeField(auto_now_add=True)
last_login = models.DateTimeField(null=True)

objects = AccountManager()

USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['shop_name', 'contact', 'is_staff']

def __str__(self):
return str(self.shop_name)
See if that helps you out.


Regards,
Amitesh 

On Saturday, 9 January, 2021, 07:39:18 pm IST, Vishesh Mangla 
 wrote:  
 
 I did paste my `models.py` with the help the help of a dpaste link. 
```class UserManager( BaseUserManager):def _create_user(self, PAN_ID, 
password=None, **extra_fields):"""Creates and saves a User with 
the given email, date ofbirth and password."""if not 
PAN_ID:raise ValueError('Users must have an email address')
extra_fields['email'] = self.normalize_email(extra_fields["email"])user 
= self.model(PAN_ID=PAN_ID, **extra_fields)
user.set_password(password)user.save(using=self._db)
return userdef create_user(self, PAN_ID, password=None, **extra_fields):
extra_fields.setdefault('is_staff', False)
extra_fields.setdefault('is_superuser', False)return 
self._create_user(PAN_ID, password, **extra_fields)def 
create_superuser(self, PAN_ID, password=None, **extra_fields):
extra_fields.setdefault('is_staff', True)
extra_fields.setdefault('is_superuser', True)
if extra_fields.get('is_staff') is not True:raise 
ValueError('Superuser must have is_staff=True.')if 
extra_fields.get('is_superuser') is not True:raise 
ValueError('Superuser must have is_superuser=True.')
return self._create_user(PAN_ID, password, **extra_fields)

```   The following code worked. I used 
https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html
 and the source code from 
https://github.com/django/django/blob/master/django/contrib/auth/models.py.   
Can I get help in the migrations and creating groups? Code is in the dpaste s.
On Saturday, January 9, 2021 at 7:11:23 PM UTC+5:30 Amitesh Sahay wrote:

Could you please paste your models.py

Sent from Yahoo Mail on Android 
 


  On Sat, 9 Jan 2021 at 18:36, Vishesh Mangla wrote:  

https://dpaste.org/Zz5Z

(venv) PS C:\Users\Dell\OneDrive\Desktop\djangodev\mass> python manage.py 
createsuperuser
PAN ID: 6785
Email: s@g
Error: Enter a valid email address.
Email: s...@gmail.com
Name: fjghg
Type: fg
Error: Value 'fg' is not a valid choice.
Type: ADM
Holding: 568
Password: 
Password (again):
This password is too short. It must contain at least 8 characters.
Bypass password validation and create user anyway? [y/N]: y
Traceback (most recent call last):
  File "manage.py", line 22, in 
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File 
"C:\Users\Dell\OneDrive\Desktop\djangodev\venv\lib\site-packages\django\core\management\__init__.py",
 line 401, in execute_from_command_line
    utility.execute()
  File 
"C:\Users\Dell\OneDrive\Desktop\djangodev\venv\lib\site-packages\django\core\management\__init__.py",
 line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"C:\Users\Dell\OneDrive\Desktop\djangodev\venv\lib\site-packages\django\core\management\base.py",
 line 330, in run_from_argv
    

Re: UserManager creation for AbstractUserModel extended MyUser

2021-01-09 Thread 'Amitesh Sahay' via Django users
Could you please paste your models.py

Sent from Yahoo Mail on Android 
 
  On Sat, 9 Jan 2021 at 18:36, Vishesh Mangla wrote: 
  https://dpaste.org/Zz5Z

(venv) PS C:\Users\Dell\OneDrive\Desktop\djangodev\mass> python manage.py 
createsuperuser
PAN ID: 6785
Email: s@g
Error: Enter a valid email address.
Email: s...@gmail.com
Name: fjghg
Type: fg
Error: Value 'fg' is not a valid choice.
Type: ADM
Holding: 568
Password: 
Password (again):
This password is too short. It must contain at least 8 characters.
Bypass password validation and create user anyway? [y/N]: y
Traceback (most recent call last):
  File "manage.py", line 22, in 
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File 
"C:\Users\Dell\OneDrive\Desktop\djangodev\venv\lib\site-packages\django\core\management\__init__.py",
 line 401, in execute_from_command_line
    utility.execute()
  File 
"C:\Users\Dell\OneDrive\Desktop\djangodev\venv\lib\site-packages\django\core\management\__init__.py",
 line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"C:\Users\Dell\OneDrive\Desktop\djangodev\venv\lib\site-packages\django\core\management\base.py",
 line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File 
"C:\Users\Dell\OneDrive\Desktop\djangodev\venv\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py",
 line 79, in execute
    return super().execute(*args, **options)
  File 
"C:\Users\Dell\OneDrive\Desktop\djangodev\venv\lib\site-packages\django\core\management\base.py",
 line 371, in execute
    output = self.handle(*args, **options)
  File 
"C:\Users\Dell\OneDrive\Desktop\djangodev\venv\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py",
 line 189, in handle
    
self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
  File "C:\Users\Dell\OneDrive\Desktop\djangodev\mass\base\models.py", line 25, 
in create_superuser
    return super()._create_user(PAN_ID,  password, **extra_fields)
AttributeError: 'super' object has no attribute '_create_user'


-- 
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/b4ff8445-8ed7-4d29-8ae6-73f3b1f8295fn%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/2075996235.129575.1610199622793%40mail.yahoo.com.


Reg: django termination

2021-01-06 Thread 'Amitesh Sahay' via Django users
Hi All,
please somebody reply on the below link
why the django admin console is terminating the web server automatically?  
|  
|   
|   
|   ||

   |

  |
|  
|   |  
why the django admin console is terminating the web server automatically?
 
I have created a custom User model as I wanted to use email as unique 
constraint. Below is the code snippetmodels.pyfrom django.db import modelsfrom 
django.contrib.auth.base_user import
  |   |

  |

  |

  
Regards,Amitesh

Sent from Yahoo Mail on Android

-- 
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/1493392368.1334172.1610002343865%40mail.yahoo.com.


reg: Custom User model

2021-01-06 Thread 'Amitesh Sahay' via Django users
Hi, 
I have created a custom User model as show below
models.py



Regards,
Amitesh Sahay91-750 797 8619

-- 
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/1471470402.6238134.1609944739516%40mail.yahoo.com.


reg: Django resource requirement for a Start-up project.

2020-11-21 Thread 'Amitesh Sahay' via Django users
Dear Members. 
We are launching a start-up in some month. A  basic website on Django platform 
have already been developed. However, we still need some more features to be 
developed and enabled on the web application.
Any candidate who are interested. Please connect with me  on 
amitesh.sa...@yahoo.com with your full name and direct contact number along 
with below details.
Requirements:
1) 6 month - 2 years in Django.2) having good knowledge on developing 
algorithm.3) 1 - 2 years in Python.4) 1 - 2 years in HTML, CSS, Jinja 
templating.
Even freshers are considered 
Note: 
1) Candidate who would be eligible for the project has to sign a Non- 
Disclosure Agreement.2) Very good compensation.3) The candidate would be 
working very closely with the CTO of the organization. 4) we would be more than 
glad to absorb the candidate as a full time employee after certain time 
period.5) There is no such strict interview process. We are looking for a 
candidate who can complete the task irrespective of the work experience.
Please do not hesitate to ask any question if any. We would be more than glad 
to make you comfortable and give right environment to work on the development 
work.


Regards,
Amitesh sahayamitesh.sa...@yahoo.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/1395512443.181194.1606017916080%40mail.yahoo.com.


Re: Help:What is the problem in this code?

2020-09-14 Thread 'Amitesh Sahay' via Django users
have you configured the django env in virtual env, and are you trying to 
execute the commands outside the virtual env?


Regards,
Amitesh
On Sunday, 13 September, 2020, 09:39:59 pm IST, Kasper Laudrup 
 wrote:  
 
 Hi Hassan,

There's nothing wrong with this code. It's just that it's only valid in 
Python 3, so you're probably using a Python 2 interpreter.

Without really knowing what you're trying to do, I'd suggest you start 
out by following the "getting started" documentation carefully instead 
of getting lost in the code generated by Django.

Kind regards,

Kasper Laudrup



On 13/09/2020 17.35, Hassan Shuvo wrote:
> manage.PNGcode.PNG
> 
> -- 
> 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/d3fa106f-2db2-4c63-a12e-178f5bce9ca9n%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/e33aee7e-cba1-2d9a-c647-af1eeadcdaf6%40stacktrace.dk.
  

-- 
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/407688207.1597212.1600139051632%40mail.yahoo.com.


Re: 404 error

2020-09-12 Thread 'Amitesh Sahay' via Django users
You are trying "http://127.0.0.1:8000/music//;
try something like
http://127.0.0.1:8000//



Regards,
Amitesh  

On Saturday, 12 September, 2020, 12:55:57 pm IST, Kunal Solanke 
 wrote:  
 
 I think he have created the music url,But the {{album_id}} is not properly 
passed as context from view.

On Sat, Sep 12, 2020, 12:52 'Amitesh Sahay' via Django users 
 wrote:

At the first glance, I think you havn't created URL pattern for "music". May 
bejust saying.


Regards,
Amitesh  

On Saturday, 12 September, 2020, 12:47:56 pm IST, Spyke Lionel 
 wrote:  
 
 I have this urlpatterns..
urlpatterns = [    path('', views.index, name='index'),    
path('/', views.detail, name='detail'),]
my index.html looks like this
Albums to display    {% for album in all_albums %}     {{ album.album_title }}    {% endfor 
%}#my index.html simply displays my albums. and the above works just fine
my detail.html looks like this
{{ album }}#and it works just fine too
my views.py looks like this
def index(request):    all_albums = Album.objects.all()    return 
render(request, 'music/index.html', {'all_albums': all_albums})
def detail(request, album_id):    try:        album = 
Album.objects.get(pk=album_id)    except Album.DoesNotExist:        raise 
Http404("Album does not exist")    return render(request, 'music/detail.html', 
{'album': album})
#when ever I click on an album link to get the album details, I get the 404 
below:
Page not found (404)Request Method: GETRequest URL: 
http://127.0.0.1:8000/music//
Using the URLconf defined in website.urls, Django tried these URL patterns, in 
this order:1. admin/2. music/ [name='index']3. music/ / 
[name='detail']The current path, music//, didn't match any of these.
in my detail funtion in views.py, at first I used on request as an argument and 
it worked just fine to give me the album details (which returned only the album 
id number), but when i added album_id, so as to get the album details, I got an 
error. saying music// not found. Now I don't understand how the last forward 
slash(/) was added.can I get the explaination to this. 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/36d25ae2-7e58-43dc-ad0f-83da9e55e526n%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/230500518.1084108.1599895276220%40mail.yahoo.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/CAOecAnyAVZf16m20HGu0KQp8_yrS9kzB8pfkMMyf55Y3tJY0xQ%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/1325467128.1082007.1599895682642%40mail.yahoo.com.


Re: 404 error

2020-09-12 Thread 'Amitesh Sahay' via Django users
At the first glance, I think you havn't created URL pattern for "music". May 
bejust saying.


Regards,
Amitesh  

On Saturday, 12 September, 2020, 12:47:56 pm IST, Spyke Lionel 
 wrote:  
 
 I have this urlpatterns..
urlpatterns = [    path('', views.index, name='index'),    
path('/', views.detail, name='detail'),]
my index.html looks like this
Albums to display    {% for album in all_albums %}     {{ album.album_title }}    {% endfor 
%}#my index.html simply displays my albums. and the above works just fine
my detail.html looks like this
{{ album }}#and it works just fine too
my views.py looks like this
def index(request):    all_albums = Album.objects.all()    return 
render(request, 'music/index.html', {'all_albums': all_albums})
def detail(request, album_id):    try:        album = 
Album.objects.get(pk=album_id)    except Album.DoesNotExist:        raise 
Http404("Album does not exist")    return render(request, 'music/detail.html', 
{'album': album})
#when ever I click on an album link to get the album details, I get the 404 
below:
Page not found (404)Request Method: GETRequest URL: 
http://127.0.0.1:8000/music//
Using the URLconf defined in website.urls, Django tried these URL patterns, in 
this order:1. admin/2. music/ [name='index']3. music/ / 
[name='detail']The current path, music//, didn't match any of these.
in my detail funtion in views.py, at first I used on request as an argument and 
it worked just fine to give me the album details (which returned only the album 
id number), but when i added album_id, so as to get the album details, I got an 
error. saying music// not found. Now I don't understand how the last forward 
slash(/) was added.can I get the explaination to this. 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/36d25ae2-7e58-43dc-ad0f-83da9e55e526n%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/230500518.1084108.1599895276220%40mail.yahoo.com.


Re: NGINX + GUNICORN

2020-09-10 Thread 'Amitesh Sahay' via Django users
Please make sure that gunicorn.service file has same entry of project dir path 
as nginx.


Regards,
Amitesh 

On Thursday, 10 September, 2020, 01:09:20 pm IST, Giovanni Silva 
 wrote:  
 
 Dears, 
can anyone help-me to configure a NGINX + GUNICORN to multiple projects?
for the first project everything is work fine, for the second project, I create 
a new .socket file and new service file.. 
The nginx and gunicorn is running, but when I try to access my site, appears 
the default page of nginx.. 
Any suggestions??
Best regards,
-- 
Giovanni Silva(31) 9 9532-1877

-- 
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/CABO2r9dNQd24yM%3DDD-fjy9dNjV5GigYxxwNNFjtAivs5xfsKRQ%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/2098253062.527392.1599724310808%40mail.yahoo.com.


Re: Sources for learning django

2020-08-23 Thread 'Amitesh Sahay' via Django users
Yo start with you can implement the Django in - built authentication system . 
You will learn a lot

Sent from Yahoo Mail on Android 
 
  On Fri, 21 Aug 2020 at 4:00, Mohamed Ghoneim wrote:   
Hey guys, 
can any one tell me  name of books , websites or youtube channels  which are 
good to learn django .
i also want to ask ,how long does it take to learn django ?
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/5acb085e-246d-4802-9d23-b87b501918c9n%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/1482317931.3525134.1598216714045%40mail.yahoo.com.


Re: type error

2020-08-18 Thread 'Amitesh Sahay' via Django users
Hi, 
I have developed a django website for my company. Its schoolnskill.com. For now 
its not much to look at. But due to other work I am not able to add 
enhancements to it. 
1) I need to add payment gateway(Paytm and Paypal)2) Create one more model and 
then create respective forms.py and views.py and integrate it with frontend.( I 
can give more clarity).
Please let me know if anybody is up for it


Regards,
Amitesh 

On Tuesday, 18 August, 2020, 07:05:42 pm IST, Liu Zheng 
 wrote:  
 
 hi,
What’s the type and value of that variable “value”? It would be helpful to 
print out value and type(value) right in front of this line where error occurs.
BestZheng
On Tue, 18 Aug 2020 at 9:21 PM, Rostislav Kornatsky  
wrote:

Hi, my name is Rostislav and I'm learning Django too, We could collaborate and 
learn it together:)

пт, 14 авг. 2020 г. в 21:50, Peter Kirieny :

hello, can somebody help with this please
    match = datetime_re.match(value)
TypeError: expected string or bytes-like object

I've made migrations but now i can't migrate, it brings the above error instead









-- 


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/CAL8t8epXffzY6L6ox8whRQuf16n1bGOuQ9pGnHEWPt_XQBahqg%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/CAPe0rWvVEVE%2B-3vaSq5VCWmQFBY4T5FTn2tLVs_hKD%3DfHv6CaA%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/CAGQ3pf9_TLkj8%3D6qD9%2BNYU3r1YnepGc-isMai2G9D-PLj4Lqfw%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/238851525.2088150.1597816322801%40mail.yahoo.com.


[no subject]

2020-08-12 Thread 'Amitesh Sahay' via Django users
probably, you can implement binary search algorithm


Regards,
Amitesh  

On Thursday, 13 August, 2020, 08:28:02 am IST, ROHINI PUNDE 
 wrote:  
 
 Hi, I want to do sorting, searching and paging in my crud operations,I am not 
getting exactly what can I do easily with python and django.please give me 
suggestions

-- 
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/CAO9_9ZbbXbcYBZK5i5%3DQSS%2BaO_3ShLNzq1HUz5AfiNdH%3DCwHdg%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/800650729.736718.1597289790123%40mail.yahoo.com.


Re: Problem in user creation

2020-08-04 Thread 'Amitesh Sahay' via Django users
Post your signal here to check




On Tuesday, 4 August, 2020, 11:07:56 pm IST, sonam pankaj 
 wrote:  
 
 We have already used signals. still it escaped to make one of the user

On Tue, Aug 4, 2020 at 9:35 PM neeraj garg  wrote:

You could use django signals which will keep the models in sync.
On Tue, Aug 4, 2020, 9:16 PM sonam pankaj  wrote:

   

  Hi,  there is a problem when doing profile model using 
contrib.auth , sometimes profile is created without user so they went out of 
sync. How to make sure that user_id and Profile_id remain in sync. 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/c08a9b60-25a3-40d4-9fb6-e1d4a40e4038o%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/CAGR%2BspeEyGRKjcuGphNGA%2B57zSh5WxOpttHsAbCZv4-tyTRnWQ%40mail.gmail.com.



-- 
Sonam 
Lead Software EngineerSolinas IntegrityIIT Madras


-- 
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/CAEUYDiTp6oAUx1X%3DjhB%2B4x9dBhejDBhF9yk85LqYe2Q%3Di7BOqQ%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/636724511.78164.1596601179749%40mail.yahoo.com.


Re: Can't get rid of "CSRF verification failed. Request aborted.: when submit form with nothing selected

2020-07-30 Thread 'Amitesh Sahay' via Django users
Hi, 
I am glad that I could help you. Cheerz


Regards,
Amitesh 

On Friday, 31 July, 2020, 01:16:14 am IST, Isha Thakur 
 wrote:  
 
 #yiv1468174970 P {margin-top:0;margin-bottom:0;}Hi, 
I think, it can help you.

You should never compare the complete HTML content. Just check the 
functionalities. In case you need disabling the csrf at any cost, following 
logic should help I guess.

In your views.py file, add the following package

from django.views.decorators.csrf import csrf_exempt

Then just before the function definintion, in which you are performing your 
checks, add this snippet:

@csrf_exempt

This will disable the default verification of csrf. Even if your incoming 
request has a hidden csrf token, your server function will completely ignore 
it. This should do the trick of disabling the csrf.

https://stackoverflow.com/questions/28983158/how-to-disable-csrf-in-testing-django/52185276

Regards
|  | how to disable csrf in testing django? - Stack OverflowYou should never 
compare the complete HTML content. Just check the functionalities. In case you 
need disabling the csrf at any cost, following logic should help I guess.. In 
your views.py file, add the following package. from 
django.views.decorators.csrf import csrf_exemptstackoverflow.com |



From: django-users@googlegroups.com  on behalf 
of coolguy 
Sent: July 29, 2020 10:05 PM
To: Django users 
Subject: Re: Can't get rid of "CSRF verification failed. Request aborted.: when 
submit form with nothing selected By default, Django checks for the CSRF token 
in all POST requests. Remember to include the csrf_token tag in all forms that 
are submitted via POST.
Please place csrf_token in  tag. You have placed it outside of form tag.
On Wednesday, July 29, 2020 at 9:57:41 PM UTC-4, Christian Seberino wrote:
Here is my template...
{% extends "html_base" %}
{% block body_elements %}


        
                UPDATE STATUSES
                
                        {% for e in both %}
                                
                                        
                                                {{e.0.customer.first}}
                                                {{e.0.customer.last}}
                                        
                                        
                                                {{e.0.date|date:"Y-m-d"}}
                                                 
                                                 
                                                 
                                                {{e.0.time|time:"h:i A"}}
                                        
                                        {{e.1}} Completed
                                
                        {% endfor %}
                
                
        

        Go Back To Admin Page

        {% csrf_token %}


{% endblock %}


Here is the view
def admin_status(request):
        appts = [e for e in APPT.objects.all() if e.status != "Completed"]
        appts = sorted(appts,
                       key = lambda a : a.customer.last + a.customer.first +   \
                                                    str(a.date) + str(a.time))
        if request.method == "POST":
                form = grandmas4hire.forms. StatusForm(request.POST)

                if form.is_valid():                        # Need to enter more 
code here when this page works...
                        reply = django.shortcuts.redirect("/ admin_status")
                else:
                        both  = [(e, form.fields[str(e.id)]) for e in appts]
                        reply = django.shortcuts.render( request,
                                                        "admin_status.html",
                                                        {"both" : both})
        else:
                form  = grandmas4hire.forms. StatusForm()
                both  = [(e, form[str(e.id)]) for e in appts]
                reply = django.shortcuts.render( request,
                                                "admin_status.html",
                                                {"both" : both})

        return reply


Here is the dynamic form StatusForm
class StatusForm(django.forms.Form):
        def __init__(self, *args, **kwargs):
                super().__init__(*args, **kwargs)
                for e in grandmas4hire.models. Appointment.objects.all():
                        self.fields[str(e.id)] =                               \
                                   django.forms.BooleanField( required = False)


(I need to make a dynamic form because I needed 1 field for each Appointment 
object.)
Chris


-- 
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 
todjango-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 

Re: help on extending user model using django rest_framework

2020-07-30 Thread 'Amitesh Sahay' via Django users
Where is your "CustomUser" defined? D you think it could be 
user = models.OneToOneField(User, ..)


Regards,
Amitesh  

On Thursday, 30 July, 2020, 03:59:59 pm IST, ola neat 
 wrote:  
 
 good day fellaz, i'm working on extending my user model to enable user create 
a profile but i'm getting an error i dont seem to understand, below are my code 
and err msg 
thnks 


-- 
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/CAHLKn7303fjWtwatCifjxdDp78a1LfT7kW-4W1GPOboWNys6JA%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/619227809.7734742.1596106206524%40mail.yahoo.com.


Re: Django3 runserver error

2020-07-30 Thread 'Amitesh Sahay' via Django users
It seems to me as if there is a mismatch of some in-built functionality. Can't 
say for exact though. Did you follow the migration rules from one version to 
another ?


Regards,
Amitesh  

On Thursday, 30 July, 2020, 03:22:51 pm IST, Thierry DECKER 
 wrote:  
 
 The resolve() method dose not have the strict parameter anymore.
Regards
Le jeu. 30 juil. 2020 à 11:25, Mira  a écrit :

Hi All,I recently upgraded Django from 2.2 to 3 on my MacOS10.13.I am using 
Python 3.6 and My Application was working fine with Django 2.2 but now i am 
getting below error.
Any help related with this topic would be greatly appreciated.

$>python3 manage.py runserver

Watching for file changes with StatReloader

Performing system checks...




Traceback (most recent call last):

  File "manage.py", line 22, in 

    execute_from_command_line(sys.argv)

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py",
 line 401, in execute_from_command_line

    utility.execute()

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py",
 line 395, in execute

    self.fetch_command(subcommand).run_from_argv(self.argv)

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py",
 line 328, in run_from_argv

    self.execute(*args, **cmd_options)

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
 line 60, in execute

    super().execute(*args, **options)

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py",
 line 369, in execute

    output = self.handle(*args, **options)

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
 line 95, in handle

    self.run(**options)

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
 line 102, in run

    autoreload.run_with_reloader(self.inner_run, **options)

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
 line 599, in run_with_reloader

    start_django(reloader, main_func, *args, **kwargs)

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
 line 584, in start_django

    reloader.run(django_main_thread)

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
 line 299, in run

    self.run_loop()

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
 line 305, in run_loop

    next(ticker)

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
 line 345, in tick

    for filepath, mtime in self.snapshot_files():

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
 line 361, in snapshot_files

    for file in self.watched_files():

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
 line 260, in watched_files

    yield from iter_all_python_module_files()

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
 line 105, in iter_all_python_module_files

    return iter_modules_and_files(modules, frozenset(_error_files))

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
 line 141, in iter_modules_and_files

    resolved_path = path.resolve(strict=True).absolute()

TypeError: resolve() got an unexpected keyword argument 'strict'

udaysingh@udays-MacBook-Pro:~/Django/dreamProj>


-- 
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/CAANDXNtvg9sP5OqLktcECco1MhpV0%3DcMgYCKvAF0TLXAH9bpog%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/CAP0vuur1YSp4ptXz%2BnLYAR7adzKLT%2BDRgSXmvvoWa-7DcR2PuQ%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 

reg: error after I update my user profile page successfully

2020-07-30 Thread 'Amitesh Sahay' via Django users
Hello All, 
I have been facing a very notorious issue. I say notorious because, I do not 
see any issue with my back-end functionality.
I have developed a method to update the default User model field(email), and 
other extended User model(custom fields like country, state, phone etc).
Below is the method:
@login_required(login_url="/login/")
def editUserProfile(request):
if request.method == "POST":
form = UserProfileUpdateForm(request.POST, instance=request.user)  # 
default user profile update
obj = UserProfile.objects.get(user__id=request.user.id)
form1 = UserProfileForm(request.POST or None, instance=obj)

if form.is_valid() and form1.is_valid():
obj.Photo = form1.cleaned_data['Photo']
obj.dob = form1.cleaned_data['dob']
obj.country = form1.cleaned_data['country']
obj.State = form1.cleaned_data['State']
obj.District = form1.cleaned_data['District']
obj.phone = form1.cleaned_data['phone']
form.save()
form1.save()
messages.success(request, f'updated successfully')
return redirect('/profile1')
else:
messages.error(request, f'Please correct the error below.')
else:
form = UserProfileUpdateForm(instance=request.user)
form1 = UserProfileUpdateForm(instance=request.user)
return render(request, "authenticate\\editProfilePage.html", {'form': form, 
'form1': form1})The surprising part is that I am able to perform the user 
profile update successfully. 
So, I have issues as below:
In the first glance I do not see any issue immediately as my purpose of 
updating the profile is successful. However, to test, after I update a user 
profile I logout the user which redirects me to login page, and there I see 
error "Please correct the error below." which is coming from the "else" part of 
the update method. I also see a message "updated successfully" on the same 
login screen which is coming from the "if" part of the update method 
(screenshot attached -- update_error3).
So, I have below observations:
My update method "editUserProfile" is somehow calling the inner most "if - 
else" together.I think the issue lies in the HTML page. I could say this 
because when I click on the "update" button from the profile page, I see 
"email" field appearing twice on the screen and the "update" button to insert 
the data to database(screenshot attached -- update_error1).Now, I could see the 
rest of the fields only after I click on the "update" button further(screenshot 
attached -- update_error2). Furthermore, this is when I enter all my details 
and when I click on the "update" button, the data get saved successfully in the 
database and redirected to the profile page with the new data.Finally, I think 
the issue is something related to the HTML code for the appearance of the 
"email" and other fields. May be I am wrong. 
I am also not able to understand the cause of the error " Please correct the 
error below"

{% load static %}
{% block content %}


Edit Profile
   
  {% csrf_token %}

  {% if form.errors and form1.errors %}
{% if messages %}

  {% for message in messages %}
  
   {{ message }} {{form.errors}}
  
  {% endfor %}

{% endif %}
 
  {% endif %}
 {{ form.as_p }}
 {{ form1.as_p }}






  
   

   

{% endblock %}I have tried many things, but none of them working. Kindly help 
me debug the issue.Do let me know if more information is needed.


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/155395458.500875.1596091914033%40mail.yahoo.com.


Re: Can't get rid of "CSRF verification failed. Request aborted.: when submit form with nothing selected

2020-07-29 Thread 'Amitesh Sahay' via Django users
Generally, {% csrf_token %} is written just below the opening  tag. I 
mean, not sure if this has anything to do with your issue. Others may confirm 
as well


Regards,
Amitesh 

On Thursday, 30 July, 2020, 07:26:21 am IST, Christian Seberino 
 wrote:  
 
 Here is my template...
{% extends "html_base" %}
{% block body_elements %}


        
                UPDATE STATUSES
                
                        {% for e in both %}
                                
                                        
                                                {{e.0.customer.first}}
                                                {{e.0.customer.last}}
                                        
                                        
                                                {{e.0.date|date:"Y-m-d"}}
                                                 
                                                 
                                                 
                                                {{e.0.time|time:"h:i A"}}
                                        
                                        {{e.1}} Completed
                                
                        {% endfor %}
                
                
        

        Go Back To Admin Page

        {% csrf_token %}


{% endblock %}


Here is the view
def admin_status(request):
        appts = [e for e in APPT.objects.all() if e.status != "Completed"]
        appts = sorted(appts,
                       key = lambda a : a.customer.last + a.customer.first +   \
                                                    str(a.date) + str(a.time))
        if request.method == "POST":
                form = grandmas4hire.forms.StatusForm(request.POST)

                if form.is_valid():                        # Need to enter more 
code here when this page works...
                        reply = django.shortcuts.redirect("/admin_status")
                else:
                        both  = [(e, form.fields[str(e.id)]) for e in appts]
                        reply = django.shortcuts.render(request,
                                                        "admin_status.html",
                                                        {"both" : both})
        else:
                form  = grandmas4hire.forms.StatusForm()
                both  = [(e, form[str(e.id)]) for e in appts]
                reply = django.shortcuts.render(request,
                                                "admin_status.html",
                                                {"both" : both})

        return reply


Here is the dynamic form StatusForm
class StatusForm(django.forms.Form):
        def __init__(self, *args, **kwargs):
                super().__init__(*args, **kwargs)
                for e in grandmas4hire.models.Appointment.objects.all():
                        self.fields[str(e.id)] =                               \
                                   django.forms.BooleanField(required = False)


(I need to make a dynamic form because I needed 1 field for each Appointment 
object.)
Chris

-- 
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/CAG5-5i%2BJC3tOHr3T-a8D6E9Cy2yEohTZOR_Z3HWVTNUtoLnEBg%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/725525470.7515030.1596074301490%40mail.yahoo.com.


REG: django form rendering query

2020-05-10 Thread 'Amitesh Sahay' via Django users
Hello All,
I have a website, which is up and running. No issues at all. 
My Query:
I have a form which users could only see once they are successfully logged in. 
Currently, it have just 5 mandatory fields. However, going forward, I have to 
incorporate more 30 fields. So it could be a mess if I put everything in one 
single page.
Therefore, I wanted to distribute the fields among 4 to 5 web pages based on 
the categories having "next" button on all the web pages, and  "review" and 
"submit" button in the last web page..
Of course I need to alter my model to accommodate those extra fields. However, 
do I need to make any changes in my POST view method? Or such feature has to be 
coded in the front-end templates?
I hope I am clear with my queries.


Regards,
Amitesh

-- 
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/1517354123.696932.1589134634131%40mail.yahoo.com.


Re: How to send dict to template and use it

2020-05-07 Thread 'Amitesh Sahay' via Django users
Your view seems to have incorrect render.

Sent from Yahoo Mail on Android 
 
  On Thu, 7 May 2020 at 11:25, Mohsen Pahlevanzadeh 
wrote:   I have the following view function:

def index(request, question_id):
    latest_question_list = User.objects.all() #Post.objects.all()
    template = loader.get_template('posts/index.html')
    context = {
          'latest_question_list': latest_question_list,
      }
    return HttpResponse(template.render(context))
#
And the following template:

{% if latest_question_list %}

          salaam
          {{ latest_question_list }}
 {% endif %}
###

I see the following result in my browser:
#

salaam
]>


##

How Can I some field in my Queryset in template?

-- 
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/CAJFFGZLhqwkvNVbHtGoU2zG5HdNjy-xbL7NbSTWJxfN0tnaZKQ%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/1903469156.1738920.1588832205464%40mail.yahoo.com.


Re: reg: User model data missing from web page

2020-05-06 Thread 'Amitesh Sahay' via Django users
Hello Chetan,
I got the issue resolved. Below are the correct views:
def userprofileview(request):  # Authenticated user filling the form to 
complete the registration
if request.method == 'POST':
form = UserProfileForm(request.POST, request.FILES)
if form.is_valid():
pr = UserProfile()
pr.user = User.objects.get(id=request.user.id)
pr.dob = form.cleaned_data['dob']
pr.country = form.cleaned_data['country']
pr.State = form.cleaned_data['State']
pr.District = form.cleaned_data['District']
pr.phone = form.cleaned_data['phone']
pr.save()
messages.success(request, f'Profile has been updated successfully')
return redirect('/profile')
else:
messages.error(request, AssertionError)
else:
form = UserProfileForm()
return render(request, 'authenticate\\bolo.html', context={'form': form})

@login_required
def profile_page(request):  # Fetching data from DB to show user's complete 
profile page
data = get_object_or_404(UserProfile, user=request.user)
#data2 = get_object_or_404(User, user=request.user)
data2 = User.objects.get(id = request.user.id)
context = {'data': data, 'data2': data2}
return render(request, 'authenticate\\profile.html', locals())



Regards,
Amitesh 

On Wednesday, 6 May, 2020, 10:34:05 am IST, 'Amitesh Sahay' via Django 
users  wrote:  
 
 Hello Chetan, 
Below is how I have created the forms.
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from .models import UserProfile
from django import forms


class SignUpForm(UserCreationForm):
email = forms.EmailField()
first_name = forms.CharField(max_length=100)
last_name = forms.CharField(max_length=100)

class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email', 'password1', 
'password2')


class UserProfileForm(forms.ModelForm):
Photo = forms.FileField( max_length=100)  
#widget=forms.ClearableFileInput(attrs={'multiple': True}),
dob = forms.DateField(widget=forms.TextInput(attrs={'type': 'date'}))
country = forms.CharField(max_length=100)
State = forms.CharField(max_length=100)
District = forms.CharField(max_length=100)
phone = forms.CharField(max_length=10)

class Meta:
model = UserProfile
fields = ('Photo', 'dob', 'country', 'State', 'District', 'phone')
I hope that helps. Please let me know. Just to let you know that there was a 
time during the development when I could only see the User model data on my 
page, but none from the UserProfile model. During the debug process I have made 
changes in both the files over the last couple of weeks, so now I have reached 
to the point where I can see only the UserProfile data.
Just wanted to give you some insight.


Regards,
Amitesh 

On Wednesday, 6 May, 2020, 12:11:32 am IST, 'Amitesh Sahay' via Django 
users  wrote:  
 
 Hi Chetan,
The default user model already has those three fields, right? And since I have 
extended the  User as a onetoone field inside the UserProfile model, so 
shouldn't that work? I mean, that's my understanding. May be I am wrong. Let me 
know, just for the sake of clarity.
Right now I don't have access to my system. I will send the code snippet of the 
forms.py, may be then you can give more inputs
Thank you so much for your time though
Amitesh
Sent from Yahoo Mail on Android 
 
  On Tue, 5 May 2020 at 23:32, Chetan Ganji wrote:   Hi 
Amitesh,

Assuming you are using model forms in django without any customisation, as 
UserProfile model does not have first_name, last_name and email field, 
reading the first_name from cleaned_data is failing. 
To solve it, you have to add 3 extra fields in the UserProfileForm i.e. 
first_name, last_name and email, and pop them before saving the form.
also save these three fields on the user model. 
request.user.first_name = form.cleaned_data.pop('first_name')
request.user.save()

form.save()
Cheers!

Regards,Chetan Ganji+91-900-483-4183ganji.chetan@gmail.comhttp://ryucoder.in


On Tue, May 5, 2020 at 10:32 PM 'Amitesh Sahay' via Django users 
 wrote:

Hello Chetan,
I was doing some random test, so I put "User" there. It is not the part of the 
original code. 
Below is models.py
from django.db import modelsfrom django.urls import reversefrom 
django.contrib.auth.models import User

class UserProfile(models.Model):    user = models.OneToOneField(User, 
on_delete=models.CASCADE)    Photo = 
models.FileField(upload_to='documents/%Y/%m/%d)    uploaded_at = 
models.DateTimeField(auto_now_add=True)    dob = 
models.DateField(max_length=20)    country = models.CharField(max_length=100)   
 State = models.CharField(max_length=100)    District = 
models.CharField(max_length=100)    phone = models.CharField(max_length=10)
    def get_absolute_url(self):        return reverse('profile', kwargs={'id'

Re: reg: User model data missing from web page

2020-05-05 Thread 'Amitesh Sahay' via Django users
Hello Chetan, 
Below is how I have created the forms.
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from .models import UserProfile
from django import forms


class SignUpForm(UserCreationForm):
email = forms.EmailField()
first_name = forms.CharField(max_length=100)
last_name = forms.CharField(max_length=100)

class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email', 'password1', 
'password2')


class UserProfileForm(forms.ModelForm):
Photo = forms.FileField( max_length=100)  
#widget=forms.ClearableFileInput(attrs={'multiple': True}),
dob = forms.DateField(widget=forms.TextInput(attrs={'type': 'date'}))
country = forms.CharField(max_length=100)
State = forms.CharField(max_length=100)
District = forms.CharField(max_length=100)
phone = forms.CharField(max_length=10)

class Meta:
model = UserProfile
fields = ('Photo', 'dob', 'country', 'State', 'District', 'phone')
I hope that helps. Please let me know. Just to let you know that there was a 
time during the development when I could only see the User model data on my 
page, but none from the UserProfile model. During the debug process I have made 
changes in both the files over the last couple of weeks, so now I have reached 
to the point where I can see only the UserProfile data.
Just wanted to give you some insight.


Regards,
Amitesh 

On Wednesday, 6 May, 2020, 12:11:32 am IST, 'Amitesh Sahay' via Django 
users  wrote:  
 
 Hi Chetan,
The default user model already has those three fields, right? And since I have 
extended the  User as a onetoone field inside the UserProfile model, so 
shouldn't that work? I mean, that's my understanding. May be I am wrong. Let me 
know, just for the sake of clarity.
Right now I don't have access to my system. I will send the code snippet of the 
forms.py, may be then you can give more inputs
Thank you so much for your time though
Amitesh
Sent from Yahoo Mail on Android 
 
  On Tue, 5 May 2020 at 23:32, Chetan Ganji wrote:   Hi 
Amitesh,

Assuming you are using model forms in django without any customisation, as 
UserProfile model does not have first_name, last_name and email field, 
reading the first_name from cleaned_data is failing. 
To solve it, you have to add 3 extra fields in the UserProfileForm i.e. 
first_name, last_name and email, and pop them before saving the form.
also save these three fields on the user model. 
request.user.first_name = form.cleaned_data.pop('first_name')
request.user.save()

form.save()
Cheers!

Regards,Chetan Ganji+91-900-483-4183ganji.chetan@gmail.comhttp://ryucoder.in


On Tue, May 5, 2020 at 10:32 PM 'Amitesh Sahay' via Django users 
 wrote:

Hello Chetan,
I was doing some random test, so I put "User" there. It is not the part of the 
original code. 
Below is models.py
from django.db import modelsfrom django.urls import reversefrom 
django.contrib.auth.models import User

class UserProfile(models.Model):    user = models.OneToOneField(User, 
on_delete=models.CASCADE)    Photo = 
models.FileField(upload_to='documents/%Y/%m/%d)    uploaded_at = 
models.DateTimeField(auto_now_add=True)    dob = 
models.DateField(max_length=20)    country = models.CharField(max_length=100)   
 State = models.CharField(max_length=100)    District = 
models.CharField(max_length=100)    phone = models.CharField(max_length=10)
    def get_absolute_url(self):        return reverse('profile', kwargs={'id': 
self.id})
Kindly give me the modified code that you think would work. 


Regards,
Amitesh 

On Tuesday, 5 May, 2020, 09:24:58 pm IST, Chetan Ganji 
 wrote:  
 
 Hi Amitesh, 
If you post the models, then only someone will be able to give you exact 
solution.

Couple of things I noticed. 
How is this even working??You have not defined User variable in the function?? 
If its the default User model, how would passing it to UserProfile will help in 
your scenario??pr = UserProfile(User)

You dont need this line as it is already available as request.user.  Why do you 
want to fetch it again, when it is already available???pr.user = 
User.objects.get(id=request.user.id)data2 = get_object_or_404(User, 
user=request.user)

In the profile_page view, you can use reverse relation on the user model.
Regards,Chetan Ganji+91-900-483-4183ganji.chetan@gmail.comhttp://ryucoder.in

On Tue, May 5, 2020 at 9:02 PM 'Amitesh Sahay' via Django users 
 wrote:

I have a profile page where I am fetching data from two models. One from the 
default User model and another one is custom UserProfile. 
However, The data from the custom model is getting populated, but not the User 
model.Below are the two functions responsible for the whole procedure. 
def userprofileview(request):  # Authenticated user filling the form to 
complete the registration    if request.method == 'POST':        form = 
UserProfileForm(request.POST, request.FILES)        if form.is_valid():     

Re: reg: User model data missing from web page

2020-05-05 Thread 'Amitesh Sahay' via Django users
Hi Chetan,
The default user model already has those three fields, right? And since I have 
extended the  User as a onetoone field inside the UserProfile model, so 
shouldn't that work? I mean, that's my understanding. May be I am wrong. Let me 
know, just for the sake of clarity.
Right now I don't have access to my system. I will send the code snippet of the 
forms.py, may be then you can give more inputs
Thank you so much for your time though
Amitesh
Sent from Yahoo Mail on Android 
 
  On Tue, 5 May 2020 at 23:32, Chetan Ganji wrote:   Hi 
Amitesh,

Assuming you are using model forms in django without any customisation, as 
UserProfile model does not have first_name, last_name and email field, 
reading the first_name from cleaned_data is failing. 
To solve it, you have to add 3 extra fields in the UserProfileForm i.e. 
first_name, last_name and email, and pop them before saving the form.
also save these three fields on the user model. 
request.user.first_name = form.cleaned_data.pop('first_name')
request.user.save()

form.save()
Cheers!

Regards,Chetan Ganji+91-900-483-4183ganji.chetan@gmail.comhttp://ryucoder.in


On Tue, May 5, 2020 at 10:32 PM 'Amitesh Sahay' via Django users 
 wrote:

Hello Chetan,
I was doing some random test, so I put "User" there. It is not the part of the 
original code. 
Below is models.py
from django.db import modelsfrom django.urls import reversefrom 
django.contrib.auth.models import User

class UserProfile(models.Model):    user = models.OneToOneField(User, 
on_delete=models.CASCADE)    Photo = 
models.FileField(upload_to='documents/%Y/%m/%d)    uploaded_at = 
models.DateTimeField(auto_now_add=True)    dob = 
models.DateField(max_length=20)    country = models.CharField(max_length=100)   
 State = models.CharField(max_length=100)    District = 
models.CharField(max_length=100)    phone = models.CharField(max_length=10)
    def get_absolute_url(self):        return reverse('profile', kwargs={'id': 
self.id})
Kindly give me the modified code that you think would work. 


Regards,
Amitesh 

On Tuesday, 5 May, 2020, 09:24:58 pm IST, Chetan Ganji 
 wrote:  
 
 Hi Amitesh, 
If you post the models, then only someone will be able to give you exact 
solution.

Couple of things I noticed. 
How is this even working??You have not defined User variable in the function?? 
If its the default User model, how would passing it to UserProfile will help in 
your scenario??pr = UserProfile(User)

You dont need this line as it is already available as request.user.  Why do you 
want to fetch it again, when it is already available???pr.user = 
User.objects.get(id=request.user.id)data2 = get_object_or_404(User, 
user=request.user)

In the profile_page view, you can use reverse relation on the user model.
Regards,Chetan Ganji+91-900-483-4183ganji.chetan@gmail.comhttp://ryucoder.in

On Tue, May 5, 2020 at 9:02 PM 'Amitesh Sahay' via Django users 
 wrote:

I have a profile page where I am fetching data from two models. One from the 
default User model and another one is custom UserProfile. 
However, The data from the custom model is getting populated, but not the User 
model.Below are the two functions responsible for the whole procedure. 
def userprofileview(request):  # Authenticated user filling the form to 
complete the registration    if request.method == 'POST':        form = 
UserProfileForm(request.POST, request.FILES)        if form.is_valid():         
   pr = UserProfile(User)
            pr.user = User.objects.get(id=request.user.id)            
pr.first_name = form.cleaned_data['first_name']            pr.last_name = 
form.cleaned_data['last_name']            pr.email = form.cleaned_data['email']
            pr.dob = form.cleaned_data['dob']            pr.country = 
form.cleaned_data['country']            pr.State = form.cleaned_data['State']   
         pr.District = form.cleaned_data['District']            pr.phone = 
form.cleaned_data['phone']            pr.save()
            messages.success(request, f'Profile has been updated successfully') 
           return redirect('/profile')        else:            
messages.error(request, AssertionError)    else:        form = 
UserProfileForm()    return render(request, 'authenticate\\bolo.html', 
context={'form': form})

@login_requireddef profile_page(request):  # Fetching data from DB to show 
user's complete profile page    data = get_object_or_404(UserProfile, 
user=request.user)    data2 = get_object_or_404(User, user=request.user)    
context = {'data': data, 'data2': data2}    return render(request, 
'authenticate\\profile.html', locals())
To test it further, I realized that the three fields (email, first_name, and 
last_name) is coming from the "user". So, in the "userprofileview" I added 
"user" for those fields in the below format. 
pr.user.first_name = form.cleaned_data['first_name']            
pr.user.last_name = form.cleaned_data['last_name']            pr.user.email 

Re: reg: User model data missing from web page

2020-05-05 Thread 'Amitesh Sahay' via Django users
Hello Chetan,
I was doing some random test, so I put "User" there. It is not the part of the 
original code. 
Below is models.py
from django.db import modelsfrom django.urls import reversefrom 
django.contrib.auth.models import User

class UserProfile(models.Model):    user = models.OneToOneField(User, 
on_delete=models.CASCADE)    Photo = 
models.FileField(upload_to='documents/%Y/%m/%d)    uploaded_at = 
models.DateTimeField(auto_now_add=True)    dob = 
models.DateField(max_length=20)    country = models.CharField(max_length=100)   
 State = models.CharField(max_length=100)    District = 
models.CharField(max_length=100)    phone = models.CharField(max_length=10)
    def get_absolute_url(self):        return reverse('profile', kwargs={'id': 
self.id})
Kindly give me the modified code that you think would work. 


Regards,
Amitesh 

On Tuesday, 5 May, 2020, 09:24:58 pm IST, Chetan Ganji 
 wrote:  
 
 Hi Amitesh, 
If you post the models, then only someone will be able to give you exact 
solution.

Couple of things I noticed. 
How is this even working??You have not defined User variable in the function?? 
If its the default User model, how would passing it to UserProfile will help in 
your scenario??pr = UserProfile(User)

You dont need this line as it is already available as request.user.  Why do you 
want to fetch it again, when it is already available???pr.user = 
User.objects.get(id=request.user.id)data2 = get_object_or_404(User, 
user=request.user)

In the profile_page view, you can use reverse relation on the user model.
Regards,Chetan Ganji+91-900-483-4183ganji.chetan@gmail.comhttp://ryucoder.in

On Tue, May 5, 2020 at 9:02 PM 'Amitesh Sahay' via Django users 
 wrote:

I have a profile page where I am fetching data from two models. One from the 
default User model and another one is custom UserProfile. 
However, The data from the custom model is getting populated, but not the User 
model.Below are the two functions responsible for the whole procedure. 
def userprofileview(request):  # Authenticated user filling the form to 
complete the registration    if request.method == 'POST':        form = 
UserProfileForm(request.POST, request.FILES)        if form.is_valid():         
   pr = UserProfile(User)
            pr.user = User.objects.get(id=request.user.id)            
pr.first_name = form.cleaned_data['first_name']            pr.last_name = 
form.cleaned_data['last_name']            pr.email = form.cleaned_data['email']
            pr.dob = form.cleaned_data['dob']            pr.country = 
form.cleaned_data['country']            pr.State = form.cleaned_data['State']   
         pr.District = form.cleaned_data['District']            pr.phone = 
form.cleaned_data['phone']            pr.save()
            messages.success(request, f'Profile has been updated successfully') 
           return redirect('/profile')        else:            
messages.error(request, AssertionError)    else:        form = 
UserProfileForm()    return render(request, 'authenticate\\bolo.html', 
context={'form': form})

@login_requireddef profile_page(request):  # Fetching data from DB to show 
user's complete profile page    data = get_object_or_404(UserProfile, 
user=request.user)    data2 = get_object_or_404(User, user=request.user)    
context = {'data': data, 'data2': data2}    return render(request, 
'authenticate\\profile.html', locals())
To test it further, I realized that the three fields (email, first_name, and 
last_name) is coming from the "user". So, in the "userprofileview" I added 
"user" for those fields in the below format. 
pr.user.first_name = form.cleaned_data['first_name']            
pr.user.last_name = form.cleaned_data['last_name']            pr.user.email = 
form.cleaned_data['email']
However, I started to get below error
-Internal Server Error: 
/fetch_data/      # HTML Template
Traceback (most recent call last):
  File "C:\Python38\lib\site-packages\django\core\handlers\exception.py", line 
34, in inner
    response = get_response(request)
  File "C:\Python38\lib\site-packages\django\core\handlers\base.py", line 115, 
in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "C:\Python38\lib\site-packages\django\core\handlers\base.py", line 113, 
in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\anshu\djago-project\AUTHENTICATION\views.py", line 65, in 
userprofileview
    pr.user.first_name = form.cleaned_data['first_name']
KeyError: 'first_name'
--
It would be very kind of anybody who can help me rectify the issue. I have been 
struggling for 4 days minimum now.
Amitesh 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and 

reg: User model data missing from web page

2020-05-05 Thread 'Amitesh Sahay' via Django users
I have a profile page where I am fetching data from two models. One from the 
default User model and another one is custom UserProfile. 
However, The data from the custom model is getting populated, but not the User 
model.Below are the two functions responsible for the whole procedure. 
def userprofileview(request):  # Authenticated user filling the form to 
complete the registration    if request.method == 'POST':        form = 
UserProfileForm(request.POST, request.FILES)        if form.is_valid():         
   pr = UserProfile(User)
            pr.user = User.objects.get(id=request.user.id)            
pr.first_name = form.cleaned_data['first_name']            pr.last_name = 
form.cleaned_data['last_name']            pr.email = form.cleaned_data['email']
            pr.dob = form.cleaned_data['dob']            pr.country = 
form.cleaned_data['country']            pr.State = form.cleaned_data['State']   
         pr.District = form.cleaned_data['District']            pr.phone = 
form.cleaned_data['phone']            pr.save()
            messages.success(request, f'Profile has been updated successfully') 
           return redirect('/profile')        else:            
messages.error(request, AssertionError)    else:        form = 
UserProfileForm()    return render(request, 'authenticate\\bolo.html', 
context={'form': form})

@login_requireddef profile_page(request):  # Fetching data from DB to show 
user's complete profile page    data = get_object_or_404(UserProfile, 
user=request.user)    data2 = get_object_or_404(User, user=request.user)    
context = {'data': data, 'data2': data2}    return render(request, 
'authenticate\\profile.html', locals())
To test it further, I realized that the three fields (email, first_name, and 
last_name) is coming from the "user". So, in the "userprofileview" I added 
"user" for those fields in the below format. 
pr.user.first_name = form.cleaned_data['first_name']            
pr.user.last_name = form.cleaned_data['last_name']            pr.user.email = 
form.cleaned_data['email']
However, I started to get below error
-Internal Server Error: 
/fetch_data/      # HTML Template
Traceback (most recent call last):
  File "C:\Python38\lib\site-packages\django\core\handlers\exception.py", line 
34, in inner
    response = get_response(request)
  File "C:\Python38\lib\site-packages\django\core\handlers\base.py", line 115, 
in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "C:\Python38\lib\site-packages\django\core\handlers\base.py", line 113, 
in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\anshu\djago-project\AUTHENTICATION\views.py", line 65, in 
userprofileview
    pr.user.first_name = form.cleaned_data['first_name']
KeyError: 'first_name'
--
It would be very kind of anybody who can help me rectify the issue. I have been 
struggling for 4 days minimum now.
Amitesh 

-- 
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/710931514.1164631.1588692639153%40mail.yahoo.com.


Re: Page 404 error after running Django server

2020-05-04 Thread 'Amitesh Sahay' via Django users
Please import HttpResponse , 
HttpRequest will not work

Sent from Yahoo Mail on Android 
 
  On Tue, 5 May 2020 at 0:14, Amitesh Sahay wrote:   
path("", views.welcome)
This should work

Sent from Yahoo Mail on Android 
 
  On Tue, 5 May 2020 at 0:13, Deepti sharma wrote:   
@rdsaini...@gmail.com I updated it with: path("welcome/",views.welcome),But  no 
success.
Error at http://127.0.0.1:8000/welcome :

TypeError at /welcome/
__init__() takes 1 positional argument but 2 were given
| Request Method: | GET |
| Request URL: | http://127.0.0.1:8000/welcome/ |
| Django Version: | 3.0.5 |
| Exception Type: | TypeError |
| Exception Value: | __init__() takes 1 positional argument but 2 were given |
| Exception Location: | 
C:\Users\deeptish\PycharmProjects\GettingStartedDjango\meeting_planner\website\views.py
 in welcome, line 6 |
| Python Executable: | 
C:\Users\deeptish\PycharmProjects\GettingStartedDjango\venv\Scripts\python.exe |
| Python Version: | 3.7.7 |
| Python Path: | 
['C:\\Users\\deeptish\\PycharmProjects\\GettingStartedDjango\\meeting_planner',
 
'C:\\Users\\deeptish\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
 'C:\\Users\\deeptish\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
 'C:\\Users\\deeptish\\AppData\\Local\\Programs\\Python\\Python37\\lib',
 'C:\\Users\\deeptish\\AppData\\Local\\Programs\\Python\\Python37',
 'C:\\Users\\deeptish\\PycharmProjects\\GettingStartedDjango\\venv',
 
'C:\\Users\\deeptish\\PycharmProjects\\GettingStartedDjango\\venv\\lib\\site-packages']
 |
| Server time: | Mon, 4 May 2020 18:40:54 + |


Traceback Switch to copy-and-paste view
   
   - 
C:\Users\deeptish\PycharmProjects\GettingStartedDjango\venv\lib\site-packages\django\core\handlers\exception.py
 in inner  
  -   response = get_response(request) …
▶ Local vars
   - 
C:\Users\deeptish\PycharmProjects\GettingStartedDjango\venv\lib\site-packages\django\core\handlers\base.py
 in _get_response  
  -   response = 
self.process_exception_by_middleware(e, request) …
▶ Local vars
   - 
C:\Users\deeptish\PycharmProjects\GettingStartedDjango\venv\lib\site-packages\django\core\handlers\base.py
 in _get_response  
  -   response = wrapped_callback(request, 
*callback_args, **callback_kwargs) 




On Mon, May 4, 2020 at 2:37 PM R D Saini  wrote:

path("welcome/",views.welcom),
On Mon 4 May, 2020, 11:42 PM 'Amitesh Sahay' via Django users, 
 wrote:

There are lots of issues with urls.pyPlease go through the django documents on 
how to write urls.py

Sent from Yahoo Mail on Android 
 
  On Mon, 4 May 2020 at 23:39, Deepti sharma wrote:  
 Hi, I have just started learning django and was trying to make a meeting 
planner project y folllowing a course.I updated the setting.py file to add 
website into Instaled_Apps. Then have written a function named welcome in 
views.pyFinally I added it's entry into urls.py fieBut when I run the server, I 
am getting following error on webpage:

Page not found (404)

| Request Method: | GET |
| Request URL: | http://127.0.0.1:8000/ |


Using the URLconf defined in meeting_planner.urls, Django tried these URL 
patterns, in this order:
   
   - admin/
   - welcome.html/

The empty path didn't match any of these.

You're seeing this error because you have DEBUG = True in your Django settings 
file. Change that to False, and Django will display a standard 404 page.




Can someone please help me with this? I am stuck.







This is my code:  (meeting_planner/website/views.py):
from django.shortcuts import render
from django.http import HttpRequest
# Create your views here.

def welcome(request):
return HttpRequest("Welcome to the Meeting Planner Website!")

(meeting_planner/meeting_planer/urls.py):from django.contrib import admin
from django.urls import path
from website import views
from django.conf.urls import url,include

from website.views import welcome

urlpatterns = [
path('admin/', admin.site.urls),
path('welcome.html', welcome)
]



-- 
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/3d38a2c2-3449-4c2f-839e-244b9295f55d%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/1203797502.769610.1588615897439%40mail.yahoo.com.



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and 

Re: Page 404 error after running Django server

2020-05-04 Thread 'Amitesh Sahay' via Django users
path("", views.welcome)
This should work

Sent from Yahoo Mail on Android 
 
  On Tue, 5 May 2020 at 0:13, Deepti sharma wrote:   
@rdsaini...@gmail.com I updated it with: path("welcome/",views.welcome),But  no 
success.
Error at http://127.0.0.1:8000/welcome :

TypeError at /welcome/
__init__() takes 1 positional argument but 2 were given
| Request Method: | GET |
| Request URL: | http://127.0.0.1:8000/welcome/ |
| Django Version: | 3.0.5 |
| Exception Type: | TypeError |
| Exception Value: | __init__() takes 1 positional argument but 2 were given |
| Exception Location: | 
C:\Users\deeptish\PycharmProjects\GettingStartedDjango\meeting_planner\website\views.py
 in welcome, line 6 |
| Python Executable: | 
C:\Users\deeptish\PycharmProjects\GettingStartedDjango\venv\Scripts\python.exe |
| Python Version: | 3.7.7 |
| Python Path: | 
['C:\\Users\\deeptish\\PycharmProjects\\GettingStartedDjango\\meeting_planner',
 
'C:\\Users\\deeptish\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
 'C:\\Users\\deeptish\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
 'C:\\Users\\deeptish\\AppData\\Local\\Programs\\Python\\Python37\\lib',
 'C:\\Users\\deeptish\\AppData\\Local\\Programs\\Python\\Python37',
 'C:\\Users\\deeptish\\PycharmProjects\\GettingStartedDjango\\venv',
 
'C:\\Users\\deeptish\\PycharmProjects\\GettingStartedDjango\\venv\\lib\\site-packages']
 |
| Server time: | Mon, 4 May 2020 18:40:54 + |


Traceback Switch to copy-and-paste view
   
   - 
C:\Users\deeptish\PycharmProjects\GettingStartedDjango\venv\lib\site-packages\django\core\handlers\exception.py
 in inner  
  -   response = get_response(request) …
▶ Local vars
   - 
C:\Users\deeptish\PycharmProjects\GettingStartedDjango\venv\lib\site-packages\django\core\handlers\base.py
 in _get_response  
  -   response = 
self.process_exception_by_middleware(e, request) …
▶ Local vars
   - 
C:\Users\deeptish\PycharmProjects\GettingStartedDjango\venv\lib\site-packages\django\core\handlers\base.py
 in _get_response  
  -   response = wrapped_callback(request, 
*callback_args, **callback_kwargs) 




On Mon, May 4, 2020 at 2:37 PM R D Saini  wrote:

path("welcome/",views.welcom),
On Mon 4 May, 2020, 11:42 PM 'Amitesh Sahay' via Django users, 
 wrote:

There are lots of issues with urls.pyPlease go through the django documents on 
how to write urls.py

Sent from Yahoo Mail on Android 
 
  On Mon, 4 May 2020 at 23:39, Deepti sharma wrote:  
 Hi, I have just started learning django and was trying to make a meeting 
planner project y folllowing a course.I updated the setting.py file to add 
website into Instaled_Apps. Then have written a function named welcome in 
views.pyFinally I added it's entry into urls.py fieBut when I run the server, I 
am getting following error on webpage:

Page not found (404)

| Request Method: | GET |
| Request URL: | http://127.0.0.1:8000/ |


Using the URLconf defined in meeting_planner.urls, Django tried these URL 
patterns, in this order:
   
   - admin/
   - welcome.html/

The empty path didn't match any of these.

You're seeing this error because you have DEBUG = True in your Django settings 
file. Change that to False, and Django will display a standard 404 page.




Can someone please help me with this? I am stuck.







This is my code:  (meeting_planner/website/views.py):
from django.shortcuts import render
from django.http import HttpRequest
# Create your views here.

def welcome(request):
return HttpRequest("Welcome to the Meeting Planner Website!")

(meeting_planner/meeting_planer/urls.py):from django.contrib import admin
from django.urls import path
from website import views
from django.conf.urls import url,include

from website.views import welcome

urlpatterns = [
path('admin/', admin.site.urls),
path('welcome.html', welcome)
]



-- 
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/3d38a2c2-3449-4c2f-839e-244b9295f55d%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/1203797502.769610.1588615897439%40mail.yahoo.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 
h

Re: Page 404 error after running Django server

2020-05-04 Thread 'Amitesh Sahay' via Django users
There are lots of issues with urls.pyPlease go through the django documents on 
how to write urls.py

Sent from Yahoo Mail on Android 
 
  On Mon, 4 May 2020 at 23:39, Deepti sharma wrote:  
 Hi, I have just started learning django and was trying to make a meeting 
planner project y folllowing a course.I updated the setting.py file to add 
website into Instaled_Apps. Then have written a function named welcome in 
views.pyFinally I added it's entry into urls.py fieBut when I run the server, I 
am getting following error on webpage:

Page not found (404)

| Request Method: | GET |
| Request URL: | http://127.0.0.1:8000/ |


Using the URLconf defined in meeting_planner.urls, Django tried these URL 
patterns, in this order:
   
   - admin/
   - welcome.html/

The empty path didn't match any of these.

You're seeing this error because you have DEBUG = True in your Django settings 
file. Change that to False, and Django will display a standard 404 page.




Can someone please help me with this? I am stuck.







This is my code:  (meeting_planner/website/views.py):
from django.shortcuts import render
from django.http import HttpRequest
# Create your views here.

def welcome(request):
return HttpRequest("Welcome to the Meeting Planner Website!")

(meeting_planner/meeting_planer/urls.py):from django.contrib import admin
from django.urls import path
from website import views
from django.conf.urls import url,include

from website.views import welcome

urlpatterns = [
path('admin/', admin.site.urls),
path('welcome.html', welcome)
]



-- 
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/3d38a2c2-3449-4c2f-839e-244b9295f55d%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/1203797502.769610.1588615897439%40mail.yahoo.com.


Re: Form not visible on the add page

2020-05-03 Thread 'Amitesh Sahay' via Django users
did you migrate the MODEL?


Regards,
Amitesh Sahay91-750 797 8619 

On Sunday, 3 May, 2020, 08:15:32 pm IST, Jorge Gimeno 
 wrote:  
 
 

On Sun, May 3, 2020 at 7:34 AM Vikram Jaiswal 
 wrote:

I am not able to see the form on admin page to add the dataFirst  -First
 -settings.py -urls.py
  -travello -migrations -urls.py 
-models.py -admin.py
here is the models.pyfrom django.db import models
# Create your models here.class Destination(models.Model): #id : int name : 
models.CharField(max_length=100)#str img : 
models.ImageField(upload_to='pics')#str desc : 
models.CharField(max_length=100)#str price : models.IntegerField()#int offer : 
models.BooleanField(default=False)#bool

here is the admin.pyfrom django.contrib import adminfrom travello.models import 
Destination



# Register your models here.admin.site.register(Destination)
Please help!


-- 
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/6f1d4cad-2d83-454d-b49b-7eaaef5b0ea8%40googlegroups.com.


This is related to your previous post.  The fields aren't showing up, and they 
won't until they are properly defined and the database migration is done.
-Jorge


-- 
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/CANfN%3DK9NwDKE8o0zcJMatAZpCYBm5WvDLgZbuxZFxfw4LZPu2A%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/1505356251.370458.1588517911879%40mail.yahoo.com.


Re: Re:

2020-05-03 Thread 'Amitesh Sahay' via Django users
please show your app's urls.py, as well the errors


Regards,
Amitesh 

On Sunday, 3 May, 2020, 07:53:47 pm IST, fahad rasool 
 wrote:  
 
 Than also it is not working
On Sun, 3 May 2020, 7:44 pm 'Amitesh Sahay' via Django users, 
 wrote:

it should be return redirect('login')


please check
On Sunday, 3 May, 2020, 07:34:11 pm IST, fahad rasool 
 wrote:  
 
 
I am unable to redirect to my login page from signup page and nor i am able to 
store sign up form details in the database .please someone help its urgent..

-- 
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/CACqgSmBdoviTSbHH%3D8yMo86MO6vpGpHyNQz1FtXgRf-UiL7zYw%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/660971716.362954.1588515193796%40mail.yahoo.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/CACqgSmAwKgU4dVWN72-u2xnvqBz5ThV6CNarukWo%2BFACwN%3DGFQ%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/940225696.366548.1588517794311%40mail.yahoo.com.


[no subject]

2020-05-03 Thread 'Amitesh Sahay' via Django users
it should be return redirect('login')


please check
On Sunday, 3 May, 2020, 07:34:11 pm IST, fahad rasool 
 wrote:  
 
 
I am unable to redirect to my login page from signup page and nor i am able to 
store sign up form details in the database .please someone help its urgent..

-- 
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/CACqgSmBdoviTSbHH%3D8yMo86MO6vpGpHyNQz1FtXgRf-UiL7zYw%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/660971716.362954.1588515193796%40mail.yahoo.com.


reg: rendering profile page

2020-05-01 Thread 'Amitesh Sahay' via Django users
Hello All, 
Kindly help in the below link
how to redirect to a profile page and see the data of the logged in user in 
Django?

| 
| 
| 
|  |  |

 |

 |
| 
|  | 
how to redirect to a profile page and see the data of the logged in user...

I have been working on a small project, and it was developing smoothly until I 
got a road block. However, I am n...
 |

 |

 |



Thank you

-- 
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/1627326366.223609.1588347621881%40mail.yahoo.com.


Re: Can anyone please help?

2020-04-30 Thread 'Amitesh Sahay' via Django users
You can also try keeping the same name for the endpoint as below
path('endpoint/', views.Endpoint.as_view(), name='endpoint'),
Sent from Yahoo Mail on Android 
 
  On Thu, 30 Apr 2020 at 23:52, Milson Munakami wrote:   
Hi Sahay,
That is already path('endpoint/', views.Endpoint.as_view(), 
name='get_endpoint'),
On Thu, Apr 30, 2020 at 1:15 PM 'Amitesh Sahay' via Django users 
 wrote:

It should be Endpoint.as_view()

Sent from Yahoo Mail on Android 
 


  On Thu, 30 Apr 2020 at 17:35, Milson Munakami wrote:   
Can anyone please help me to resolve this issue?

https://stackoverflow.com/q/61514512/1316060

My url path in project's url.py is defined as follows:
path('endpoint/', views.Endpoint.as_view(), name='get_endpoint'),
The views.py include the following class to handle this routing:
@method_decorator(csrf_exempt, name='dispatch') 
class Endpoint(View):
def get(self, request, *args, **kwargs):
 Here I can see the User Session ##
if not request.user.is_authenticated:
return redirect('authentication_router')

return redirect(

'https://app.globus.org/file-manager?method=POST=%s=%s=1=0=%s'
% (
request.build_absolute_uri(), "/", "To Transfer your Files Select 
the Folder first!")
)

def post(self, request, *args, **kwargs):  # On return from OAuth Page
 Here, User Session return nothing so user is AnonymousUser 
##
if request.POST.get('folder[0]'):  # A Endpoint folder was selected
endpoint_path = os.path.join(request.POST.get('path'), 
request.POST.get('folder[0]'))
else:
endpoint_path = request.POST.get('path') 

profile = request.user.userprofile # request.user does not has 
userprofile
profile.endpoint_path = endpoint_path
profile.save()

return HttpResponseRedirect(reverse('authentication_router'))
The problem is when the get is called it finds the request.user value as 
authenticated user but once the redirect from OAUTH page with POST hits the 
class it loss all request user session and gives error at this line:
profile = request.user.userprofile
As, request.user seems loss its session and has value of AnonymousUser even 
though till GET method it is preserving the user's login session values.

My settings.py file includes:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
**'django.contrib.sessions',**
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'myapp',
]

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',
]
I am testing it in localhost:8000 .Please let me know what I am missing this 
code. Same code is perfectly working in Django 1.8 and Python 2.7. Recently, I 
am trying to upgrade it to work with Django 3 and Python 3. Only difference I 
can see is in settings.py in Django 1.8 version includes: 
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',in 
MIDDLEWARE_CLASSES which is removed in latest version of Django.

-- 
Thank you,
| 
 | Milson |



|  | Virus-free. www.avg.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/CAP1qhGui2o%3DDJD57Rq7GaiVO-s9wOgSdw1G-bNLPSYCL9Wkeuw%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/1981496808.1824222.1588270514644%40mail.yahoo.com.

-- 
Thank you,
| 
 | Milson Munakami

Mobile: 208.220.2943 


 |



-- 
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/CAP1qhGvo2X8%2BAPvqQGoOuVFOfhkmC%3DCkiByxfow6s4YVSzawnA%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 recei

Re: Can anyone please help?

2020-04-30 Thread 'Amitesh Sahay' via Django users
I think "views." is incorrect. It should not appear as prefix. However , it 
also depends on how you have impoted 
Did you import as below?
from views import view_name
OR
import views


Sent from Yahoo Mail on Android 
 
  On Thu, 30 Apr 2020 at 23:52, Milson Munakami wrote:   
Hi Sahay,
That is already path('endpoint/', views.Endpoint.as_view(), 
name='get_endpoint'),
On Thu, Apr 30, 2020 at 1:15 PM 'Amitesh Sahay' via Django users 
 wrote:

It should be Endpoint.as_view()

Sent from Yahoo Mail on Android 
 


  On Thu, 30 Apr 2020 at 17:35, Milson Munakami wrote:   
Can anyone please help me to resolve this issue?

https://stackoverflow.com/q/61514512/1316060

My url path in project's url.py is defined as follows:
path('endpoint/', views.Endpoint.as_view(), name='get_endpoint'),
The views.py include the following class to handle this routing:
@method_decorator(csrf_exempt, name='dispatch') 
class Endpoint(View):
def get(self, request, *args, **kwargs):
 Here I can see the User Session ##
if not request.user.is_authenticated:
return redirect('authentication_router')

return redirect(

'https://app.globus.org/file-manager?method=POST=%s=%s=1=0=%s'
% (
request.build_absolute_uri(), "/", "To Transfer your Files Select 
the Folder first!")
)

def post(self, request, *args, **kwargs):  # On return from OAuth Page
 Here, User Session return nothing so user is AnonymousUser 
##
if request.POST.get('folder[0]'):  # A Endpoint folder was selected
endpoint_path = os.path.join(request.POST.get('path'), 
request.POST.get('folder[0]'))
else:
endpoint_path = request.POST.get('path') 

profile = request.user.userprofile # request.user does not has 
userprofile
profile.endpoint_path = endpoint_path
profile.save()

return HttpResponseRedirect(reverse('authentication_router'))
The problem is when the get is called it finds the request.user value as 
authenticated user but once the redirect from OAUTH page with POST hits the 
class it loss all request user session and gives error at this line:
profile = request.user.userprofile
As, request.user seems loss its session and has value of AnonymousUser even 
though till GET method it is preserving the user's login session values.

My settings.py file includes:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
**'django.contrib.sessions',**
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'myapp',
]

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',
]
I am testing it in localhost:8000 .Please let me know what I am missing this 
code. Same code is perfectly working in Django 1.8 and Python 2.7. Recently, I 
am trying to upgrade it to work with Django 3 and Python 3. Only difference I 
can see is in settings.py in Django 1.8 version includes: 
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',in 
MIDDLEWARE_CLASSES which is removed in latest version of Django.

-- 
Thank you,
| 
 | Milson |



|  | Virus-free. www.avg.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/CAP1qhGui2o%3DDJD57Rq7GaiVO-s9wOgSdw1G-bNLPSYCL9Wkeuw%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/1981496808.1824222.1588270514644%40mail.yahoo.com.

-- 
Thank you,
| 
 | Milson Munakami

Mobile: 208.220.2943 


 |



-- 
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/CAP1qhGvo2X8%2BAPvqQGoOuVFOfhkmC%3DCkiByxfow6s4YVSzawnA%40mail.gmail.com.
  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users"

Re: Can anyone please help?

2020-04-30 Thread 'Amitesh Sahay' via Django users
It should be Endpoint.as_view()

Sent from Yahoo Mail on Android 
 
  On Thu, 30 Apr 2020 at 17:35, Milson Munakami wrote:   
Can anyone please help me to resolve this issue?

https://stackoverflow.com/q/61514512/1316060

My url path in project's url.py is defined as follows:
path('endpoint/', views.Endpoint.as_view(), name='get_endpoint'),
The views.py include the following class to handle this routing:
@method_decorator(csrf_exempt, name='dispatch') 
class Endpoint(View):
def get(self, request, *args, **kwargs):
 Here I can see the User Session ##
if not request.user.is_authenticated:
return redirect('authentication_router')

return redirect(

'https://app.globus.org/file-manager?method=POST=%s=%s=1=0=%s'
% (
request.build_absolute_uri(), "/", "To Transfer your Files Select 
the Folder first!")
)

def post(self, request, *args, **kwargs):  # On return from OAuth Page
 Here, User Session return nothing so user is AnonymousUser 
##
if request.POST.get('folder[0]'):  # A Endpoint folder was selected
endpoint_path = os.path.join(request.POST.get('path'), 
request.POST.get('folder[0]'))
else:
endpoint_path = request.POST.get('path') 

profile = request.user.userprofile # request.user does not has 
userprofile
profile.endpoint_path = endpoint_path
profile.save()

return HttpResponseRedirect(reverse('authentication_router'))
The problem is when the get is called it finds the request.user value as 
authenticated user but once the redirect from OAUTH page with POST hits the 
class it loss all request user session and gives error at this line:
profile = request.user.userprofile
As, request.user seems loss its session and has value of AnonymousUser even 
though till GET method it is preserving the user's login session values.

My settings.py file includes:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
**'django.contrib.sessions',**
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'myapp',
]

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',
]
I am testing it in localhost:8000 .Please let me know what I am missing this 
code. Same code is perfectly working in Django 1.8 and Python 2.7. Recently, I 
am trying to upgrade it to work with Django 3 and Python 3. Only difference I 
can see is in settings.py in Django 1.8 version includes: 
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',in 
MIDDLEWARE_CLASSES which is removed in latest version of Django.

-- 
Thank you,
| 
 | Milson |



|  | Virus-free. www.avg.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/CAP1qhGui2o%3DDJD57Rq7GaiVO-s9wOgSdw1G-bNLPSYCL9Wkeuw%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/1981496808.1824222.1588270514644%40mail.yahoo.com.


Re: "detail": "CSRF Failed: Referer checking failed - no Referer."

2020-04-30 Thread 'Amitesh Sahay' via Django users
Try the below link
https://docs.djangoproject.com/en/3.0/ref/settings/
Sent from Yahoo Mail on Android
Sent from Yahoo Mail on Android 
 
  On Thu, 30 Apr 2020 at 19:35, VenkataSivaRamiReddy 
wrote:   Send the url let me check
On Thu, Apr 30, 2020, 18:49 shreehari Vaasistha L  
wrote:

Also csrf exempt is not making any difference
On Thursday, April 30, 2020 at 6:48:36 PM UTC+5:30, shreehari Vaasistha L wrote:
hello
i have deployed django app on aws .with https im getting error "detail": "CSRF 
Failed: Referer checking failed - no Referer." . But with http everything works 
fine.

Thank you


-- 
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/277d9146-e450-433a-8add-d675a5411bd4%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/CAGiJVX2%3DA7P-LLVrvgHo23V7AViyG_%3DVbmJfYWX2%3DagfJc9QWQ%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/1383369658.337492.1588260929138%40mail.yahoo.com.


Reg: need helping hand on a real time project

2020-04-30 Thread 'Amitesh Sahay' via Django users
Hello All,
I am working on a project, which happens to be a real time project, once 
completed would be deployed over the cloud.
Therefore, I am looking for a helping hand who is willing to learn and get some 
real time experience. 
But let me be very clear, it's not a very complex project, but good to start 
with for anybody who is willing to learn Django just like me. Especially final 
year students.
Let me know. 
Amit

Sent from Yahoo Mail on Android

-- 
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/163757351.1806351.1588260745017%40mail.yahoo.com.


Re: {"image":["File extension “zip” is not allowed. Allowed extensions are: bmp, dib, gif, tif, tiff, jfif, jpe, jpg, jpeg, pbm, pgm, ppm, pnm, png, apng, blp, bufr, cur, pcx, dcx, dds, ps, eps, fit,

2020-04-30 Thread 'Amitesh Sahay' via Django users
This is a very less information, please share more information, code snippet 
where the attachment conditions are written, etc.


Regards,
Amitesh 

On Thursday, 30 April, 2020, 02:05:59 pm IST, yashwanth balanagu 
 wrote:  
 
 {"image":["File extension “zip” is not allowed. Allowed extensions are: bmp, 
dib, gif, tif, tiff, jfif, jpe, jpg, jpeg, pbm, pgm, ppm, pnm, png, apng, blp, 
bufr, cur, pcx, dcx, dds, ps, eps, fit, fits, fli, flc, ftc, ftu, gbr, grib, 
h5, hdf, jp2, j2k, jpc, jpf, jpx, j2c, icns, ico, im, iim, mpg, mpeg, mpo, msp, 
palm, pcd, pdf, pxr, psd, bw, rgb, rgba, sgi, ras, tga, icb, vda, vst, webp, 
wmf, emf, xbm, xpm."]}


-- 
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/72e536a4-4029-4a54-8423-a0681d90ec5a%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/847979920.1738358.1588246000866%40mail.yahoo.com.


Re: App Dev wanted

2020-04-29 Thread 'Amitesh Sahay' via Django users
Hey Arne,
I have 4 years of web dev exp.. if you wish we can have a con call and get 
around the work based on the requirements
Amitesh

Sent from Yahoo Mail on Android 
 
  On Wed, 29 Apr 2020 at 20:52, tejasri mamidi wrote:  
 I'm new django developer ,I wanna help you ...if need it ..email me
On Wed, Apr 29, 2020, 19:38 Arne Bollinger  wrote:

Hey,
We came with a project out of a Covid-19 Hackathon that we could not finish. 
Now we want to launch as fast as possible as long as people are still in need 
of social contact.
https://devpost.com/software/corona-circles
We want to develop an Open-Source Django App that creates Jitsi Meet Sessions 
and sends out Emails to participants. Pretty simple. 3 volunteer backend devs 
have left us with unfinished code, so now we want to pay somebody from our 
pockets, to get it online asap! 
Here is a head start, the frontend is almost 
ready:https://github.com/CoronaCircles/coronacircles-django
I estimate roughly maximum 10 hours needed. We have a Budget of at least 1000€.
Anybody wants to help us?

Cheers,
Arne




-- 
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/81f7a052-7366-45b7-b2dc-ffe23a6c5050%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/CAP6hVmDhf3WBK%2B1uvyO9Ff092_ngWO9qkrTvHB-b5ucDKAF8ng%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/162938532.1436036.1588175852065%40mail.yahoo.com.


Re: reg: NoReverseMatch at "login"

2020-04-29 Thread 'Amitesh Sahay' via Django users
Forget it, I figured out the issue. Solved it.. As said silly mistake...

Sent from Yahoo Mail on Android 
 
  On Wed, 29 Apr 2020 at 10:15, 'Amitesh Sahay' via Django 
users wrote:   That didn't work. we need to 
redirect to a web page, and not a function. May be I am wrong. As I have said, 
it was working before, and suddenly it stopped working. Not sure what went 
wrong.
Regards,Amitesh 

On Wednesday, 29 April, 2020, 12:52:16 am IST, 'Amitesh Sahay' via Django 
users  wrote:  
 
 Well, I can try your suggestion. But I am little unsure of the outcome though. 
Will update.
Thank you 

Sent from Yahoo Mail on Android 
 
  On Tue, 28 Apr 2020 at 23:05, 'Adrian Havenga-Bennett' via Django 
users wrote:   Hello
Redirect should call the view rather than the html page. Whichever view is 
handling the rendering of the chittr.html page is what should be the argument 
for redirect.

Sent from my iPhone

On 28 Apr 2020, at 16:28, 'Amitesh Sahay' via Django users 
 wrote:



Hi,
Its a shame that I am not able to resolve this simple issue. Explanation as 
below
Once the user login, he/she will be rendered to a page called (chitrr.html). 
This I have mentioned as a "return redirect('chitrr')". But when I login, it is 
giving "NoReverseMatch" error. 
It's ironic that everything was working before. But I don't know what changed, 
things went south. 
views.py---def login_user(request):
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
messages.success(request, f'login success')
return redirect('chitrr')
else:
messages.error(request, f'error while login, please try again')
return redirect('login')
else:
return render(request, 'authenticate\\login.html', 
{})urls.py-urlpatterns = [
path("home/", home, name='home'),
path("login/", login_user, name='login'),
path("logout/", logout_user, name='logout'),
path("register/", register_user, name='register'),
path("profile1/", userProfileView, name='profile1'),
path('summary/', getUserProfile.as_view(), name='summary'),  # drf
path('comp/', GetUserData.as_view(), name='comp')
]chitrr.html--
{% extends 'base.html' %}
{% load crispy_forms_tags %}
{% load static %}
{% block content %}


{% csrf_token %}


{{form.Photo|as_crispy_field }}



{{form.dob|as_crispy_field }}





{{form.country|as_crispy_field }}



{{form.State|as_crispy_field }}




{{form.District|as_crispy_field }}



{{form.phone|as_crispy_field }}


Save

{% endblock %}login.html---




   Login
   https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css; 
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
 crossorigin="anonymous">
   https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js&quot</a>;>
   https://use.fontawesome.com/releases/v5.6.1/css/all.css; 
integrity="sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP"
 crossorigin="anonymous">


   
  body,
  html {
 margin: 0;
 padding: 0;
 height: 100%;
 background: #7abecc !important;
  }
  .user_card {
 width: 350px;
 margin-top: auto;
 margin-bottom: auto;
 background: #74cfbf;
 position: relative;
 display: flex;
 justify-content: center;
 flex-direction: column;
 padding: 10px;
 box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 
0.19);
 -webkit-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 
rgba(0, 0, 0, 0.19);
 -moz-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 
0, 0, 0.19);
 border-radius: 5px;

  }

  .form_container {
 margin-top: 20px;
  }

  #form-title{
 color: #fff;

  }

  .login_btn {
 width: 100%;
 background: #33ccff !important;
 color: white !important;
  }
  .login_btn:focus {
 box-shadow: none !important;
 outline: 0px !important;
  }
  .login_container {
 padding: 0 2rem;
  }
  .input-group-text {
 background: #f7ba5b !important;
 color: white !important;
 border: 0 !important;
 border-radius: 0.25rem 0 0 0.25rem !important;
  }
  .input_user,
  .input_pass:focus {
 box-shadow: none !important;
 outline: 0px !important;
  }

  #messages{
 background-color: grey;
 color:

Re: reg: NoReverseMatch at "login"

2020-04-28 Thread 'Amitesh Sahay' via Django users
That didn't work. we need to redirect to a web page, and not a function. May be 
I am wrong. As I have said, it was working before, and suddenly it stopped 
working. Not sure what went wrong.
Regards,Amitesh 

On Wednesday, 29 April, 2020, 12:52:16 am IST, 'Amitesh Sahay' via Django 
users  wrote:  
 
 Well, I can try your suggestion. But I am little unsure of the outcome though. 
Will update.
Thank you 

Sent from Yahoo Mail on Android 
 
  On Tue, 28 Apr 2020 at 23:05, 'Adrian Havenga-Bennett' via Django 
users wrote:   Hello
Redirect should call the view rather than the html page. Whichever view is 
handling the rendering of the chittr.html page is what should be the argument 
for redirect.

Sent from my iPhone

On 28 Apr 2020, at 16:28, 'Amitesh Sahay' via Django users 
 wrote:



Hi,
Its a shame that I am not able to resolve this simple issue. Explanation as 
below
Once the user login, he/she will be rendered to a page called (chitrr.html). 
This I have mentioned as a "return redirect('chitrr')". But when I login, it is 
giving "NoReverseMatch" error. 
It's ironic that everything was working before. But I don't know what changed, 
things went south. 
views.py---def login_user(request):
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
messages.success(request, f'login success')
return redirect('chitrr')
else:
messages.error(request, f'error while login, please try again')
return redirect('login')
else:
return render(request, 'authenticate\\login.html', 
{})urls.py-urlpatterns = [
path("home/", home, name='home'),
path("login/", login_user, name='login'),
path("logout/", logout_user, name='logout'),
path("register/", register_user, name='register'),
path("profile1/", userProfileView, name='profile1'),
path('summary/', getUserProfile.as_view(), name='summary'),  # drf
path('comp/', GetUserData.as_view(), name='comp')
]chitrr.html--
{% extends 'base.html' %}
{% load crispy_forms_tags %}
{% load static %}
{% block content %}


{% csrf_token %}


{{form.Photo|as_crispy_field }}



{{form.dob|as_crispy_field }}





{{form.country|as_crispy_field }}



{{form.State|as_crispy_field }}




{{form.District|as_crispy_field }}



{{form.phone|as_crispy_field }}


Save

{% endblock %}login.html---




   Login
   https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css; 
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
 crossorigin="anonymous">
   https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js&quot</a>;>
   https://use.fontawesome.com/releases/v5.6.1/css/all.css; 
integrity="sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP"
 crossorigin="anonymous">


   
  body,
  html {
 margin: 0;
 padding: 0;
 height: 100%;
 background: #7abecc !important;
  }
  .user_card {
 width: 350px;
 margin-top: auto;
 margin-bottom: auto;
 background: #74cfbf;
 position: relative;
 display: flex;
 justify-content: center;
 flex-direction: column;
 padding: 10px;
 box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 
0.19);
 -webkit-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 
rgba(0, 0, 0, 0.19);
 -moz-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 
0, 0, 0.19);
 border-radius: 5px;

  }

  .form_container {
 margin-top: 20px;
  }

  #form-title{
 color: #fff;

  }

  .login_btn {
 width: 100%;
 background: #33ccff !important;
 color: white !important;
  }
  .login_btn:focus {
 box-shadow: none !important;
 outline: 0px !important;
  }
  .login_container {
 padding: 0 2rem;
  }
  .input-group-text {
 background: #f7ba5b !important;
 color: white !important;
 border: 0 !important;
 border-radius: 0.25rem 0 0 0.25rem !important;
  }
  .input_user,
  .input_pass:focus {
 box-shadow: none !important;
 outline: 0px !important;
  }

  #messages{
 background-color: grey;
 color: #fff;
 padding: 10px;
 margin-top: 10px;
  }
   



 

Re: reg: NoReverseMatch at "login"

2020-04-28 Thread 'Amitesh Sahay' via Django users
Well, I can try your suggestion. But I am little unsure of the outcome though. 
Will update.
Thank you 

Sent from Yahoo Mail on Android 
 
  On Tue, 28 Apr 2020 at 23:05, 'Adrian Havenga-Bennett' via Django 
users wrote:   Hello
Redirect should call the view rather than the html page. Whichever view is 
handling the rendering of the chittr.html page is what should be the argument 
for redirect.

Sent from my iPhone

On 28 Apr 2020, at 16:28, 'Amitesh Sahay' via Django users 
 wrote:



Hi,
Its a shame that I am not able to resolve this simple issue. Explanation as 
below
Once the user login, he/she will be rendered to a page called (chitrr.html). 
This I have mentioned as a "return redirect('chitrr')". But when I login, it is 
giving "NoReverseMatch" error. 
It's ironic that everything was working before. But I don't know what changed, 
things went south. 
views.py---def login_user(request):
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
messages.success(request, f'login success')
return redirect('chitrr')
else:
messages.error(request, f'error while login, please try again')
return redirect('login')
else:
return render(request, 'authenticate\\login.html', 
{})urls.py-urlpatterns = [
path("home/", home, name='home'),
path("login/", login_user, name='login'),
path("logout/", logout_user, name='logout'),
path("register/", register_user, name='register'),
path("profile1/", userProfileView, name='profile1'),
path('summary/', getUserProfile.as_view(), name='summary'),  # drf
path('comp/', GetUserData.as_view(), name='comp')
]chitrr.html--
{% extends 'base.html' %}
{% load crispy_forms_tags %}
{% load static %}
{% block content %}


{% csrf_token %}


{{form.Photo|as_crispy_field }}



{{form.dob|as_crispy_field }}





{{form.country|as_crispy_field }}



{{form.State|as_crispy_field }}




{{form.District|as_crispy_field }}



{{form.phone|as_crispy_field }}


Save

{% endblock %}login.html---




   Login
   https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css; 
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
 crossorigin="anonymous">
   https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js&quot</a>;>
   https://use.fontawesome.com/releases/v5.6.1/css/all.css; 
integrity="sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP"
 crossorigin="anonymous">


   
  body,
  html {
 margin: 0;
 padding: 0;
 height: 100%;
 background: #7abecc !important;
  }
  .user_card {
 width: 350px;
 margin-top: auto;
 margin-bottom: auto;
 background: #74cfbf;
 position: relative;
 display: flex;
 justify-content: center;
 flex-direction: column;
 padding: 10px;
 box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 
0.19);
 -webkit-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 
rgba(0, 0, 0, 0.19);
 -moz-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 
0, 0, 0.19);
 border-radius: 5px;

  }

  .form_container {
 margin-top: 20px;
  }

  #form-title{
 color: #fff;

  }

  .login_btn {
 width: 100%;
 background: #33ccff !important;
 color: white !important;
  }
  .login_btn:focus {
 box-shadow: none !important;
 outline: 0px !important;
  }
  .login_container {
 padding: 0 2rem;
  }
  .input-group-text {
 background: #f7ba5b !important;
 color: white !important;
 border: 0 !important;
 border-radius: 0.25rem 0 0 0.25rem !important;
  }
  .input_user,
  .input_pass:focus {
 box-shadow: none !important;
 outline: 0px !important;
  }

  #messages{
 background-color: grey;
 color: #fff;
 padding: 10px;
 margin-top: 10px;
  }
   



   
  
 



   LOGIN


   
  {% csrf_token %}
  
 

 
 
  
  
 

 

  

 

reg: NoReverseMatch at "login"

2020-04-28 Thread 'Amitesh Sahay' via Django users
Hi,
Its a shame that I am not able to resolve this simple issue. Explanation as 
below
Once the user login, he/she will be rendered to a page called (chitrr.html). 
This I have mentioned as a "return redirect('chitrr')". But when I login, it is 
giving "NoReverseMatch" error. 
It's ironic that everything was working before. But I don't know what changed, 
things went south. 
views.py---def login_user(request):
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
messages.success(request, f'login success')
return redirect('chitrr')
else:
messages.error(request, f'error while login, please try again')
return redirect('login')
else:
return render(request, 'authenticate\\login.html', 
{})urls.py-urlpatterns = [
path("home/", home, name='home'),
path("login/", login_user, name='login'),
path("logout/", logout_user, name='logout'),
path("register/", register_user, name='register'),
path("profile1/", userProfileView, name='profile1'),
path('summary/', getUserProfile.as_view(), name='summary'),  # drf
path('comp/', GetUserData.as_view(), name='comp')
]chitrr.html--
{% extends 'base.html' %}
{% load crispy_forms_tags %}
{% load static %}
{% block content %}


{% csrf_token %}


{{form.Photo|as_crispy_field }}



{{form.dob|as_crispy_field }}





{{form.country|as_crispy_field }}



{{form.State|as_crispy_field }}




{{form.District|as_crispy_field }}



{{form.phone|as_crispy_field }}


Save

{% endblock %}login.html---




   Login
   https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css; 
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
 crossorigin="anonymous">
   https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js";>
   https://use.fontawesome.com/releases/v5.6.1/css/all.css; 
integrity="sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP"
 crossorigin="anonymous">


   
  body,
  html {
 margin: 0;
 padding: 0;
 height: 100%;
 background: #7abecc !important;
  }
  .user_card {
 width: 350px;
 margin-top: auto;
 margin-bottom: auto;
 background: #74cfbf;
 position: relative;
 display: flex;
 justify-content: center;
 flex-direction: column;
 padding: 10px;
 box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 
0.19);
 -webkit-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 
rgba(0, 0, 0, 0.19);
 -moz-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 
0, 0, 0.19);
 border-radius: 5px;

  }

  .form_container {
 margin-top: 20px;
  }

  #form-title{
 color: #fff;

  }

  .login_btn {
 width: 100%;
 background: #33ccff !important;
 color: white !important;
  }
  .login_btn:focus {
 box-shadow: none !important;
 outline: 0px !important;
  }
  .login_container {
 padding: 0 2rem;
  }
  .input-group-text {
 background: #f7ba5b !important;
 color: white !important;
 border: 0 !important;
 border-radius: 0.25rem 0 0 0.25rem !important;
  }
  .input_user,
  .input_pass:focus {
 box-shadow: none !important;
 outline: 0px !important;
  }

  #messages{
 background-color: grey;
 color: #fff;
 padding: 10px;
 margin-top: 10px;
  }
   



   
  
 



   LOGIN


   
  {% csrf_token %}
  
 

 
 
  
  
 

 

  

 

 
   


{{ form.errors }}
{% for msg in messages %}
{{ msg }}
{% endfor %}

   
  Don't have an account? Sign Up
   


 
  
   


Error:---
NoReverseMatch at /login/
Reverse for 'chitrr' not found. 'chitrr' is not a valid view function or 
pattern name.
| Request Method: | POST |
| Request URL: | http://127.0.0.1:8000/login/ |
| Django Version: | 3.0.5 |
| Exception Type: | NoReverseMatch |
| Exception Value: | Reverse for 'chitrr' not found. 

Re: AttributeError

2020-04-27 Thread 'Amitesh Sahay' via Django users
Do you have a "date" field in your models.py.? Please share models.py, and 
views.py as well

Sent from Yahoo Mail on Android 
 
  On Mon, 27 Apr 2020 at 22:44, Phako Perez<13.phak...@gmail.com> wrote:   I 
think issue is how you are trying to access the attributeThis is a form and 
must be accessed through a post call.
Can you share your html form???

Sent from my iPhone

On 27 Apr 2020, at 10:29, DimGo  wrote:



from django import forms
from django.core.exceptions import ValidationError

class SearchProduct(forms.Form):
 text=forms.CharField(label='Search ')
 date=forms.DateField(required=False)
 
t = SearchProduct()
print(t.date)

Error: 

AttributeError: 'SearchProduct' object has no attribute 'date'



why is there this error? How to fix it? 

ff


-- 
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/445e0ffb-03e7-4a32-9d83-b48795a9866c%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/6FEB0B14-73FF-4A74-80B4-ED982F95D01F%40gmail.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/37640327.684638.1588012361686%40mail.yahoo.com.


Re: AttributeError with forms

2020-04-27 Thread 'Amitesh Sahay' via Django users
I couldn't open the screenshot . But to work with the django forms you need to 
perform below tasks.
1) create model of your choice in models.py.2).  Python manage.py 
makemigrations3) python manage py migrate.4 create a python file called 
forms.py inside your app.5) import your models there ( from .models import 
model_name6) create class to extend forms module.7) in views.py you either need 
to define class based views or function based views. 
I hope that helps.

Sent from Yahoo Mail on Android 
 
  On Mon, 27 Apr 2020 at 20:59, DimGo wrote:   Why 
is this this strange error? 


-- 
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/7a2089af-344a-479d-bf7c-8a943973159b%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/407015029.685337.1588012209457%40mail.yahoo.com.


reg: DRF serializer ot pulling data from User model

2020-04-27 Thread 'Amitesh Sahay' via Django users
Hello All,
DRF failing to pull the data from User model
I have two Serializers for Two models(User model and UserProfile). 
models.py--class UserProfile(models.Model):
Photo = models.FileField(upload_to='documents/%Y/%m/%d/', null=True)
uploaded_at = models.DateTimeField(auto_now_add=True, null=True)
dob = models.DateField(max_length=20, null=True)
country = models.CharField(max_length=100, null=True)
State = models.CharField(max_length=100, null=True)
District = models.CharField(max_length=100, null=True)
phone = models.CharField(max_length=10, null=True)

def __str__(self):
return self.phoneserializers.py-from rest_framework 
import serializers
from django.contrib.auth.models import User
from .models import UserProfile


class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ('first_name', 'last_name', 'email')


class ProfileSerializer(serializers.ModelSerializer):
class Meta:
model = UserProfile
fields = ('Photo', 'dob', 'country', 'State', 'District', 'phone')
views.py
class getUserProfile(generics.ListAPIView):
lookup_field = []
def get(self, *args, **kwargs):
qs = User.objects.all()
qs1 = UserProfile.objects.all()
UserData = UserSerializer(qs).data
ProfileData = ProfileSerializer(qs1).data
return Response({'UserData': UserData, 'ProfileData': ProfileData})


If you one see the above screenshot, it clearly says that "UserData" serializer 
doesn't getting any data, as well as the ProfileData is successfully pulling 
the column names, however, the values are NULL. Below screenshot show that 
there are data in the table
UserData

ProfileData

Please suggest.


Regards,
Amitesh

-- 
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/979964516.653709.1587998763254%40mail.yahoo.com.


Re: Django Rest Framework - Integrating Django Channels

2020-04-24 Thread 'Amitesh Sahay' via Django users
Hi,
Try the below link:Django REST Framework and Channels

| 
| 
| 
|  |  |

 |

 |
| 
|  | 
Django REST Framework and Channels

OddBird

We’ve begun exploring some patterns for how to add WebSocket push notifications 
to what is otherwise a RESTful A...
 |

 |

 |







Regards,
Amitesh Sahay91-750 797 8619 

On Friday, 24 April, 2020, 08:08:31 pm IST, Eesa Munir  
wrote:  
 
 Hello. I am unable to find a way to implement Django channels into a (DRF) 
application. If this is possible, does anybody know how to accomplish this 
easily and efficiently? Thank you.

-- 
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/4783b814-cdb5-4554-8b71-0380b02bbd47%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/305687484.205440.1587740074852%40mail.yahoo.com.


Re: Need help whit DJANGO_SETTINGS_MODULE

2020-04-24 Thread 'Amitesh Sahay' via Django users
DJANGO_SETTINGS_MODULE is not the problem I guess, as its not there even in my 
settings.py. Did you define your app in apps settings? 



Regards,
Amitesh 

On Friday, 24 April, 2020, 06:45:43 pm IST, Raja Sekar Sambath 
 wrote:  
 
 Yes I'm
On Fri, 24 Apr 2020 at 18:30, DANIEL URBANO DE LA RUA 
 wrote:

are you using virtual environment?
El vie., 24 abr. 2020 a las 14:33, Raja Sekar Sambath () 
escribió:

could you share the solution hereresetting PC didn't making any sense to 
me
On Sun, 19 Apr 2020 at 19:19, Ilie Ioana  wrote:

After resetting the pc it worked.Thanks.

On Sunday, April 19, 2020 at 4:39:50 PM UTC+3, Ilie Ioana wrote:
The project structure:


(test1) ioana.i@ioana-spamexperts:~/Workspace/Ioana/test1/test1$ tree.├── 
manage.py└── test1    ├── asgi.py    ├── __init__.py    ├── settings.py    ├── 
urls.py    └── wsgi.py


:~/Workspace/Ioana/test1/test1$ python manage.py runserverTraceback (most 
recent call last):  File "manage.py", line 21, in     main()  File 
"manage.py", line 17, in main    execute_from_command_line(sys.argv)  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py",
 line 401, in execute_from_command_line    utility.execute()  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py",
 line 395, in execute    
self.fetch_command(subcommand).run_from_argv(self.argv)  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py",
 line 328, in run_from_argv    self.execute(*args, **cmd_options)  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
 line 60, in execute    super().execute(*args, **options)  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py",
 line 369, in execute    output = self.handle(*args, **options)  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
 line 67, in handle    if not settings.DEBUG and not settings.ALLOWED_HOSTS:  
File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py",
 line 76, in __getattr__    self._setup(name)  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py",
 line 61, in _setup    % (desc, 
ENVIRONMENT_VARIABLE))django.core.exceptions.ImproperlyConfigured: Requested 
setting DEBUG, but settings are not configured. You must either define the 
environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before 
accessing settings.



On Sunday, April 19, 2020 at 4:35:11 PM UTC+3, Ayser shuhaib wrote:
to run the server use:Python manage.py runserver
It would be better if you send a picture of the project files structure.
On Sun, 19 Apr 2020 at 15:22, Ilie Ioana  wrote:

Hi,I'm new with django and python.I just strated a new django project in a venv 
using django 3.0 and seems that DJANGO_SETTINGS_MODULE is not set when running 
django-admin runserver

Enter code here.(test1) 
ioana.i@ioana-spamexperts:~/Workspace/Ioana/test1/test1$ django-admin 
runserverTraceback (most recent call last):  File 
"/home/ioana.i/Workspace/Ioana/test1/bin/django-admin", line 8, in     
sys.exit(execute_from_command_line())  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py",
 line 401, in execute_from_command_line    utility.execute()  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py",
 line 395, in execute    
self.fetch_command(subcommand).run_from_argv(self.argv)  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py",
 line 328, in run_from_argv    self.execute(*args, **cmd_options)  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
 line 60, in execute    super().execute(*args, **options)  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py",
 line 369, in execute    output = self.handle(*args, **options)  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
 line 67, in handle    if not settings.DEBUG and not settings.ALLOWED_HOSTS:  
File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py",
 line 76, in __getattr__    self._setup(name)  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py",
 line 61, in _setup    % (desc, 
ENVIRONMENT_VARIABLE))django.core.exceptions.ImproperlyConfigured: Requested 
setting DEBUG, but settings are not configured. You must either define the 
environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before 
accessing settings...


 I tried to set it myself 

reg: how to use Jinja template in HTML for django forms

2020-04-24 Thread 'Amitesh Sahay' via Django users
Hi,I have created django forms and the logic is fine, and I have created the 
HTML page to show the form fields. I have attached the screenshot for the 
reference. The problem I am facing two issues as below:-
1) to integrate the django form fields in the HTML page through Jinja.
HTML file:{% load static %}
{% block content %}







https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css;>
https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js";>
https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js";>
Profile Page



  
contact
Sign Up
  Log in
  



{% csrf_token %}


  Profile Photo:
  




DOB: 











Country:   







State:  








District:

 





Phone:    














{{ form.errors }}



{% endblock %}
When I add {{ form.as_p }} near the submit button tag in the HTML file, I am 
getting extra boxes as show in the below screenshot:

The boxes shown below the "click to save" are the ones appearing after using 
{{form.as_p}}. Obviously, its picking up from the django model that I have 
created, and when I enter the data here, its saving the data in the DB.
However, I wish to bind my model to the boxes appearing above the "click to 
save". I have tried adding {{form.photo}}, {{form.country}} and so on below 
each , but its not working. The entire UI is getting distorted. 
2) The "DOB" field is not saving data in DB.
models.py--class UserProfile(models.Model):
Photo = models.FileField(upload_to='documets/%Y/%m/%d/', null=True)
uploaded_at = models.DateTimeField(auto_now_add=True, null=True)
dob = models.DateField(max_length=20, null=True)
country = models.CharField(max_length=100, null=True)
State = models.CharField(max_length=100, null=True)
District = models.CharField(max_length=100, null=True)
phone = models.CharField(max_length=10, null=True)forms.pyfrom 
django import forms
from .models import UserProfile


class ProfileForm(forms.ModelForm):
Photo = forms.FileField( max_length=100)
dob = forms.DateField()
country = forms.CharField(max_length=100)
State = forms.CharField(max_length=100)
District = forms.CharField(max_length=100)
phone = forms.CharField(max_length=10)

class Meta:
model = UserProfile
fields = ('Photo', 'dob', 'country', 'State', 'District', 
'phone')screenshot from the table query from 
DB--

As one could see that every field from the model is sending data to the DB but 
DOB.
Please help..


Regards,
Amitesh

-- 
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/225658712.187807.1587733349680%40mail.yahoo.com.


Re: Reg: Django signal not working

2020-04-22 Thread 'Amitesh Sahay' via Django users
Hello Sahil,
Thank you for the youtube link. The video has done the exactly same thing that 
I am doing. However, I understand that the user registration is created through 
default "User" model, and UserCreationForm. However, I am adding a custom field 
"city", and its not working for me. 
Except the city, all other default is saved into the database.(Username, 
first_name, last_name, email, password)
I have already shared the code snippet here in my previous emails. If possible 
go through it and let me know .


Regards,
Amitesh 

On Tuesday, 21 April, 2020, 06:33:42 pm IST, sahil khan 
 wrote:  
 
 Hello i am from google group plz see this video chennel and solve your 
problemhttps://youtu.be/QDk3rI_H3ks like comment and subscribe and share so 
that another people get help this channel 

On Mon, 20 Apr 2020, 4:28 pm Aditya Singh,  wrote:

What's the original issue please, seems like you picked things up with someone 
till this email.Regards,Aditya
On Mon, Apr 20, 2020, 3:11 PM 'Amitesh Sahay' via Django users 
 wrote:

-+c Hello Jorge, 
After doing some research, I realized that the signal which is saving the user 
profile should have 
"instance.signup.save()" , as the name of the custom model is signup. This time 
I still got the error .However,  I could create the new user and login to the 
website. However, when I look into the admin panel, I still could't see the 
"contact" field getting saved after the user is registered successfully. 
Therefore the main purpose of creating the custom User model still failing. 
Below are the code snippet, and screenshot from my admin panel.
Models.py-from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver


class SignUp(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
Contact = models.CharField(max_length=500, blank=True)

@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
SignUp.objects.create(user=instance)

@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
save2 = instance.signup.save()
print(save2)
To debug the issue, I used the print statement to see the output of 
"instance.signup.save()". So, after submitting the form, I checked the 
"runserver" console. The output was "None". So, something doesn't seems to be 
right.
forms.py--from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django import forms
from .models import SignUp


class SignUpForm(UserCreationForm):
email = forms.EmailField()
first_name = forms.CharField(max_length=100)
last_name = forms.CharField(max_length=100)

class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email', 'password1', 
'password2')


class CustomSignUpPage(forms.ModelForm):
Contact = forms.CharField(max_length=10)

class Meta:
model = SignUp
fields = ('Contact', )
views.py-def register_user(request):
if request.method == "POST":
form = SignUpForm(request.POST)
cus_form = CustomSignUpPage(request.POST)
if form.is_valid() and cus_form.is_valid():
save1 = form.save()
save1.refresh_from_db()
cus_form = CustomSignUpPage(request.POST, 
instance=request.save1.signup.contact)
cus_form.full_clean()
cus_form.save()
username = form.cleaned_data['username']
password = form.cleaned_data['password1']
user = authenticate(request, username=username, password=password)
login(request, user)
messages.success(request, f'Registration successful')
return redirect('home')
else:
messages.error(request, f'Please correct the error below.')
else:
form = SignUpForm()
cus_form = CustomSignUpPage()

return render(request, 'authenticate\\register.html', context={'form': 
form, 'cus_form': cus_form})Screenshot from the admin panel:
Please suggest. If you are comfortable we can go on a web meeting where I can 
share my screen and we can work on it.
Regards,Amitesh

Sent from Yahoo Mail on Android 
 
  On Sun, 19 Apr 2020 at 19:42, Jorge Gimeno wrote:   
Amitesh,

Where is User.profile defined?

-Jorge

On 4/18/20, Saurabh Ranjan Singh  wrote:
> I am having the same issue. Please fix it.
>
> On Friday, 17 April 2020 22:47:40 UTC+5:30, Amitesh Sahay wrote:
>>
>> Hi,
>>
>> I am creating a Django signup form through "User" model and
>> "UserCreationForm" and customized the User model to accommodate single
>> user
>> defined field "contact".
>>
>> Ho

Re: Reg: Django signal not working

2020-04-20 Thread 'Amitesh Sahay' via Django users
Hello Aditya,
I am using Django's "User" and "UserCreationForm" to create registration and 
login page and it's backend logic. So far so good. I could add the default 
fields to my registration page and it's working as per required.
However, I want to add a custom field "contact" as it does not come in-built. 
But no matter what I am not able to do it.
I have already shared the code in my previous email. Please go through it and 
let me know if you can help me somehow.
Thank you
Amitesh

Sent from Yahoo Mail on Android 
 
  On Mon, 20 Apr 2020 at 16:28, Aditya Singh 
wrote:   What's the original issue please, seems like you picked things up with 
someone till this email.Regards,Aditya
On Mon, Apr 20, 2020, 3:11 PM 'Amitesh Sahay' via Django users 
 wrote:

-+c Hello Jorge, 
After doing some research, I realized that the signal which is saving the user 
profile should have 
"instance.signup.save()" , as the name of the custom model is signup. This time 
I still got the error .However,  I could create the new user and login to the 
website. However, when I look into the admin panel, I still could't see the 
"contact" field getting saved after the user is registered successfully. 
Therefore the main purpose of creating the custom User model still failing. 
Below are the code snippet, and screenshot from my admin panel.
Models.py-from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver


class SignUp(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
Contact = models.CharField(max_length=500, blank=True)

@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
SignUp.objects.create(user=instance)

@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
save2 = instance.signup.save()
print(save2)
To debug the issue, I used the print statement to see the output of 
"instance.signup.save()". So, after submitting the form, I checked the 
"runserver" console. The output was "None". So, something doesn't seems to be 
right.
forms.py--from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django import forms
from .models import SignUp


class SignUpForm(UserCreationForm):
email = forms.EmailField()
first_name = forms.CharField(max_length=100)
last_name = forms.CharField(max_length=100)

class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email', 'password1', 
'password2')


class CustomSignUpPage(forms.ModelForm):
Contact = forms.CharField(max_length=10)

class Meta:
model = SignUp
fields = ('Contact', )
views.py-def register_user(request):
if request.method == "POST":
form = SignUpForm(request.POST)
cus_form = CustomSignUpPage(request.POST)
if form.is_valid() and cus_form.is_valid():
save1 = form.save()
save1.refresh_from_db()
cus_form = CustomSignUpPage(request.POST, 
instance=request.save1.signup.contact)
cus_form.full_clean()
cus_form.save()
username = form.cleaned_data['username']
password = form.cleaned_data['password1']
user = authenticate(request, username=username, password=password)
login(request, user)
messages.success(request, f'Registration successful')
return redirect('home')
else:
messages.error(request, f'Please correct the error below.')
else:
form = SignUpForm()
cus_form = CustomSignUpPage()

return render(request, 'authenticate\\register.html', context={'form': 
form, 'cus_form': cus_form})Screenshot from the admin panel:
Please suggest. If you are comfortable we can go on a web meeting where I can 
share my screen and we can work on it.
Regards,Amitesh

Sent from Yahoo Mail on Android 
 
  On Sun, 19 Apr 2020 at 19:42, Jorge Gimeno wrote:   
Amitesh,

Where is User.profile defined?

-Jorge

On 4/18/20, Saurabh Ranjan Singh  wrote:
> I am having the same issue. Please fix it.
>
> On Friday, 17 April 2020 22:47:40 UTC+5:30, Amitesh Sahay wrote:
>>
>> Hi,
>>
>> I am creating a Django signup form through "User" model and
>> "UserCreationForm" and customized the User model to accommodate single
>> user
>> defined field "contact".
>>
>> However, the signal that I have written seems not to be working.
>> Whenever, I am filling the form, I am getting below error:
>>
>> AttributeError at /auth/register/
>> 'User' object has no attribute 'profile'
>>

Re: Reg: Django signal not working

2020-04-20 Thread 'Amitesh Sahay' via Django users
-+c Hello Jorge, 
After doing some research, I realized that the signal which is saving the user 
profile should have 
"instance.signup.save()" , as the name of the custom model is signup. This time 
I still got the error .However,  I could create the new user and login to the 
website. However, when I look into the admin panel, I still could't see the 
"contact" field getting saved after the user is registered successfully. 
Therefore the main purpose of creating the custom User model still failing. 
Below are the code snippet, and screenshot from my admin panel.
Models.py-from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver


class SignUp(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
Contact = models.CharField(max_length=500, blank=True)

@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
SignUp.objects.create(user=instance)

@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
save2 = instance.signup.save()
print(save2)
To debug the issue, I used the print statement to see the output of 
"instance.signup.save()". So, after submitting the form, I checked the 
"runserver" console. The output was "None". So, something doesn't seems to be 
right.
forms.py--from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django import forms
from .models import SignUp


class SignUpForm(UserCreationForm):
email = forms.EmailField()
first_name = forms.CharField(max_length=100)
last_name = forms.CharField(max_length=100)

class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email', 'password1', 
'password2')


class CustomSignUpPage(forms.ModelForm):
Contact = forms.CharField(max_length=10)

class Meta:
model = SignUp
fields = ('Contact', )
views.py-def register_user(request):
if request.method == "POST":
form = SignUpForm(request.POST)
cus_form = CustomSignUpPage(request.POST)
if form.is_valid() and cus_form.is_valid():
save1 = form.save()
save1.refresh_from_db()
cus_form = CustomSignUpPage(request.POST, 
instance=request.save1.signup.contact)
cus_form.full_clean()
cus_form.save()
username = form.cleaned_data['username']
password = form.cleaned_data['password1']
user = authenticate(request, username=username, password=password)
login(request, user)
messages.success(request, f'Registration successful')
return redirect('home')
else:
messages.error(request, f'Please correct the error below.')
else:
form = SignUpForm()
cus_form = CustomSignUpPage()

return render(request, 'authenticate\\register.html', context={'form': 
form, 'cus_form': cus_form})Screenshot from the admin panel:
Please suggest. If you are comfortable we can go on a web meeting where I can 
share my screen and we can work on it.
Regards,Amitesh

Sent from Yahoo Mail on Android 
 
  On Sun, 19 Apr 2020 at 19:42, Jorge Gimeno wrote:   
Amitesh,

Where is User.profile defined?

-Jorge

On 4/18/20, Saurabh Ranjan Singh  wrote:
> I am having the same issue. Please fix it.
>
> On Friday, 17 April 2020 22:47:40 UTC+5:30, Amitesh Sahay wrote:
>>
>> Hi,
>>
>> I am creating a Django signup form through "User" model and
>> "UserCreationForm" and customized the User model to accommodate single
>> user
>> defined field "contact".
>>
>> However, the signal that I have written seems not to be working.
>> Whenever, I am filling the form, I am getting below error:
>>
>> AttributeError at /auth/register/
>> 'User' object has no attribute 'profile'
>>
>> *Full traceback log as below:*
>>
>> Installed Applications:
>> ['django.contrib.admin',
>>  'django.contrib.auth',
>>  'django.contrib.contenttypes',
>>  'django.contrib.sessions',
>>  'django.contrib.messages',
>>  'django.contrib.staticfiles',
>>  'phone_field',
>>  'AUTHENTICATION']
>> Installed 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']
>>
>>
>>
>> Traceback (most recent call last):
>>  File "C:\Python38\lib\site-packages\django\core\handlers\exception.py",
>>
>> line 34, in inner
>>    response = get_response(request)
>>  File "C:\Python38\lib\site-packages\django\core\handlers\base.py", line
>>
>> 115, in _get_response
>>    

Reg: Django signal not working

2020-04-17 Thread 'Amitesh Sahay' via Django users
Hi,
I am creating a Django signup form through "User" model and "UserCreationForm" 
and customized the User model to accommodate single user defined field 
"contact".

However, the signal that I have written seems not to be working.
Whenever, I am filling the form, I am getting below error:
AttributeError at /auth/register/'User' object has no attribute 'profile'
Full traceback log as below:
Installed Applications:['django.contrib.admin', 'django.contrib.auth', 
'django.contrib.contenttypes', 'django.contrib.sessions', 
'django.contrib.messages', 'django.contrib.staticfiles', 'phone_field', 
'AUTHENTICATION']Installed 
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']


Traceback (most recent call last):  File 
"C:\Python38\lib\site-packages\django\core\handlers\exception.py", line 34, in 
inner    response = get_response(request)  File 
"C:\Python38\lib\site-packages\django\core\handlers\base.py", line 115, in 
_get_response    response = self.process_exception_by_middleware(e, request)  
File "C:\Python38\lib\site-packages\django\core\handlers\base.py", line 113, in 
_get_response    response = wrapped_callback(request, *callback_args, 
**callback_kwargs)  File 
"C:\Users\anshu\djago-project\SkoolSkill\AUTHENTICATION\views.py", line 50, in 
register_user    save1 = form.save()  File 
"C:\Python38\lib\site-packages\django\contrib\auth\forms.py", line 137, in save 
   user.save()  File 
"C:\Python38\lib\site-packages\django\contrib\auth\base_user.py", line 66, in 
save    super().save(*args, **kwargs)  File 
"C:\Python38\lib\site-packages\django\db\models\base.py", line 745, in save    
self.save_base(using=using, force_insert=force_insert,  File 
"C:\Python38\lib\site-packages\django\db\models\base.py", line 793, in 
save_base    post_save.send(  File 
"C:\Python38\lib\site-packages\django\dispatch\dispatcher.py", line 173, in 
send    return [  File 
"C:\Python38\lib\site-packages\django\dispatch\dispatcher.py", line 174, in 
    (receiver, receiver(signal=self, sender=sender, **named))  File 
"C:\Users\anshu\djago-project\SkoolSkill\AUTHENTICATION\models.py", line 17, in 
save_user_profile    instance.profile.save()
Exception Type: AttributeError at /auth/register/Exception Value: 'User' object 
has no attribute 'profile'
I have uploaded the project in google drive with below location link, just in 
case if somebody wishes to test it.
https://drive.google.com/file/d/1COB3BBoRb95a85cLi9k1PdIYD3bmlnc0/view?usp=sharing
My environment:
Django==3.0.5 python 3.8.2
Not sure what is the mistake. Please help.
models.py
from django.db import modelsfrom django.contrib.auth.models import Userfrom 
django.db.models.signals import post_savefrom django.dispatch import receiver
class SignUp(models.Model):    user = models.OneToOneField(User, 
on_delete=models.CASCADE)    Contact = models.TextField(max_length=500, 
blank=True)
@receiver(post_save, sender=User)def create_user_profile(sender, instance, 
created, **kwargs):    if created:        SignUp.objects.create(user=instance)
@receiver(post_save, sender=User)def save_user_profile(sender, instance, 
**kwargs):    instance.profile.save()
forms.py
from django.contrib.auth.forms import UserCreationFormfrom 
django.contrib.auth.models import Userfrom django import formsfrom  .models 
import SignUp
class SignUpForm(UserCreationForm):    email = forms.EmailField()    first_name 
= forms.CharField(max_length=100)    last_name = 
forms.CharField(max_length=100)#    phone = format()
    class Meta:        model = User        fields = ('username', 'first_name', 
'last_name', 'email', 'password1', 'password2')

class CustomSignUpPage(forms.ModelForm):    Contact = 
forms.CharField(max_length=10)    class Meta:        model = SignUp        
fields = ('Contact', )
views.py
from django.shortcuts import render, redirectfrom django.contrib.auth import 
authenticate, login, logoutfrom django.contrib import messages#from 
django.contrib.auth.forms import UserCreationFormfrom .forms import SignUpForm, 
CustomSignUpPage
def home(request):   return render(request, 'authenticate\home.html', {})
def login_user(request):   if request.method == 'POST':      username = 
request.POST['username']      password = request.POST['password']      user = 
authenticate(request, username=username, password=password)      if user is not 
None:         login(request, user)         messages.success(request, ('login 
success'))         return redirect('home')      else:         
messages.success(request, ('error while login, please try again'))         
return redirect('login')   else:      return render(request, 
'authenticate\login.html', {})
def logout_user(request):   

reg: CUstomizing User model

2020-04-17 Thread 'Amitesh Sahay' via Django users
Hi, 
I am creating the user signup form with the help of "UserCreationForm" and 
"User" model. So, whatever came in-built is working fine for me, I am able to 
successfully create the sign up and form and able to authenticate. So far so 
good. 
Now, I am trying to add a new "phone" field in the existing User model as per 
my customization plan. 
1) So, as per the user model customization process I make the entries in the 
models.py
from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver

class SignUp(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
Contact = models.TextField(max_length=500, blank=True)


@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
SignUp.objects.create(user=instance)

@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
instance.profile.save() 2) python manage.py makemigrations3) python 
manage.py migrate4) I added the newly defined model in my forms.py as below:
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django import forms
from  .models import SignUp

class SignUpForm(UserCreationForm): # Default signup page layout
email = forms.EmailField()
first_name = forms.CharField(max_length=100)
last_name = forms.CharField(max_length=100)

class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email', 'password1', 
'password2')


class SignUpPage(UserCreationForm): # Newly added model
phone = forms.CharField(max_length=10)
class Meta:
model = User
fields = ('phone', )But I am not sure if I needed to create a separate 
class for that, or I should add the extra field in the same default sign up 
page layout. Below is my views.py for the default layout
from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login, logout
from django.contrib import messages
#from django.contrib.auth.forms import UserCreationForm
from .forms import SignUpForm, SignUp

def home(request):
   return render(request, 'authenticate\home.html', {})

def login_user(request):
   if request.method == 'POST':
  username = request.POST['username']
  password = request.POST['password']
  user = authenticate(request, username=username, password=password)
  if user is not None:
 login(request, user)
 messages.success(request, ('login success'))
 return redirect('home')
  else:
 messages.success(request, ('error while login, please try again'))
 return redirect('login')
   else:
  return render(request, 'authenticate\login.html', {})

def logout_user(request):
   logout(request)
   messages.success(request, ('logout successful'))
   return redirect('home')


def register_user(request):
   if request.method == "POST":
  form = SignUpForm(request.POST)
  if form.is_valid():
 form.save()
 username = form.cleaned_data['username']
 password = form.cleaned_data['password1']
 user = authenticate(request, username=username, password=password)
 login(request, user)
 messages.success(request, ('Registration successful'))
 return redirect('home')
  else:
 form = SignUpForm()
  return render(request, 'authenticate\\register.html', context={'form': 
form})

As one can see that I have imported the required class from forms.py, but I am 
not able to recognize the place where I can call it in "register_user" in 
views.py.Please help. Also correct if I have done anything wrong.

Regards,
Amitesh 

-- 
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/1470388256.1447595.1587121976643%40mail.yahoo.com.


reg: Error:-django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'Description' used in key specification without a key length")

2020-02-24 Thread 'Amitesh Sahay' via Django users
Hi, 
I am creating a model, which is taking a description as text field. when I 
migrate I see the below error:
django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'Description' used 
in key specification without a key length")

ON further research I came to know that its some limitation with MySQL. I am 
using MYSQL for my dev. Below is the link that describes the issue.
MySQL error: key specification without a key length

| 
| 
| 
|  |  |

 |

 |
| 
|  | 
MySQL error: key specification without a key length

I have a table with a primary key that is a varchar(255). Some cases have 
arisen where 255 characters isn't enou...
 |

 |

 |


So what am I suppose to use if not TextField? I have tried CharField, that 
doesn't work either. Below is the model details:
class OnlineShop(models.Model):
Product_name = models.CharField(max_length=100, unique=True)
Price = models.IntegerField()
Slug = models.SlugField(max_length=250, unique=True)
Description = models.TextField()
Curr_Time = models.DateTimeField(auto_now_add=True)

def __str__(self):
return '{}'.format(self.Product_name)



Regards,
Amitesh Sahay91-750 797 8619

-- 
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/1073924601.858407.1582555396348%40mail.yahoo.com.


Re: Understanding of GIL

2020-01-16 Thread 'Amitesh Sahay' via Django users
Hi, 

You should also undertand that Python uses GIL for Threading purpose. Yes, if 
you have functiosn that needs simulataneous execution you should use Threading 
approach. As well as if Huge data is involved then also use multi-processing 
concept as well
 

On Thursday, 19 December, 2019, 7:42:12 pm IST, onlinejudge95 
 wrote:  
 
 Hi Devs,
I am currently writing some custom Django commands for data updation, my 
workflow is like
Fetch data from PostgreSQL.Call Elasticsearch for searching based on the data 
fetched from PostgreSQL.Query PostgreSQL and do an upsert behavior.
I am using pandas data frame to hold my data during processing.

The host we are using to run this jobs has a CPython interpreter as given by

`platform.python_implementation()`

I want to confirm whether multithreading would be a better choice here, given 
the fact that GIL is the biggest blocker(I agree it has to be there) for the 
same in CPython interpreters.

In case further information is required do let me know.

Thanksonlinejudge95

-- 
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/CAD%3DM5eRWh9-EB180f2OzvnPLHh969vgaCzFyniFRSFa1-CwUHA%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/551451096.10373381.1579167791939%40mail.yahoo.com.


reg: Building Django REST API to show number of matching pattern from log file

2020-01-13 Thread 'Amitesh Sahay' via Django users
Hello Users, 

I have a scenario for which I need to develop a Web API through Django 
RESTFrameWork.
1) We have a multiple linux machines on which a  log file is generated as soon 
as there is some change in hash value of a license file . The log file 
generation and the license file monitoring has been automated through Python 
script on the servers itself. So far so good.
2) Now, I need develop an API that will read the matching pattern from the log 
file, and push it to the DB.
3) I also need to develop a dashboard where we can pull data on Daily, Weekly, 
monthly, and Yearly basis and show graph.
So far, I could do some testing with the Python RegEx to catch the matching 
pattern and its fine. But the problem is how to use DRF to pull those matching 
pattern directly from the log file to the DB each time the patter is generated 
in real time? I have been brainstorming for 3 days now, but reached nowhere.
Note:1) There is a log rotation happening I believe every 24 hours, and the log 
files are kept only for seven days. Prior to that the logs get deleted. 

I am not sure even if its possible, or what would be my approach.Please pour in 
with your suggestions.


Regards,
Amitesh 

-- 
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/1342849622.9012128.1578913093968%40mail.yahoo.com.


Re: Strange issue with django

2019-12-27 Thread 'Amitesh Sahay' via Django users
Also let us know the procedure that you adopted to upgrade to the new version?



Regards,
Amitesh
 

On Thursday, 26 December, 2019, 10:19:31 pm IST, Jason 
 wrote:  
 
 Also, you haven't stated where the bottlenecks are happening.  Is it app code, 
internal in django, your stack, database, networking?  There's alot of 
variables in play for diagnosing a major slowdown, and you've provided no 
information about profiling/monitoring

-- 
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/37b9526a-756f-4ac7-835a-af49f0dada02%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/2119895222.3536368.1577439175073%40mail.yahoo.com.


Re: Strange issue with django

2019-12-26 Thread 'Amitesh Sahay' via Django users
Could you please let us know which part of the DRF performance dipped? We can 
try to troubleshoot accordingly.
Your statements are very generic.


Regards,
Amitesh 
 

On Thursday, 26 December, 2019, 7:51:28 pm IST, Andréas Kühne 
 wrote:  
 
 Yeah - we have gone through the release notes - and performance wise the 
environment is the same but we got an extreme performance dip - we have been 
trying to check where we have taken performance hits - but it seems to be 
random and also in places where we didn't have any issues previously
We have checked the places where we are taking hits - but my main thing is I 
would like to find out WHY this has happened - because it just happened 
spontaneously

Regards,
Andréas

Den tors 26 dec. 2019 kl 15:09 skrev Integr@te System 
:

Hi Andreas,
Let try:# Perf tip 
https://gawron.sdsu.edu/compling/course_core/python_intro/intro_lecture_files/fastpython.html
# Release note Django 3.0, DRF vs. best version

Hope this helpful.


On Thu, Dec 26, 2019, 20:46 Andréas Kühne  wrote:

Hi all,
We have a django backend for our application - running with DRF. This has been 
working perfectly since November last year. Now we have upgraded to django 3.0 
and also DRF to the latest version. We also added some DB indexes. After this 
upgrade we now have certain endpoints that went up to 25 s loading time (from 
about 5 s). We have reverted most of these changes and gone through our code 
but still can't find where this issue is.
We even reverted back to django 2.2 and the previous version of DRF which gave 
us reasonable speed, but it still doesn't work correctly. 
Does anyone have any ideas what the issue might be?
Regards,
Andréas

-- 
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/CAK4qSCe1Nr3c41OOG2zKz3yt2z0pEE4G-629wWsRkLeHjqaNRQ%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/CAP5HUWp2gXjRCKeqB5i3EZeSdp-tJUkHpkiUQUEJETCWp05ErQ%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/CAK4qSCdbL1h1b1dqhoLQh%3DTQ127XU0cx2Kp7KbCNKJzz_nVwYA%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/1339206341.3272866.1577370248968%40mail.yahoo.com.


Re: reg: How to call multiple APIView in one single web page as a list of items?

2019-12-04 Thread 'Amitesh Sahay' via Django users
Hi,
There is no error. But based on the urls settings I could see the "QuizList" 
output to my web page. Other than that, other serializers are not being 
displayed there. Below is the serializers.py 
from rest_framework import serializers
from .models import Quiz, Question, QuizTakers, Answer, User
from django.contrib.auth import authenticate, login


class userSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = 'email'


class QuizSerializer(serializers.ModelSerializer):
class Meta:
model = Quiz()
fields = ('name', 'questions_count', 'description', 'created', 
'roll_out')

def createQuestion(self, validated_data):
return Question().objects.create_question(**validated_data)


class AnswerSerializer(serializers.ModelSerializer):
class Meta:
model = Answer()
fields = ('question', 'text', 'is_correct')


class QuestionSerializer(serializers.ModelSerializer):

class Meta:
model = Question()
fields = ('quiz', 'label', 'order')


class QuizTakerSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = QuizTakers()
fields = ('user', 'quiz', 'correct_answers', 'completed', 'timestamp')



Regards,
Amitesh 

On Thursday, 5 December, 2019, 12:19:34 am IST, Integr@te System 
 wrote:  
 
 Hi Issuer, Plz show result with errors.
Tks.
On Thu, Dec 5, 2019, 01:31 'Amitesh Sahay' via Django users 
 wrote:

I am in the process of developing a small project using django rest framework, 
and within that requirement, I need to list every table in one single page. 
Below is the code snippet.
class QuizList(APIView):
renderer_classes = [TemplateHTMLRenderer]
template_name = 'adminView.html'

def get(self, request):
queryset = Quiz.objects.all()
return Response({'quiz': queryset})


class AnswerList(APIView):
renderer_classes = [TemplateHTMLRenderer]
template_name = 'adminView.html'

def get(self, request):
queryset = Answer.objects.all()
return Response({'answer': queryset})


class QuestionList(APIView):
renderer_classes = [TemplateHTMLRenderer]
template_name = 'adminView.html'

def get(self, request):
queryset = Question.objects.all()
return Response({'question': queryset})
In the above snippet, I am able to list the very first class "QuizView" on my 
web page. But other than that, when I am trying to add other APIViews, they are 
simply not happening. Below is the HTML template:




Admin View



{% for quizez in quiz %}

{{ quizez.name }}
{% endfor %}




{% for questions in question %}
{{ questions.label }}
{% endfor %}



{% for answers in answer %}
{{ answer.text }}
{% endfor %}




I tried to put all the for loops within a single "ul", but even that didn't 
work. Please help.

Thank you


-- 
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/1895937763.9174288.1575484276499%40mail.yahoo.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/CAP5HUWo1YnZf9Y0cOUYtYc-noQTzVz%3Do90k9Fy37SD%2BPcqQ75Q%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/2093858531.9194413.1575486878110%40mail.yahoo.com.


Re: what tool will be using for Continues integration in python projects??

2019-12-04 Thread 'Amitesh Sahay' via Django users
GIT, JENKINS, Travis CI, bitbucket. Jeera.


Regards,
Amitesh 

On Wednesday, 4 December, 2019, 11:43:45 pm IST, Integr@te System 
 wrote:  
 
 Hi,Pythonist(a) -pybuilder.
On Thu, Dec 5, 2019, 00:52 DANIEL URBANO DE LA RUA  
wrote:

You can use jenkins with whatever language you use

-- 
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/ac939c48-a145-4d55-9a26-443151275676%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/CAP5HUWqTvHzgjxgqES63OE49yt6_Gwp3ThwYnVJsUT9VGrtSww%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/792737415.9217546.1575484452404%40mail.yahoo.com.


reg: How to call multiple APIView in one single web page as a list of items?

2019-12-04 Thread 'Amitesh Sahay' via Django users
I am in the process of developing a small project using django rest framework, 
and within that requirement, I need to list every table in one single page. 
Below is the code snippet.
class QuizList(APIView):
renderer_classes = [TemplateHTMLRenderer]
template_name = 'adminView.html'

def get(self, request):
queryset = Quiz.objects.all()
return Response({'quiz': queryset})


class AnswerList(APIView):
renderer_classes = [TemplateHTMLRenderer]
template_name = 'adminView.html'

def get(self, request):
queryset = Answer.objects.all()
return Response({'answer': queryset})


class QuestionList(APIView):
renderer_classes = [TemplateHTMLRenderer]
template_name = 'adminView.html'

def get(self, request):
queryset = Question.objects.all()
return Response({'question': queryset})
In the above snippet, I am able to list the very first class "QuizView" on my 
web page. But other than that, when I am trying to add other APIViews, they are 
simply not happening. Below is the HTML template:




Admin View



{% for quizez in quiz %}

{{ quizez.name }}
{% endfor %}




{% for questions in question %}
{{ questions.label }}
{% endfor %}



{% for answers in answer %}
{{ answer.text }}
{% endfor %}




I tried to put all the for loops within a single "ul", but even that didn't 
work. Please help.

Thank you

-- 
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/1895937763.9174288.1575484276499%40mail.yahoo.com.


Re: reg: django Model for MCQs type project

2019-11-21 Thread 'Amitesh Sahay' via Django users
Hi Yoo, 

Thank you for your detailed reply. 
while I was waiting for some response. I did some research and I came up with 
some model as below. Please go through it and suggest the changes.
from django.db import models
from django.contrib.auth.models import User
from django.template.defaultfilters import slugify
from django.db.models.signals import post_save, pre_save
from django.dispatch import receiver


class Quiz(models.Model):
name = models.CharField(max_length=1000)
questions_count = models.IntegerField(default=0)
description = models.CharField(max_length=70)
created = models.DateTimeField(auto_now_add=True,null=True,blank=True)
slug = models.SlugField()
roll_out = models.BooleanField(default=False)

class Meta:
ordering = ['created', ]
verbose_name_plural = 'Quizzes'

def __str__(self):
return self.name


class Question(models.Model):
quiz = models.ForeignKey(Quiz, on_delete=models.CASCADE)
label = models.CharField(max_length=1000)
order = models.IntegerField(default=0)

def __str__(self):
return self.label


class Answer(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
text = models.CharField(max_length=1000)
is_correct = models.BooleanField(default=False)

def __str__(self):
return self.text


class QuizTakers(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
quiz = models.ForeignKey(Quiz, on_delete=models.CASCADE)
correct_answers = models.IntegerField(default=0)
completed = models.BooleanField(default=False)
timestamp = models.DateTimeField(auto_now_add=True)

def __str__(self):
return self.user.username


class Response(models.Model):
quiztaker = models.ForeignKey(QuizTakers, on_delete=models.CASCADE)
question = models.ForeignKey(Question, on_delete=models.CASCADE)
answer = 
models.ForeignKey(Answer,on_delete=models.CASCADE,null=True,blank=True)

def __str__(self):
return self.question.label


@receiver(post_save, sender=Quiz)
def set_default_quiz(sender, instance, created, **kwargs):
quiz = Quiz.objects.filter(id=instance.id)

quiz.update(questions_count=instance.question_set.filter(quiz=instance.pk).count())


@receiver(post_save, sender=Question)
def set_default(sender, instance, created, **kwargs):
quiz = Quiz.objects.filter(id=instance.quiz.id)

quiz.update(questions_count=instance.quiz.question_set.filter(quiz=instance.quiz.pk).count())


@receiver(pre_save, sender=Quiz)
def slugify_title(sender, instance, *args, **kwargs):
instance.slug = slugify(instance.name)




Regards,
Amitesh 
 

On Thursday, 21 November, 2019, 11:54:57 AM IST, Yoo 
 wrote:  
 
 Have a Test model which as a unique identifier (BigAutoField). Get a Questions 
model with a foreign key to a test and a charfield for the question itself (you 
can add BrinIndex for optimization). You can add a booleanfield if the question 
is optional and whatever else you need (like the correct answer letter). Get an 
Answers model with a foreign key to a specific question. This is the most 
efficient.

You say you don’t need authentication, but it looks like students need some 
kind of it... BUT there is an alternative. If the student doesn’t have to fill 
out their name, then, using paths, you can show the student a URL that is 
connected to a record on another model. 

It could look like this: example.com/test/3?completed=846

With the path of completed=846, a view can query this new model, we’ll call 
Completed, that has the following attributes (columns): id (BigAutoField) and 
Your_Answers (ArrayField/JSONField Both PostgreSQL only). The view does a query 
on the test (test 3) to show and now also has data from the Completed table at 
the row with id=846.

Just to open your mind up to another world WHICH IS NOT EFFICIENT AND NOT 
PRETTY TO IMPLEMENT SO PLEASE DO NOT DO IT... You could also try it with 
PostgreSQL’s JSON attribute. Just make a test model which includes a unique 
identifier and a json field. The JSON field would just have keys be the 
question number (1-10) and then a... nvm here’s an example of a piece of json.

{
  1: {“question”: “What is your name?”,
      “answers”: [“blah1”, “blah2”, “blah3”] }
  2: {“question”: “What is your ethnicity?”,
      “answers”: [“blah1”, “blah2”, “blah3”] }
}

You could also try it NoSQL style with MongoDB. Each document is a test with a 
unique identifier
Good luck!
On Wednesday, November 20, 2019 at 12:21:38 AM UTC-5, Amitesh Sahay wrote:
> Hello Members,
> 
> 
> I have below requirements for a project where I need to develop the model 
> based on "multiple Choice Questions". Below are the criteria:-
> 
> 
> 
> Admin can create/edit/delete(soft delete only) a "Test" in the form of 
> MCQs.Admin can then create/edit/delete a "Question"
>  to each test. Each question contains the actual question, the correct 
> answer and 3 incorrect answers. An 

reg: django Model for MCQs type project

2019-11-19 Thread 'Amitesh Sahay' via Django users
Hello Members,
I have below requirements for a project where I need to develop the model based 
on "multiple Choice Questions". Below are the criteria:-
   
   - Admin can create/edit/delete(soft delete only) a "Test" in the form of 
MCQs.
   - Admin can then create/edit/delete a "Question" to each test. Each question 
contains the actual question, the correct answer and 3 incorrect answers. An 
admin can mark a question as mandatory or optional. An optional question can be 
skipped by the student.
   - Admin can also set the marks for each question
   - Student can view a testStudent can attempt a test. Every test can be 
attempted multiple times. Each attempt is scored and saved separately. 
   - Since the questions are in MCQ format, the students answers are 
auto-evaluated by the application.

This is something very new for me. So, I am little reluctant on how to create 
the model for the above requirement. Here I do not need to develop any 
authentication environment. 

Any help would be highly appreciated.



Regards,
Amitesh

-- 
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/717890174.2580735.1574227227426%40mail.yahoo.com.


Re: reg: creating blog topic in database

2019-11-19 Thread 'Amitesh Sahay' via Django users
I have got a work around though, and yes, those two links were handy.



Regards,
Amitesh
 

On Monday, 18 November, 2019, 6:27:01 PM IST, 'Amitesh Sahay' via Django 
users  wrote:  
 
 Hi, 

To be honest, I have tried following the django docs link that you have shared. 
But I failed to understand the relevance . I have little knowledge. So, I might 
be little clueless here.



Regards,
Amitesh
 

On Saturday, 16 November, 2019, 5:00:11 PM IST, Integr@te System 
 wrote:  
 
 Hi Issuer
Follow to part 3 - 4 and check docs for some thing else around you need
https://docs.djangoproject.com/en/2.2/ref/templates/language/
https://docs.djangoproject.com/en/2.2/intro/tutorial04/

On Sat, Nov 16, 2019, 16:40 'Amitesh Sahay' via Django users 
 wrote:

Hello All,
I have created the two models to create post on desired topic, as well as to 
get the comments from the visitors. But, I am not able to figure out, how to 
connect that model to my HTML page. 

I know how to create a static HTML pages for each topic,and write page content 
in  tags. which I have been thinking to do until now, but it seems to be 
a time taking and non-productive way. So, now I would like to write posts in my 
database model which I have registered in admin.py. 

Any idea, how can I achieve this, as this would be a like generating dynamic 
HTML pages based on models.

I am not sure if I was able to explain my requirements. May be as I am not 
getting right words to express them. Please ask me questions if any confusion, 
I will try to answer them. 

Below is my models.py 

from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User


class Post(models.Model):
STATUS_CHOICES = (
('draft', 'Draft'),
('published', 'Published'),
)
title = models.CharField(max_length=250)
slug = models.SlugField(max_length=250, unique_for_date='publish')
author = models.ForeignKey(User, related_name='blog_posts', 
on_delete=models.CASCADE)
body = models.TextField()
publish = models.DateTimeField(default=timezone.now)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
status = models.CharField(max_length=10, choices=STATUS_CHOICES, 
default='draft')

class Meta:
ordering = ('-publish',)

def __str__(self):
return self.title


class Comment(models.Model):
post = models.ForeignKey(Post, related_name='comments', 
on_delete=models.CASCADE)
name = models.CharField(max_length=80)
email = models.EmailField()
body = models.TextField()
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
active = models.BooleanField(default=True)

class Meta:
ordering = ('created',)

def __str__(self):
return self.email
Regards,
Amitesh


-- 
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/1799372727.1057468.1573897086523%40mail.yahoo.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/CAP5HUWr7Tt14R-o8Jz0_mAZYV2KeDm5CkwBfqQBm9T8PkjaC%3Dw%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/294189113.1738336.1574081785206%40mail.yahoo.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/371936794.2325659.1574168366621%40mail.yahoo.com.


Re: reg: creating blog topic in database

2019-11-18 Thread 'Amitesh Sahay' via Django users
Hi, 

To be honest, I have tried following the django docs link that you have shared. 
But I failed to understand the relevance . I have little knowledge. So, I might 
be little clueless here.



Regards,
Amitesh
 

On Saturday, 16 November, 2019, 5:00:11 PM IST, Integr@te System 
 wrote:  
 
 Hi Issuer
Follow to part 3 - 4 and check docs for some thing else around you need
https://docs.djangoproject.com/en/2.2/ref/templates/language/
https://docs.djangoproject.com/en/2.2/intro/tutorial04/

On Sat, Nov 16, 2019, 16:40 'Amitesh Sahay' via Django users 
 wrote:

Hello All,
I have created the two models to create post on desired topic, as well as to 
get the comments from the visitors. But, I am not able to figure out, how to 
connect that model to my HTML page. 

I know how to create a static HTML pages for each topic,and write page content 
in  tags. which I have been thinking to do until now, but it seems to be 
a time taking and non-productive way. So, now I would like to write posts in my 
database model which I have registered in admin.py. 

Any idea, how can I achieve this, as this would be a like generating dynamic 
HTML pages based on models.

I am not sure if I was able to explain my requirements. May be as I am not 
getting right words to express them. Please ask me questions if any confusion, 
I will try to answer them. 

Below is my models.py 

from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User


class Post(models.Model):
STATUS_CHOICES = (
('draft', 'Draft'),
('published', 'Published'),
)
title = models.CharField(max_length=250)
slug = models.SlugField(max_length=250, unique_for_date='publish')
author = models.ForeignKey(User, related_name='blog_posts', 
on_delete=models.CASCADE)
body = models.TextField()
publish = models.DateTimeField(default=timezone.now)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
status = models.CharField(max_length=10, choices=STATUS_CHOICES, 
default='draft')

class Meta:
ordering = ('-publish',)

def __str__(self):
return self.title


class Comment(models.Model):
post = models.ForeignKey(Post, related_name='comments', 
on_delete=models.CASCADE)
name = models.CharField(max_length=80)
email = models.EmailField()
body = models.TextField()
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
active = models.BooleanField(default=True)

class Meta:
ordering = ('created',)

def __str__(self):
return self.email
Regards,
Amitesh


-- 
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/1799372727.1057468.1573897086523%40mail.yahoo.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/CAP5HUWr7Tt14R-o8Jz0_mAZYV2KeDm5CkwBfqQBm9T8PkjaC%3Dw%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/294189113.1738336.1574081785206%40mail.yahoo.com.


reg: creating blog topic in database

2019-11-16 Thread 'Amitesh Sahay' via Django users
Hello All,
I have created the two models to create post on desired topic, as well as to 
get the comments from the visitors. But, I am not able to figure out, how to 
connect that model to my HTML page. 

I know how to create a static HTML pages for each topic,and write page content 
in  tags. which I have been thinking to do until now, but it seems to be 
a time taking and non-productive way. So, now I would like to write posts in my 
database model which I have registered in admin.py. 

Any idea, how can I achieve this, as this would be a like generating dynamic 
HTML pages based on models.

I am not sure if I was able to explain my requirements. May be as I am not 
getting right words to express them. Please ask me questions if any confusion, 
I will try to answer them. 

Below is my models.py 

from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User


class Post(models.Model):
STATUS_CHOICES = (
('draft', 'Draft'),
('published', 'Published'),
)
title = models.CharField(max_length=250)
slug = models.SlugField(max_length=250, unique_for_date='publish')
author = models.ForeignKey(User, related_name='blog_posts', 
on_delete=models.CASCADE)
body = models.TextField()
publish = models.DateTimeField(default=timezone.now)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
status = models.CharField(max_length=10, choices=STATUS_CHOICES, 
default='draft')

class Meta:
ordering = ('-publish',)

def __str__(self):
return self.title


class Comment(models.Model):
post = models.ForeignKey(Post, related_name='comments', 
on_delete=models.CASCADE)
name = models.CharField(max_length=80)
email = models.EmailField()
body = models.TextField()
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
active = models.BooleanField(default=True)

class Meta:
ordering = ('created',)

def __str__(self):
return self.email
Regards,
Amitesh

-- 
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/1799372727.1057468.1573897086523%40mail.yahoo.com.


Re: reg: Django forms and models

2019-11-13 Thread 'Amitesh Sahay' via Django users
Initially I had written the "else" statement at the wrong place. Moved it under 
the very first "if" and used then returned the HTTPresponse on the right place 
inside the function



Regards,
Amitesh S
 

On Wednesday, 13 November, 2019, 5:42:57 AM IST, o1bigtenor 
 wrote:  
 
 On Tue, Nov 12, 2019 at 12:39 PM 'Amitesh Sahay' via Django users
 wrote:
>
> Hello Kasper,
>
> Thank you for the hint. I found my mistake and resolved it.
>
So what did you do?
(doesn't need to have all the detail just the idea please)

TIA

-- 
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/CAPpdf5_RVtwmN73i5%3Dm2LmBdboYVfHvqY3dJyuqHxYQYbRzB_Q%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/424090062.3213208.1573671943319%40mail.yahoo.com.


Re: reg: Django forms and models

2019-11-12 Thread 'Amitesh Sahay' via Django users
Hello Kasper,
Thank you for the hint. I found my mistake and resolved it.



Regards,
Amitesh 
 

On Tuesday, 12 November, 2019, 2:02:09 AM IST, Kasper Laudrup 
 wrote:  
 
 Hi Amitesh,

In this view:

On 11/11/2019 20.36, 'Amitesh Sahay' via Django users wrote:
> 
> def contact(request):
>      if request.method =='POST':
>          name_r = request.POST.get('name')
>          email_r = request.POST.get('email')
>          phone_r = request.POST.get('phone')
>          comment_r = request.POST.get('comment')
> 
>          form = ContactForm(name=name_r, email=email_r, phone=phone_r, 
>comment=comment_r)
>          if form.is_valid():
>              form.save()
>              form = ContactForm()
>              return HttpResponse('Thank you for your enquiry')
>              return redirect(request, 'contact.html')
>          else:
>              form = ContactForm()
>              return render(request, 'contact.html', {'form': form})
>

Concider what will happen if request.method is *not* POST?

As a hint, if a Python function doesn't return anything explicitly, it 
will implicitly return None.

Hope that will guide you in the right direction.

I could just solve it for you, but it's better that you figure it out 
yourself if you want to learn.

Kind regards,

Kasper Laudrup

-- 
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/43c7a649-b008-d0ef-dd2c-64679c270017%40stacktrace.dk.
  

-- 
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/66612613.2744567.1573583921914%40mail.yahoo.com.


reg: Django forms and models

2019-11-11 Thread 'Amitesh Sahay' via Django users
Hello Members,
I am creating a simple django forms and integrating it with models. I have 
followed the django docs to perform the task, but I believe that I am doing 
some mistake due to which I am getting 
"ValueError at /blog/contact/". Below is the full error stack:
Environment:


Request Method: GET
Request URL: http://localhost:8000/blog/contact/

Django Version: 2.2.5
Python Version: 3.6.8
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'BLOG']
Installed 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']



Traceback:

File 
"/root/PycharmProjects/myvenv/lib/python3.6/site-packages/django/core/handlers/exception.py"
 in inner
  34. response = get_response(request)

File 
"/root/PycharmProjects/myvenv/lib/python3.6/site-packages/django/core/handlers/base.py"
 in _get_response
  126. "returned None instead." % (callback.__module__, 
view_name)

Exception Type: ValueError at /blog/contact/
Exception Value: The view BLOG.views.contact didn't return an HttpResponse 
object. It returned None instead.Below are my python files snippet:
models.py-from django.db import models


class Contact(models.Model):
name = models.CharField(max_length=100)
email = models.EmailField(max_length=200)
phone = models.IntegerField()
Comment = models.TextField(blank=False)

def __str__(self):
return self.emailforms.pyfrom django import forms
from .models import Contact


class ContactForm(forms.ModelForm):
name = forms.CharField(label='Your name', max_length=100)
email = forms.EmailField(label='Your Email Address', max_length=200)
phone = forms.IntegerField(label='Your Phone Number', max_value=20)
Comment = forms.TextInput()

class Meta:
model = Contact
fields = ('name', 'email', 'phone', 'Comment')views.pyfrom django.http 
import HttpResponse
from django.shortcuts import render, redirect

from .forms import ContactForm


def contact(request):
if request.method == 'POST':
name_r = request.POST.get('name')
email_r = request.POST.get('email')
phone_r = request.POST.get('phone')
comment_r = request.POST.get('comment')

form = ContactForm(name=name_r, email=email_r, phone=phone_r, 
comment=comment_r)
if form.is_valid():
form.save()
form = ContactForm()
return HttpResponse('Thank you for your enquiry')
return redirect(request, 'contact.html')
else:
form = ContactForm()
return render(request, 'contact.html', {'form': form})Any 
suggestions




Regards,
AS

-- 
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/1654382225.2288963.1573500974885%40mail.yahoo.com.


Re: Making a scheduling app/programm for recurring treatment

2019-11-01 Thread 'Amitesh Sahay' via Django users
Hello Nitin, 

First of all, you start with the following basics: 

-  Install Django, database(if you do not wish to use the default one)-  
Register the Database to you Django project inside settings.py
-  a Django project.-  create an APP.-  register the APP in settings.py.
-  create an urls.py under the APP.-  create a templates folder under your 
ROOT_DIR(project level).-  create a static folder inside your APP.-  Decided on 
the HTML Layout that you would like to have for your pages.There are lots of 
ready- made HTML templates available on various online websites, you can 
use them if you do not wish to create on your own. If you have knowledge 
about creating front-end pages then I would recommend you start on your 
own, that way you would know what is where.-  start creating HTML pages inside 
the templates folder.-  under the static folder create sub directories(CSS, js, 
media).
Once you are done with the front-end , now return to back-end logic. 

-  Decide on the types of form fields that you need to have in your APP.-  Now 
manually write down the fields name on a piece of paper and make their entry in 
the models.py. I am assuming that you know how to create models.
The list will go on, but start with the above, and then ask questions on the 
advanced part. You will face lots of issues while working on the above points 
itself. 

For basic configuration, you can follow my project that I have on git-hub, 
below is the link
SuperGoogler/ShoppingCart

| 
| 
| 
|  |  |

 |

 |
| 
|  | 
SuperGoogler/ShoppingCart

Contribute to SuperGoogler/ShoppingCart development by creating an account on 
GitHub.
 |

 |

 |


Do not try to understand the advance part of the project, just see how the 
project skeleton is developed, I am sure you will get lots of good information.



Regards,
Amitesh
 

On Friday, 1 November, 2019, 7:44:24 PM IST, Nithin Bhaskar 
 wrote:  
 
 Hey,
I have send you a request. I think the name may appear as 'Charu'Do let me know 
when you are free
Thanks

On Thu, 31 Oct 2019 at 14:15, Motaz Hejaze  wrote:

Any time , send me a text message at first
On Thu, 31 Oct 2019, 6:10 am Nithin Bhaskar,  wrote:

Hey,Thanks.What would be the right time to call you?

On Wed, 30 Oct 2019 at 22:36, Motaz Hejaze  wrote:

I can cooperate with you .. Talk to me on skype : m3tz-hjze
On Wed, 30 Oct 2019, 6:43 pm Uzama Zaid Mohammed Jaward, 
 wrote:

I think you don’t get any answer for these like questions in here. This is a 
forum to discuss about Django and Support. First you have to design the system. 
Then onwards you can use Django. You might get answer for this if you will post 
this in stack overflow 
On Wed, Oct 30, 2019 at 19:34, Nithin Bhaskar  wrote:

Well to be frank, I am stuck right at the beginning itself.
I am working in a public sector with limiter resources and a huge patient load 
and almost no funding. I was thinking of making patient scheduling a bit 
manageable and easy in my hospital.
I have not yet figured out how to go about with it. I know its too naive, but i 
could really use some help starting from the core basics. I have just made an 
app called scheduler1.1. How do i progam treatments in the  7 scheduling rooms 
and block them for the next 7 weeks.
2. Certain procedures are done only in room 1 and 2. So in option 4 (modality 
of treatment), if i have chosen them, the patients have to be scheduled in 
these rooms.
But before this, I need to start with the basic layout of the app.
I understand that you may find it similar to teaching a kindergarten kid, but I 
would be really grateful if you could help me put
Thanking you 

Regards..



On Wed, 30 Oct 2019 at 18:59, Kasper Laudrup  wrote:

Hi Nithin,

On 30/10/2019 08.19, Nithin Bhaskar wrote:
> 
> I am completely new to django and python and don't have a background in 
> programming
> I have taught myself a bit of python and django and use PyCharm
> 
> Kindly help me out
> 

What exactly do you need help with? What have you done so far? Where are 
you stuck?

You need to be more specific.

Kind regards,

Kasper Laudrup

-- 
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/e4a53cf5-2dd4-49cb-a6a2-b59cdaf93ce3%40stacktrace.dk.



-- 
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/CAKJvVH0v-Ar%2BOct%2BNX2oCX89vbOX4RBWXqYTEbZMXumschS9_g%40mail.gmail.com.



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and 

Re: Query regarding Jija templates with django project

2019-10-30 Thread 'Amitesh Sahay' via Django users
Hey Red, 

Thank you for your reply.
Your suggestion did the trick. 
Now I am facing issues with static files, especially for CSS files. There were 
issues for images files, but I got that rectified. I know that the location 
that I have mentioned in the HTML pages has the CSS files. Still  I am getting 
the below error:

Not Found: /blog/contact/%{ static 'CSS/tooplate_style.css' %}
Not Found: /blog/contact/%{ static 'CSS/ddsmoothmenu.css' %}
[30/Oct/2019 10:41:07] "GET 
/blog/contact/%%7B%20static%20'CSS/tooplate_style.css'%20%%7D HTTP/1.1" 404 3124
[30/Oct/2019 10:41:07] "GET 
/blog/contact/%%7B%20static%20'CSS/ddsmoothmenu.css'%20%%7D HTTP/1.1" 404 3118
Not Found: /blog/contact/%{ static 'CSS/ddsmoothmenu.css' %}
[30/Oct/2019 10:41:07] "GET 
/blog/contact/%%7B%20static%20'CSS/ddsmoothmenu.css'%20%%7D HTTP/1.1" 404 3118

Below is the snippet of my static file settings:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_DIRS = (
   os.path.join(BASE_DIR, 'static'),
   )Below is my static dir structure as seen in my pycharm.


I went through below stackoverflow web link, but the suggestion don't seem to 
be working for me.
Django - Static file not found

| 
| 
| 
|  |  |

 |

 |
| 
|  | 
Django - Static file not found

I've seen several posts for this issue but didn't found my solution. I'm trying 
to serve static files within my...
 |

 |

 |




It would great if you could suggest .



Regards,
Amitesh
 

On Saturday, 26 October, 2019, 4:42:05 AM IST, red  
wrote:  
 
  
Hello,
 
Your views have a 'name' attribute. You can also give a name to an app in the 
urls.py file of the app, right above your urlpatterns list:
 app_name = "myappname"

urlpatterns = [
path('', views.index, name='index'),
path('about', views.about, name='about'),
path('blog', views.blog, name='blog'),

] 

 
 
Then, when you need to put a link to a another page in your template, use the 
following syntax:
 Home
About Us 
Regards,
 
 
Red
 On 25/10/2019 21:01, 'Amitesh Sahay' via Django users wrote:
  
 
  Hello Team, 
  
  I am kind of new to software development, and trying to find my feat. I have 
a queries which could be quite dumb to most of you, but I need to know.   As 
far as I know, we need Jija templates in the HTML files, so that we can assign 
correct path of the static files. 
  
  Its a general practice to create base.html and extend this in other HTML 
files. Since, I am new to development, so I want to do things in a stupid way, 
I have a HTML templates, and I do not wish to create base.html for now. 
Therefore, if I want to render the html page, I need to create views.py , 
urls.py, and modify the HTML pages to use 'static' any where required. Below 
are the snippet of my test environment. 
  views.py 
from django.shortcuts import render, get_object_or_404


def index(request):
return render(request, 'index.html')


def blog(request):
return render(request, 'blog.html')


def about(request):
return render(request, 'about.html')
  project/urls.py 
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),
path('blog/', include('BLOG.urls'))
]

if settings.DEBUG:
   urlpatterns += static(settings.STATIC_URL, 
document_root=settings.STATIC_ROOT)  APP/urls.py 
from django.urls import path
from django.conf import settings
from . import views

urlpatterns = [
path('', views.index, name='index'),
path('about', views.about, name='about'),
path('blog', views.blog, name='blog'),

]  below is the HTML(index.html) file, which I modified as per my limited 
understanding. 
{% load staticfiles %}
{% block content %}

http://www.w3.org/1999/xhtml;>


Orange Theme - Free Website Template







   var flashvars = {};
   flashvars.xml_file = "photo_list.xml";
   var params = {};
   params.wmode = "transparent";
   var attributes = {};
   attributes.id = "slider";
   swfobject.embedSWF("flash_slider.swf", "flash_grid_slider", "440", "220", 
"9.0.0", false, flashvars, params, attributes);







/***
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library 
(www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at <a  rel="nofollow" href="http://www.dynamicdrive.com/">http://www.dynamicdrive.com/</a> for full source code
***/





ddsmoothmenu.init({
   mainmenuid: "tooplate_menu", //menu DIV id
   orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
   classname: 'ddsmoothmenu', //class added to menu's outer DIV
   //customtheme: ["#1c5a80", "

Query regarding Jija templates with django project

2019-10-25 Thread 'Amitesh Sahay' via Django users
Hello Team, 

I am kind of new to software development, and trying to find my feat. I have a 
queries which could be quite dumb to most of you, but I need to know. As far as 
I know, we need Jija templates in the HTML files, so that we can assign correct 
path of the static files. 

Its a general practice to create base.html and extend this in other HTML files. 
Since, I am new to development, so I want to do things in a stupid way, I have 
a HTML templates, and I do not wish to create base.html for now. Therefore, if 
I want to render the html page, I need to create views.py , urls.py, and modify 
the HTML pages to use 'static' any where required. Below are the snippet of my 
test environment.
views.py
from django.shortcuts import render, get_object_or_404


def index(request):
return render(request, 'index.html')


def blog(request):
return render(request, 'blog.html')


def about(request):
return render(request, 'about.html')
project/urls.py
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),
path('blog/', include('BLOG.urls'))
]

if settings.DEBUG:
   urlpatterns += static(settings.STATIC_URL, 
document_root=settings.STATIC_ROOT)APP/urls.py
from django.urls import path
from django.conf import settings
from . import views

urlpatterns = [
path('', views.index, name='index'),
path('about', views.about, name='about'),
path('blog', views.blog, name='blog'),

]below is the HTML(index.html) file, which I modified as per my limited 
understanding.
{% load staticfiles %}
{% block content %}

http://www.w3.org/1999/xhtml;>


Orange Theme - Free Website Template







   var flashvars = {};
   flashvars.xml_file = "photo_list.xml";
   var params = {};
   params.wmode = "transparent";
   var attributes = {};
   attributes.id = "slider";
   swfobject.embedSWF("flash_slider.swf", "flash_grid_slider", "440", "220", 
"9.0.0", false, flashvars, params, attributes);







/***
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library 
(www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***/





ddsmoothmenu.init({
   mainmenuid: "tooplate_menu", //menu DIV id
   orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
   classname: 'ddsmoothmenu', //class added to menu's outer DIV
   //customtheme: ["#1c5a80", "#18374a"],
   contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})







   
   
   Orange HTML Template


  
   
   Home
   About Us

History
Our Team
Vision and Mission
   
   
Portfolio

Website Templates
Web Design
Free Templates
HTML CSS Layouts
Web Development
   
   
Blog
Contact

 

 













http://www.adobe.com/go/getflashplayer;>
http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif; 
alt="Get Adobe Flash player" />



  


Website Template
  
Aliquam in odio ut ipsum mollis facilisis. Integer est sem, 
dignissim quis auctor vel, dapibus vel massa. Curabitur vulputate ligula vel mi 
semper tempus.


  

 



   


New Standard

 Vivamus a velit. Vivamus leo velit, convallis id, ultrices 
sit amet, validate http://validator.w3.org/check?uri=referer; 
rel="nofollow">XHTML and http://jigsaw.w3.org/css-validator/check/referer; 
rel="nofollow">CSS. 
Detail

 

High Quality

Donec pharetra orci id tortor cursus eu ultricies velit 
vehicula. Phasellus eu ante tellus.
Detail

 

Solid Platform

Curabitur sed lectus id erat viverra consectetur nec in 
sapien. Etiam vitae tortor mi.
Detail

 


  
 

   



   
   Pages

Home
About Us
 

Re: Error while trying to connect latest Dango with MSSQL

2019-09-17 Thread 'Amitesh Sahay' via Django users
What is the error message? If the subject line you are talking about, its very 
generic. please be specific.


Regards,
Amitesh 

On Wednesday, 18 September, 2019, 02:06:03 am IST, Praveen Kumar 
 wrote:  
 
 Hi All,

Just I have updated the latest version of Dango. But now I'm getting error 
message. Please suggest me.

-- 
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/cf2ca49b-738e-457e-9d13-8a2df09a3a8f%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/329456698.7041138.1568784512666%40mail.yahoo.com.


Re: reg: Issue while rendering the page

2019-09-17 Thread 'Amitesh Sahay' via Django users
Below is the snippet of my project tree::





Regards,
Amitesh Sahay91-750 797 8619 

On Wednesday, 18 September, 2019, 12:58:57 am IST, Amitesh Sahay 
 wrote:  
 
 Hello Users, 
I am building an app called "SHOP". For some very wired reason I am getting 
below error:
ValueError at /shop/
The 'image' attribute has no file associated with it.
| Request Method: | GET |
| Request URL: | http://localhost:8000/shop/ |
| Django Version: | 2.2.5 |
| Exception Type: | ValueError |
| Exception Value: | The 'image' attribute has no file associated with it. |
| Exception Location: | 
/home/amitesh/PycharmProjects/myvenv/lib/python3.6/site-packages/django/db/models/fields/files.py
 in _require_file, line 38 |
| Python Executable: | /home/amitesh/PycharmProjects/myvenv/bin/python |
| Python Version: | 3.6.8 |
| Python Path: | ['/home/amitesh/PycharmProjects/perfectcushion',
 '/usr/lib/python36.zip',
 '/usr/lib/python3.6',
 '/usr/lib/python3.6/lib-dynload',
 '/home/amitesh/PycharmProjects/myvenv/lib/python3.6/site-packages'] |
| Server time: | Tue, 17 Sep 2019 18:59:22 + |

 When I see 
the debug page further I see that my base.html is complaining, below is the 
error:
Error during template rendering

In template 
/home/amitesh/PycharmProjects/perfectcushion/SHOP/templates/base.html, error at 
line 0

The 'image' attribute has no file associated with it.

| 1 | {% load staticfiles %} |
| 2 |  |
| 3 |  |
| 4 |  |
| 5 |   |
| 6 |   |
| 7 |  {% block title %}{% endblock %} |
| 8 |  |
| 9 |  |



base.html
{% load staticfiles %}





{% block title %}{% endblock %}



{% include 'header.html' %}
{% include 'navbar.html' %}
{% block content %}
{% endblock %}

{% include 'footer.html' %}


headers.html
{% load staticfiles %}




navbar.html
{% load staticfiles %}


All Products
Your Cart()


category.html
{% extends 'base.html' %}
{% load staticfiles %}
{%  block metadescription %}
{% if category %}
{{ category.description|truncatewords:125 }}
{% else %}
Welcome to the cushion store where you can buy comfy and awesome 
cushions.
{% endif %}
{% endblock %}

{% block title %}
{% if category %}
{{ category.name }} - Perfect Cushion Store
 {% else %}
See our Cushion Collection - Perfect Cushion Store
{% endif %}
{% endblock %}

{% block content %}

{%  if category %}


Our Product 
Collection | {{ category.name }}


{% endif %}

{% if category %}





{{ category.name }}
{{ category.description }}

{% else %}

 
 
 
Our Products collection

Lorem Ipsum is simply dummy text of the printing and typesetting 
industry. Lorem Ipsum has been the industry's standard dummy text 
ever since the 1500s, when an unknown printer took a galley of type 
and.
 
{% endif %}


{% for product in products %}




{{ product.name }}
{{ product.price }}



{% endfor %}


{% endblock %}SHOP/urls.py
from django.urls import path
from . import views

app_name = 'shop'

urlpatterns = [
path('', views.allProdCat, name='allProdCat'),
path('/', views.allProdCat, name='products_by_category'),
]project/urls.py
from django.contrib import admin
from django.urls import path, include
from SHOP import views
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),
path('shop/', include('SHOP.urls')),
]

# We need to map the static and the media URLS with the below settings
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, 
document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, 
document_root=settings.MEDIA_ROOT)views.py
from django.shortcuts import render, get_object_or_404
from .models import Category, Product


def allProdCat(request, c_slug=None):
c_page = None
products = None
if c_slug is not None:
c_page = get_object_or_404(Category, c_slug=c_slug)
products = Product.objects.filter(category=c_page, available=True)
else:
products = Product.objects.all().filter(available=True)
return render(request, 'shop/category.html', {'category': c_page, 
'products': products})Please help me figure out my mistake.



Regards,
Amitesh Sahay  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop 

reg: Issue while rendering the page

2019-09-17 Thread 'Amitesh Sahay' via Django users
Hello Users, 
I am building an app called "SHOP". For some very wired reason I am getting 
below error:
ValueError at /shop/
The 'image' attribute has no file associated with it.
| Request Method: | GET |
| Request URL: | http://localhost:8000/shop/ |
| Django Version: | 2.2.5 |
| Exception Type: | ValueError |
| Exception Value: | The 'image' attribute has no file associated with it. |
| Exception Location: | 
/home/amitesh/PycharmProjects/myvenv/lib/python3.6/site-packages/django/db/models/fields/files.py
 in _require_file, line 38 |
| Python Executable: | /home/amitesh/PycharmProjects/myvenv/bin/python |
| Python Version: | 3.6.8 |
| Python Path: | ['/home/amitesh/PycharmProjects/perfectcushion',
 '/usr/lib/python36.zip',
 '/usr/lib/python3.6',
 '/usr/lib/python3.6/lib-dynload',
 '/home/amitesh/PycharmProjects/myvenv/lib/python3.6/site-packages'] |
| Server time: | Tue, 17 Sep 2019 18:59:22 + |

 When I see 
the debug page further I see that my base.html is complaining, below is the 
error:
Error during template rendering

In template 
/home/amitesh/PycharmProjects/perfectcushion/SHOP/templates/base.html, error at 
line 0

The 'image' attribute has no file associated with it.

| 1 | {% load staticfiles %} |
| 2 |  |
| 3 |  |
| 4 |  |
| 5 |   |
| 6 |   |
| 7 |  {% block title %}{% endblock %} |
| 8 |  |
| 9 |  |



base.html
{% load staticfiles %}





{% block title %}{% endblock %}



{% include 'header.html' %}
{% include 'navbar.html' %}
{% block content %}
{% endblock %}

{% include 'footer.html' %}


headers.html
{% load staticfiles %}




navbar.html
{% load staticfiles %}


All Products
Your Cart()


category.html
{% extends 'base.html' %}
{% load staticfiles %}
{%  block metadescription %}
{% if category %}
{{ category.description|truncatewords:125 }}
{% else %}
Welcome to the cushion store where you can buy comfy and awesome 
cushions.
{% endif %}
{% endblock %}

{% block title %}
{% if category %}
{{ category.name }} - Perfect Cushion Store
 {% else %}
See our Cushion Collection - Perfect Cushion Store
{% endif %}
{% endblock %}

{% block content %}

{%  if category %}


Our Product 
Collection | {{ category.name }}


{% endif %}

{% if category %}





{{ category.name }}
{{ category.description }}

{% else %}

 
 
 
Our Products collection

Lorem Ipsum is simply dummy text of the printing and typesetting 
industry. Lorem Ipsum has been the industry's standard dummy text 
ever since the 1500s, when an unknown printer took a galley of type 
and.
 
{% endif %}


{% for product in products %}




{{ product.name }}
{{ product.price }}



{% endfor %}


{% endblock %}SHOP/urls.py
from django.urls import path
from . import views

app_name = 'shop'

urlpatterns = [
path('', views.allProdCat, name='allProdCat'),
path('/', views.allProdCat, name='products_by_category'),
]project/urls.py
from django.contrib import admin
from django.urls import path, include
from SHOP import views
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),
path('shop/', include('SHOP.urls')),
]

# We need to map the static and the media URLS with the below settings
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, 
document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, 
document_root=settings.MEDIA_ROOT)views.py
from django.shortcuts import render, get_object_or_404
from .models import Category, Product


def allProdCat(request, c_slug=None):
c_page = None
products = None
if c_slug is not None:
c_page = get_object_or_404(Category, c_slug=c_slug)
products = Product.objects.filter(category=c_page, available=True)
else:
products = Product.objects.all().filter(available=True)
return render(request, 'shop/category.html', {'category': c_page, 
'products': products})Please help me figure out my mistake.



Regards,
Amitesh Sahay

-- 
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 

Re: Problems with "Class Meta" and " __str__"

2019-09-10 Thread 'Amitesh Sahay' via Django users
I guess you should define the Meta class just under the main class, ie.
class Autore(models.Model):
    nome = models.CharField(max_length=50)
    cognome = models.CharField(max_length=50)
 class Meta:
    verbose_name_plural = "Autori"





Regards,
Amitesh Sahay91-750 797 8619 

On Tuesday, 10 September, 2019, 11:50:20 pm IST, Doddahulugappa.B 
 wrote:  
 
 def __str__(self):
    return self.name


On Tue, Sep 10, 2019, 8:30 PM Elmaco7  wrote:

Hello, I do these models but the Django admin page doesn't read the "class 
Meta" and " __str__".This is the models.py document

from django.db import models

# Create your models here.


class Autore(models.Model):
    nome = models.CharField(max_length=50)
    cognome = models.CharField(max_length=50)
def __str__(self):
    return self.autore_text
class Meta:
    verbose_name_plural = "Autori"

class Genere(models.Model):
    descrizione = models.CharField(max_length=30)
def __str__(self):
    return self.genere_text
class Meta:
    verbose_name_plural = "Generi"

class Libro(models.Model):
    titolo = models.CharField(max_length=200)
    autore = models.ForeignKey(Autore, on_delete=models.CASCADE)
    genere = models.ForeignKey(Genere, on_delete=models.CASCADE)
def __str__(self):
    return self.libro_text
class Meta:
    verbose_name_plural = "Libri"


These are the results



Can someone help me?


-- 
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/c1941b52-7d2b-4b09-8ead-fce630b73757%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/CAKfjjGrMMEkg85LOVGhDeSes%3D4eMzoh%3DTn%2BwyS%2Bc5VxWMBMiPw%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/1997993869.4201313.1568141384098%40mail.yahoo.com.


Re: How to change the label for username to 'username/email' in login page in Django

2019-08-30 Thread 'Amitesh Sahay' via Django users
If guess you are using HTML to create the form. So, I believe that Type  = 
'Text' and Type = 'email'. May be. Please cross cehck


Regards,
Amitesh Sahay 

On Friday, 30 August, 2019, 10:59:19 pm IST, Sandip Nath 
 wrote:  
 
 I am building a car rental website with Django. Currently working on user 
authentication.The user can either use his/her username/email and password to 
login.It's working fine. My question is, how will I change the label for 
username field to "username/email" so that the user can understand that either 
username or email can be entered. I cannot  make changes in the login.html 
template because I have used there {{ form.as_p }} tag and the concerned 
portion in my forms.py file has:
    class LoginForm(forms.Form):        username = forms.CharField()        
password = forms.CharField(widget=forms.PasswordInput)
I am not able to understand where to make changes. Please help.

-- 
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/d67736f6-0b96-490d-8d73-bdcb476cd048%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/1132743044.381705.1567188902042%40mail.yahoo.com.


Re: confusing about running some codes in django

2019-08-29 Thread 'Amitesh Sahay' via Django users
When you do a CRUD operation , you can use Django ORMs in view.py.


Regards,
Amitesh Sahay 

On Thursday, 29 August, 2019, 06:54:35 pm IST, Mario R. Osorio 
 wrote:  
 
 That code is meant for you to type it in the python console however, you could 
also include it pretty much anywhere in your code.

On Wednesday, August 28, 2019 at 9:15:20 AM UTC-4, Vahid Asadi wrote:
Hi . 
when i read the django docs,it suggested that running some code but it does not 
note that where to write this piece of code . the code is :
from django.contrib.auth.models import Useru = User.objects.get(username=' 
john')u.set_password('new password')u.save()
i know that i can run it in django shell (manage.py shell)but i want to write 
these in a file(its some confusing that every code in views.py should return a 
http response but this type of commands does not return any respone) where 
should i put this code ??thanks for your attention.


-- 
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/b6b3b24e-b34e-42e6-b637-3e6a30ca2823%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/1187677849.420391.1567101154852%40mail.yahoo.com.


Re: help me to fix this issue with database connection

2019-08-29 Thread 'Amitesh Sahay' via Django users
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'Authenticate', # database name
'USER': 'postgres',
'PASSWORD': 'pwd',
'HOST': 'localhost'
}
}I don't think you need anything other than this. For MySql you can use mysql 
driver "django.db.backends.mysql". I hope that works.


Regards,
Amitesh Sahay 

On Thursday, 29 August, 2019, 01:41:44 pm IST, leb dev 
 wrote:  
 
 i tried in the settings.py 

DATABASES = {    'default': {        'ENGINE': 'sql_server.pyodbc',        
'NAME':   'testDB',        'HOST':   'VSQLSERV',        'OPTIONS': {            
'driver':' SQL Server',        }
        # 'ENGINE': 'django.db.backends.sqlite3',        # 'NAME': 
os.path.join(BASE_DIR, 'db.sqlite3'),    }}
On Thursday, August 29, 2019 at 8:34:17 AM UTC+3, leb dev wrote:
i have a django project that need to be connected to MS SQL Server  i am using 
pyodbc package.
once i run the program the system display the below error:
djago.db.utils. operationalError:('08001','[ 08001] [microsoft][odbc sql server 
driver]neither dsn nor server keyword supplied (0) (sqldriverconnect); [08001] 
[microsoft][odbc sql server driver] Invalid connection string attribute (0)')

where is the error and how to fix it ?
from django.shortcuts import render
import pyodbc

def connect(request):
conn = pyodbc.connect(
'Driver={SQL Server};'
'Server=ip address;'
'Database=I-Base_beSQL;'
'Trusted_Connection=yes;'

)


cursor = conn.cursor()
c = cursor.execute('SELECT "first name" FROM Person   WHERE id = 2 ')

return render (request,'connect.html',{"c": c})


-- 
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/a1cdc16f-4cb0-4d47-872c-7c9320023263%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/1697008900.237063.1567066571422%40mail.yahoo.com.


  1   2   >