Re: Apple M1 Silicon + Django = weird results

2021-01-09 Thread Lane Campbell
I'd put the code up on an x64 virtual machine and see if it behaves as
expected. If the issues are still present then you know it's not M1
related.



On Sat, Jan 9, 2021 at 11:57 PM Mike Dewhirst  wrote:

> In principle, Django and Python and anything else you can program incuding
> the database are completely independent of the lower layers of the IP
> stack.
>
> I would restore the infrastructure to manufacturer's defaults and test
> again.
>
> Removing unknowns is always a good start in debugging.
>
> Good luck
>
> Mike
>
>
>
> --
> (Unsigned mail from my phone)
>
>
>
>  Original message 
> From: Benjamin Schollnick 
> Date: 10/1/21 15:41 (GMT+10:00)
> To: django-users@googlegroups.com
> Subject: Re: Apple M1 Silicon + Django = weird results
>
> Okay, a further update.
>
> While rewrite the code, did seem to make a marginal difference, the
> corruption issue persisted intermittently.
>
> Just today, I did some more digging, and I remembered that I turned on
> Jumbo Frames for my ethernet port on the M1 Mac Mini.
>
> Turning that off, at first glance, seems to have resolved the corruption
> issue…
>
> I’m unclear if this is an Django, Rosetta 2, Big Sur, or M1 Mac mini
> hardware issue (or a combination of factors).
>
> I can’t check, but I’d swear that I had Jumbo frames turned on with My
> Catalina 2013 iMac.
>
> Any ideas or suggestions?
>
> - Benjamin
>
>
>
> On Dec 22, 2020, at 6:46 AM, Benjamin Schollnick <
> bscholln...@schollnick.net> wrote:
>
> Just an update.
>
> Working my way through the problem, it appears that either the data is
> being written truncated to the database, or Pillow is generating a
> truncated image preview (which is being stored to the database).
>
> The later is more likely, since I am seeing no other data corruption
> errors.
>
> Rewriting the thumbnail delivery code, seemed to reduce the amount of
> downloading issues, but they are still not Non-Zero…
>
> But I may just have to live with this, since there are too many moving
> parts to be able to point a finger at any one bit of code.  (It could be
> rosetta 2 overly optimizing the code in some way…  etc.)
>
> Plus, It might be time for me to just simply start rewriting the code from
> the ground up again, to better optimize and clean it up.
>
> - Benjamin
>
>
>
> On Dec 21, 2020, at 10:52 PM, Benjamin Schollnick <
> bscholln...@schollnick.net> wrote:
>
>
> Have you tried the download with various browsers? I wonder if Safari or
> Chrome released at the same time as the M1 chips is causing different Range
> header behavior than that code is designed to handle. So it might not be
> the M1 chip, but just an unrelated change in browser software that got
> pushed out at the same time. Speculating here.
>
>
> The only issue that I see, is that I started to use RangedFileResponse to
> allow the viewing of MP4, and other media files in the browser…  (
>
> So I know it works at least in that regard.
>
> But for debugging purposes, I’ll switch it around…
>
> - Benjamin
>
>
>
> On Mon, Dec 21, 2020 at 3:19 PM Benjamin Schollnick <
> bscholln...@schollnick.net> wrote:
>
>> Folks,
>>
>> I’m using django for an online gallery application, and I’ve seen some
>> weird results since switching over to the M1 Mac Mini.
>> (Please note, I am running it under Rosetta / Intel Translation, since
>> pillow doesn’t seem to build under M1 native).
>>
>> So this could be a quirk of Rosetta, Django, or some combination of these.
>>
>> I don’t think so, but it could be.
>>
>> *So What is happening?  *
>>
>> I never saw this under my 2013 intel iMac, but now under M1 (even under
>> Rosetta 2 / Intel translation) I am receiving a damaged / altered download
>> file roughly 6 out of 8 or 9 times (~25-33% successful).
>>
>> Just retrying the download will eventually be successful.
>>
>> This isn’t Pillow related, since the file is just being downloaded
>> directly (no thumbnails or alterations to the file is occurring).
>>
>> Does anyone have a suggestion on what to do at this time?  I’m uncertain
>> on where to start to dig.  Although removing ranged_response, might be a
>> starting point…
>>
>> URLs:
>> path("download/", frontend.views.new_download,
>> name="downloads"),
>> path('thumbnails/', frontend.views.thumbnails,
>> name="raw thumbnails"),
>>
>>
>> First, I am using these function for all graphics and/or file(s) being
>> sent:
>>
>> def new_download(request, d_uuid=None):
>> page = request.GET.get('page', None)
>> if page is None:
>> download = index_data.objects.filter(uuid=d_uuid,
>>  ignore=False,
>>  delete_pending=False)[0]
>> else:
>> print ("Attempting to find page %s in archive" % page)
>> print("\tDownloading - %s, %s" % (download.fqpndirectory.lower(),
>>   download.name))
>> return respond_as_inline(request,
>>  "%s%s%s" 

Re: Apple M1 Silicon + Django = weird results

2021-01-09 Thread Mike Dewhirst
In principle, Django and Python and anything else you can program incuding the 
database are completely independent of the lower layers of the IP stack. I 
would restore the infrastructure to manufacturer's defaults and test again. 
Removing unknowns is always a good start in debugging.Good luckMike--(Unsigned 
mail from my phone)
 Original message From: Benjamin Schollnick 
 Date: 10/1/21  15:41  (GMT+10:00) To: 
django-users@googlegroups.com Subject: Re: Apple M1 Silicon + Django = weird 
results Okay, a further update.While rewrite the code, did seem to make a 
marginal difference, the corruption issue persisted intermittently.Just today, 
I did some more digging, and I remembered that I turned on Jumbo Frames for my 
ethernet port on the M1 Mac Mini.  Turning that off, at first glance, seems to 
have resolved the corruption issue…  I’m unclear if this is an Django, Rosetta 
2, Big Sur, or M1 Mac mini hardware issue (or a combination of factors).  I 
can’t check, but I’d swear that I had Jumbo frames turned on with My Catalina 
2013 iMac.  Any ideas or suggestions?   - BenjaminOn Dec 22, 2020, at 6:46 
AM, Benjamin Schollnick  wrote:Just an 
update.Working my way through the problem, it appears that either the data is 
being written truncated to the database, or Pillow is generating a truncated 
image preview (which is being stored to the database).The later is more likely, 
since I am seeing no other data corruption errors.Rewriting the thumbnail 
delivery code, seemed to reduce the amount of downloading issues, but they are 
still not Non-Zero…  But I may just have to live with this, since there are too 
many moving parts to be able to point a finger at any one bit of code.  (It 
could be rosetta 2 overly optimizing the code in some way…  etc.)Plus, It might 
be time for me to just simply start rewriting the code from the ground up 
again, to better optimize and clean it up.  - BenjaminOn Dec 21, 2020, at 
10:52 PM, Benjamin Schollnick  wrote:Have you tried 
the download with various browsers? I wonder if Safari or Chrome released at 
the same time as the M1 chips is causing different Range header behavior than 
that code is designed to handle. So it might not be the M1 chip, but just an 
unrelated change in browser software that got pushed out at the same time. 
Speculating here.The only issue that I see, is that I started to use 
RangedFileResponse to allow the viewing of MP4, and other media files in the 
browser…  (So I know it works at least in that regard.  But for debugging 
purposes, I’ll switch it around…   - BenjaminOn Mon, Dec 21, 2020 at 3:19 PM 
Benjamin Schollnick  wrote:Folks,I’m using django 
for an online gallery application, and I’ve seen some weird results since 
switching over to the M1 Mac Mini.(Please note, I am running it under Rosetta / 
Intel Translation, since pillow doesn’t seem to build under M1 native).So this 
could be a quirk of Rosetta, Django, or some combination of these.I don’t think 
so, but it could be.So What is happening?  I never saw this under my 2013 intel 
iMac, but now under M1 (even under Rosetta 2 / Intel translation) I am 
receiving a damaged / altered download file roughly 6 out of 8 or 9 times 
(~25-33% successful).  Just retrying the download will eventually be 
successful.  This isn’t Pillow related, since the file is just being downloaded 
directly (no thumbnails or alterations to the file is occurring).Does anyone 
have a suggestion on what to do at this time?  I’m uncertain on where to start 
to dig.  Although removing ranged_response, might be a starting point…URLs:    
path("download/", frontend.views.new_download, name="downloads"),  
  path('thumbnails/', frontend.views.thumbnails, name="raw 
thumbnails"),First, I am using these function for all graphics and/or file(s) 
being sent:def new_download(request, d_uuid=None):    page = 
request.GET.get('page', None)    if page is None:        download = 
index_data.objects.filter(uuid=d_uuid,                                          
   ignore=False,                                             
delete_pending=False)[0]    else:        print ("Attempting to find page %s in 
archive" % page)    print("\tDownloading - %s, %s" % 
(download.fqpndirectory.lower(),                                      
download.name))    return respond_as_inline(request,                            
     "%s%s%s" % (                                     
configdata["locations"]["albums_path"],                                     
os.sep,                                     download.fqpndirectory),            
                     download.name)def respond_as_inline(request, file_path, 
original_filename, ranged=False):    # 
https://stackoverflow.com/questions/36392510/django-download-a-file    # 
https://stackoverflow.com/questions/27712778/video-plays-in-other-browsers-but-not-safari
    # 
https://stackoverflow.com/questions/720419/how-can-i-find-out-whether-a-server-supports-the-range-header
    

Re: Apple M1 Silicon + Django = weird results

2021-01-09 Thread Benjamin Schollnick
Okay, a further update.

While rewrite the code, did seem to make a marginal difference, the corruption 
issue persisted intermittently.

Just today, I did some more digging, and I remembered that I turned on Jumbo 
Frames for my ethernet port on the M1 Mac Mini.  

Turning that off, at first glance, seems to have resolved the corruption issue… 
 

I’m unclear if this is an Django, Rosetta 2, Big Sur, or M1 Mac mini hardware 
issue (or a combination of factors).  

I can’t check, but I’d swear that I had Jumbo frames turned on with My Catalina 
2013 iMac.  

Any ideas or suggestions?

- Benjamin



> On Dec 22, 2020, at 6:46 AM, Benjamin Schollnick  
> wrote:
> 
> Just an update.
> 
> Working my way through the problem, it appears that either the data is being 
> written truncated to the database, or Pillow is generating a truncated image 
> preview (which is being stored to the database).
> 
> The later is more likely, since I am seeing no other data corruption errors.
> 
> Rewriting the thumbnail delivery code, seemed to reduce the amount of 
> downloading issues, but they are still not Non-Zero…  
> 
> But I may just have to live with this, since there are too many moving parts 
> to be able to point a finger at any one bit of code.  (It could be rosetta 2 
> overly optimizing the code in some way…  etc.)
> 
> Plus, It might be time for me to just simply start rewriting the code from 
> the ground up again, to better optimize and clean it up.  
> 
>   - Benjamin
> 
> 
> 
>> On Dec 21, 2020, at 10:52 PM, Benjamin Schollnick 
>> mailto:bscholln...@schollnick.net>> wrote:
>> 
>> 
>>> Have you tried the download with various browsers? I wonder if Safari or 
>>> Chrome released at the same time as the M1 chips is causing different Range 
>>> header behavior than that code is designed to handle. So it might not be 
>>> the M1 chip, but just an unrelated change in browser software that got 
>>> pushed out at the same time. Speculating here.
>> 
>> The only issue that I see, is that I started to use RangedFileResponse to 
>> allow the viewing of MP4, and other media files in the browser…  (
>> 
>> So I know it works at least in that regard.  
>> 
>> But for debugging purposes, I’ll switch it around…
>> 
>>  - Benjamin
>> 
>> 
>>> 
>>> On Mon, Dec 21, 2020 at 3:19 PM Benjamin Schollnick 
>>> mailto:bscholln...@schollnick.net>> wrote:
>>> Folks,
>>> 
>>> I’m using django for an online gallery application, and I’ve seen some 
>>> weird results since switching over to the M1 Mac Mini.
>>> (Please note, I am running it under Rosetta / Intel Translation, since 
>>> pillow doesn’t seem to build under M1 native).
>>> 
>>> So this could be a quirk of Rosetta, Django, or some combination of these.
>>> 
>>> I don’t think so, but it could be.
>>> 
>>> So What is happening?  
>>> 
>>> I never saw this under my 2013 intel iMac, but now under M1 (even under 
>>> Rosetta 2 / Intel translation) I am receiving a damaged / altered download 
>>> file roughly 6 out of 8 or 9 times (~25-33% successful).  
>>> 
>>> Just retrying the download will eventually be successful.  
>>> 
>>> This isn’t Pillow related, since the file is just being downloaded directly 
>>> (no thumbnails or alterations to the file is occurring).
>>> 
>>> Does anyone have a suggestion on what to do at this time?  I’m uncertain on 
>>> where to start to dig.  Although removing ranged_response, might be a 
>>> starting point…
>>> 
>>> URLs:
>>> path("download/", frontend.views.new_download, 
>>> name="downloads"),
>>> path('thumbnails/', frontend.views.thumbnails, 
>>> name="raw thumbnails"),
>>> 
>>> 
>>> First, I am using these function for all graphics and/or file(s) being sent:
>>> 
>>> def new_download(request, d_uuid=None):
>>> page = request.GET.get('page', None)
>>> if page is None:
>>> download = index_data.objects.filter(uuid=d_uuid,
>>>  ignore=False,
>>>  delete_pending=False)[0]
>>> else:
>>> print ("Attempting to find page %s in archive" % page)
>>> print("\tDownloading - %s, %s" % (download.fqpndirectory.lower(),
>>>   download.name 
>>> ))
>>> return respond_as_inline(request,
>>>  "%s%s%s" % (
>>>  configdata["locations"]["albums_path"],
>>>  os.sep,
>>>  download.fqpndirectory),
>>>  download.name )
>>> 
>>> 
>>> def respond_as_inline(request, file_path, original_filename, ranged=False):
>>> # https://stackoverflow.com/questions/36392510/django-download-a-file 
>>> 
>>> # 
>>> https://stackoverflow.com/questions/27712778/video-plays-in-other-browsers-but-not-safari
>>>  
>>> 

Re: CRUD Generator

2021-01-09 Thread David Nugent
Actually, this might help:

https://github.com/pydanny/cookiecutter-djangopackage

Cookiecutter is very simple to use, and this is a template you use with it that 
generates a boilerplate entire (reusable) django app.

There's also a django project generator that I've recently started to use 
because the project layout - although not "standard startproject" format - is 
pretty neat even if opinionated. It also mandates some additional django 
modules that are great to use both in development and runtime. I don't exactly 
like some aspects of the layout it uses (namely so much non-code going into the 
app root, which should imho be less cluttered), but that's the beauty of it - 
templates are highly customisable.

It does generate your basic django boilerplate views, templates and even urls 
and admin.  I've not actually used it yet, but now that I've discovered it, I 
fully intend to.

/d


On 10 January 2021 at 11:37:43, dav...@uniquode.io 
(dav...@uniquode.io) wrote:

Well, yes, sure you can. But I think the OP had something in mind like 
https://pypi.org/project/drf-generators/ (which is awsome btw) but targeted at 
crud views / forms.

I must admit this is one of the nice things that rails scaffold provides in the 
RoR world.  The code generated by that is certainly not ideal nor even 
complete, but it does provide at least a lot of the required boilerplate.

-- 
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/etPan.5ffa6f27.3f7c1125.a5d6%40uniquode.io.


how to install pyenv-virtualenv on windows

2021-01-09 Thread Sohail Tanveer
im facing difficulty to install pyenv-virtual env on my windows 10
i googled it several times but it directs me to a git repo where there is 
an installation process but is of no use because, the command that is 
displayed is not working in my cmd 
please help me out

-- 
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/2ab1eded-9bac-4e7a-834a-4a4fe57a2418n%40googlegroups.com.


Re: CRUD Generator

2021-01-09 Thread David Nugent
Well, yes, sure you can. But I think the OP had something in mind like 
https://pypi.org/project/drf-generators/ (which is awsome btw) but targeted at 
crud views / forms.

I must admit this is one of the nice things that rails scaffold provides in the 
RoR world.  The code generated by that is certainly not ideal nor even 
complete, but it does provide at least a lot of the required boilerplate.

-- 
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/etPan.5ffa4c57.460cad8f.a5d6%40uniquode.io.


Re: hello guys, how can I upload multiple images using single button? help me please

2021-01-09 Thread Joseph Wayodi
Post your code here, and someone will help you figure out why it does
not work like you expect.

On Sat, 9 Jan 2021 at 22:07, Chelsea Fan  wrote:
>
> I tried it, it works but it saves last file twice, for example if I upload 2 
> file it saves 3
>
> On Sat, Jan 9, 2021 at 7:53 PM Joseph Wayodi  wrote:
>>
>> The Django docs show how to do this:
>> .
>>
>> On Thu, 7 Jan 2021 at 15:24, Chelsea Fan  
>> wrote:
>> >
>> >
>> > --
>> > 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/CAJwZndca8SC7ifBzyW4ut%3DJXy-2E3RPPvq2tHrpCyxyqABQnzw%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/CAOXm%2Bp8tF1Zpt1gmFH%3DTc6fin3ijf%2B3kDrc9j_yRR2ZBbxVfSA%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/CAJwZndefeU5b4a9J_JjyMpTHyr-dwQ5GCs-7eJf0Kvf3qdjUFQ%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/CAOXm%2Bp8W8jtHYSB2dW5rHo1NmdPGH3xB4b_opJ-0BH%2B%2BR6YS8Q%40mail.gmail.com.


Re: hello guys, how can I upload multiple images using single button? help me please

2021-01-09 Thread Chelsea Fan
I tried it, it works but it saves last file twice, for example if I upload
2 file it saves 3

On Sat, Jan 9, 2021 at 7:53 PM Joseph Wayodi  wrote:

> The Django docs show how to do this:
> <
> https://docs.djangoproject.com/en/3.1/topics/http/file-uploads/#uploading-multiple-files
> >.
>
> On Thu, 7 Jan 2021 at 15:24, Chelsea Fan 
> wrote:
> >
> >
> > --
> > 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/CAJwZndca8SC7ifBzyW4ut%3DJXy-2E3RPPvq2tHrpCyxyqABQnzw%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/CAOXm%2Bp8tF1Zpt1gmFH%3DTc6fin3ijf%2B3kDrc9j_yRR2ZBbxVfSA%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/CAJwZndefeU5b4a9J_JjyMpTHyr-dwQ5GCs-7eJf0Kvf3qdjUFQ%40mail.gmail.com.


Stack Overflow Question

2021-01-09 Thread Joel Tanko
Hey, guys any ideas on how to get about this?

Django CMS in Django
https://stackoverflow.com/q/65645573/12957767?sem=2

-- 
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/CAJ4Kmg6U%2BTxJ3ffmgAXA1EYduYcbQ5tGi6Ui4Fhef921faF%2Bag%40mail.gmail.com.


Re: hello guys, how can I upload multiple images using single button? help me please

2021-01-09 Thread Joseph Wayodi
The Django docs show how to do this:
.

On Thu, 7 Jan 2021 at 15:24, Chelsea Fan  wrote:
>
>
> --
> 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/CAJwZndca8SC7ifBzyW4ut%3DJXy-2E3RPPvq2tHrpCyxyqABQnzw%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/CAOXm%2Bp8tF1Zpt1gmFH%3DTc6fin3ijf%2B3kDrc9j_yRR2ZBbxVfSA%40mail.gmail.com.


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 Vishesh Mangla
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 <
> manglav...@gmail.com> 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 of
> birth 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 user
> 
> def 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 

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 Vishesh Mangla
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 of
birth 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 user

def 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
> 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...@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 

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.


Re: UserManager creation for AbstractUserModel extended MyUser

2021-01-09 Thread Vishesh Mangla
Another thing is that my "employees" group has an additional CharField 
requirement. Only the employees group.How can I add specifically a field to 
that group? Something this 
this:https://stackoverflow.com/questions/16407217/add-extra-fields-to-django-to-django-auth-groups

On Saturday, January 9, 2021 at 6:38:56 PM UTC+5:30 Vishesh Mangla wrote:

> Hi, please help me create this UserManager child class. I 'm stuck up on 
> this. I also need to divide my users into three groups.  
> For this I extended the migrations file.   https://dpaste.org/9VSd. But 
> running `makemigrations` gives no changes detected.
>  Please help with this issue too.
> Thanks in advance.
> On Saturday, January 9, 2021 at 6:35:34 PM UTC+5:30 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/6ff80f40-30e1-4c09-9dab-7eae9461d6b2n%40googlegroups.com.


Re: UserManager creation for AbstractUserModel extended MyUser

2021-01-09 Thread Vishesh Mangla
Hi, please help me create this UserManager child class. I 'm stuck up on 
this. I also need to divide my users into three groups.  
For this I extended the migrations file.   https://dpaste.org/9VSd. But 
running `makemigrations` gives no changes detected.
 Please help with this issue too.
Thanks in advance.
On Saturday, January 9, 2021 at 6:35:34 PM UTC+5:30 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/2aaa49cd-78bf-4168-b925-7f4c35320c8cn%40googlegroups.com.


UserManager creation for AbstractUserModel extended MyUser

2021-01-09 Thread Vishesh Mangla
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.


muliple queryset result

2021-01-09 Thread Soumen Khatua
Hi Folks,

Actually I have one *Primary *Table called *CustomUser *and I'm extending
this model as *Foreign *Key in *UserContactDetails model*. So now
basically *one
user have multiple contact details.* But whenever I'm applying *filter
*on *Primary
Table field* as well as *Foreign Key table* field, this queryset is
returnning  multiple Object inside queryset, like If my *ContactDetails *have
3 numbers of record for a user then it's returning the same record 3 number
of times inside queryset, can you guys tell me, How can I solve this
problem? I almost spend three hours on it, please help me.

*models.py*
**




















*class CustomUser(AbstractBaseUser, PermissionsMixin):email =
models.EmailField(_('email address'), unique=True)company_name =
models.CharField(max_length = 150)sap_code =
models.CharField(max_length = 150)is_staff =
models.BooleanField(default=False)is_active =
models.BooleanField(default=True)date_joined =
models.DateTimeField(default=timezone.now)USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []objects = CustomUserManager()class
UserContactDetails(models.Model): user_details =
models.ForeignKey(CustomUser, related_name = 'usercontactdetailes',
related_query_name = 'usercontactdetaies', on_delete = models.CASCADE)
address = models.CharField(max_length = 150) mobile_no =
models.CharField(max_length = 150) primary_contact =
models.BooleanField(default = False)*


*views.py*
**

*query = request.GET.get('param')*





* user_data = CustomUser.objects.filter(
 Q(usercontactdetaies__address = query)|
 Q(usercontactdetaies__mobile_no = query)|   Q(company_name__exact =
query) |   Q(sap_code__exact = query)  )*

* >,
>, >]>*

*Instead of returnning one matched object inside queryset it's returnning
three matched object because I have three contact details for this user.*


*Thank you in advance*

*Regards,*
*Soumen Khatua*

-- 
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/CAPUw6WYTgHtfOv1srrGem6emBFpOwPN77KpyyQZnKDyUhqm4SQ%40mail.gmail.com.


Re: Redirect one page to another on Django tremplate

2021-01-09 Thread Luciano Martins
Put your github repo

Em sábado, 9 de janeiro de 2021 às 08:11:31 UTC-3, Joel T escreveu:

> You can try using the javascript window.locqtion.href('redirect-url')
>
> On 7 Jan 2021 10:07 pm, "pankaj palmate"  wrote:
>
>> can you elaborate it more means are you taking about Response?
>>
>>
>> On Thursday, January 7, 2021 at 10:48:33 PM UTC+5:30 amanmo...@gmail.com 
>> wrote:
>>
>>> Hello Django Lover,
>>>
>>> I have a doubt how can we redirect one page to another on API response / 
>>> fetch response on Django 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/b96bed14-da97-4f0e-a9d5-a1b044f45dc7n%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/601487a1-6211-4cd2-a959-c406defc8b11n%40googlegroups.com.


Re: Redirect one page to another on Django tremplate

2021-01-09 Thread Joel Tanko
You can try using the javascript window.locqtion.href('redirect-url')

On 7 Jan 2021 10:07 pm, "pankaj palmate" 
wrote:

> can you elaborate it more means are you taking about Response?
>
>
> On Thursday, January 7, 2021 at 10:48:33 PM UTC+5:30 amanmo...@gmail.com
> wrote:
>
>> Hello Django Lover,
>>
>> I have a doubt how can we redirect one page to another on API response /
>> fetch response on Django 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/b96bed14-da97-4f0e-a9d5-a1b044f45dc7n%
> 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/CAJ4Kmg4uf6hYuudHm6f8vYWou9jw4JTCGgjx1fXPMY2c5je_hg%40mail.gmail.com.