Re: Using Primary key in two fields

2018-10-17 Thread Ігор Магур
As I saw earlier, Django does not allow you to have two rows as autofield,
you can make your own save method for model. Ex. get first of
YourModel.objects invert sorted by wanted field, add to it's value 1 and
save

ср, 17 жовт. 2018, 08:55 користувач Rakhee Menon 
пише:

> Hi Everyone,
>
> I have a scenario where one field needs to be a primary key and another
> field needs to be an AutoFieldand Autofield requires a condition
> primary_key = true
>
> I get this error
> django_reports.MstCompositionFm.makeid: (fields.E100) AutoFields must set
> primary_key=True.
> django_reports.MstSalarystructure: (models.E026) The model cannot have
> more than one field with 'primary_key=True'
>
> This is my case:
>
> icatid = models.BigIntegerField(db_column='ICatID', primary_key=True)
> makedate = models.DateTimeField(db_column='MakeDate')
> revdate = models.DateTimeField(db_column='RevDate', blank=True, null=True)
>
> makeid = models.BigAutoField(db_column='MakeId', primary_key=False)
>
> It would be of great help if anyone could figure out whats the solution
>
> Thanks in Advance,
> Rakhee
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/341d511d-3c95-42b9-a22f-a5fa0c331da5%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEDge_zCsWNNwjWRYLvzRKdGmr2iKvn2UBmpQEg2kebyg3pyKw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


django username and password error

2018-10-17 Thread Joel Mathew
After attempting to redirect http to https by setting SECURE_SSL_REDIRECT
to True and a few other changes, suddenly I found myself locked out of
django login. It didnt accept my password, so I tried resetting it via
manage.py passwd and manage.py changepassword. I even created a new
superuser account and tried to login.

I am unable to login to django admin site and to the custom login which
used to work until yesterday night. I'm at a loss to think of what next to
check. Any ideas?


Joel G Mathew

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA%3Diw_-Md09MU-c7s2hHJ00zEdM0w4yf7hW4t1Cr24VeCEs8-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django username and password error

2018-10-17 Thread mottaz hejaze
does your server support SSL ? did you configure your server for SSL ?

On Wed, Oct 17, 2018 at 12:10 PM Joel Mathew  wrote:

> After attempting to redirect http to https by setting SECURE_SSL_REDIRECT
> to True and a few other changes, suddenly I found myself locked out of
> django login. It didnt accept my password, so I tried resetting it via
> manage.py passwd and manage.py changepassword. I even created a new
> superuser account and tried to login.
>
> I am unable to login to django admin site and to the custom login which
> used to work until yesterday night. I'm at a loss to think of what next to
> check. Any ideas?
>
>
> Joel G Mathew
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAA%3Diw_-Md09MU-c7s2hHJ00zEdM0w4yf7hW4t1Cr24VeCEs8-g%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHV4E-eC2uA7uDQWHm_A0Dh_%3D1txWdqD%2B2H1S4pMT7%3DDbn043w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django username and password error

2018-10-17 Thread Joel
Yes, my server did support ssl. But on my local development environment it
doesn't support ssl.

On Wed, 17 Oct, 2018, 4:41 PM mottaz hejaze,  wrote:

> does your server support SSL ? did you configure your server for SSL ?
>
> On Wed, Oct 17, 2018 at 12:10 PM Joel Mathew  wrote:
>
>> After attempting to redirect http to https by setting SECURE_SSL_REDIRECT
>> to True and a few other changes, suddenly I found myself locked out of
>> django login. It didnt accept my password, so I tried resetting it via
>> manage.py passwd and manage.py changepassword. I even created a new
>> superuser account and tried to login.
>>
>> I am unable to login to django admin site and to the custom login which
>> used to work until yesterday night. I'm at a loss to think of what next to
>> check. Any ideas?
>>
>>
>> Joel G Mathew
>>
>> --
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAA%3Diw_-Md09MU-c7s2hHJ00zEdM0w4yf7hW4t1Cr24VeCEs8-g%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHV4E-eC2uA7uDQWHm_A0Dh_%3D1txWdqD%2B2H1S4pMT7%3DDbn043w%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA%3Diw_-pDy8usVQL6PFeEmNArTnGQxRfUKtfhyaU%2B9C_yuOwdw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Primary key in two fields

2018-10-17 Thread Michal Petrucha
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

On Tue, Oct 16, 2018 at 10:55:48PM -0700, Rakhee Menon wrote:
> Hi Everyone,
> 
> I have a scenario where one field needs to be a primary key and another 
> field needs to be an AutoFieldand Autofield requires a condition 
> primary_key = true
> 
> I get this error 
> django_reports.MstCompositionFm.makeid: (fields.E100) AutoFields must set 
> primary_key=True.
> django_reports.MstSalarystructure: (models.E026) The model cannot have more 
> than one field with 'primary_key=True'
> 
> This is my case:
> 
> icatid = models.BigIntegerField(db_column='ICatID', primary_key=True)
> makedate = models.DateTimeField(db_column='MakeDate') 
> revdate = models.DateTimeField(db_column='RevDate', blank=True, null=True) 
> makeid = models.BigAutoField(db_column='MakeId', primary_key=False)
> 
> It would be of great help if anyone could figure out whats the solution

Hi Rakhee,

By definition, there may only be one primary key per table – primary
key is the unique key that has been chosen as the primary, all other
unique keys are secondary. AutoFields have a requirement that if they
are present in a table, they have to be the primary key of that table,
because that's how auto-increment columns work in certain databases.

What exactly is it that you're after? Do you just want both icatid and
makeid to be unique? If so, set primary_key=True on the AutoField, and
for icatid, just use unique=True instead. That will tell the database
that icatid is a secondary key.

Michal
-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iQIcBAEBCgAGBQJbxyMqAAoJEHA7T/IPM/klo8AP/i83PGOzi7+rwqc566VqdYT9
DY5SF9Vh/NAhCAxNVaC369yXRr2/L2EE0T3mDe9hMv/fSbSp00D25kFwsdLDC5TA
+tIzLN53777mAWFzTIjRhzQuc8usNRvHNcsbfJsaurbX1vm/EObdfjtnTlUzK2z2
KwieFMdbpLOicM7YDHGAGj/wF341blFhu0uDyeHQ6rcrEytaAtcMfPLEE92Ts3YR
qpxGPUwzAbhLOV5xcMsPgT6lnqE8JNxnBjA6DAqxoVk02c2tDoqEiPb71VvPzKdC
OEDxlN4veDSBciuP/ngNHG3kKL7EB5Ce60lo4pAPABhxx8YB6SVJ5gisP6s69j0w
xodELja8zVcrNi0uE0LgnvwS64XG1U5vPSSX6HJzZhozPP2aoP+NZEWcV94IX51O
4BfjWFn45LKLGy+/KENlgvPKMoKSYd9tuTcDFKDmLDb62JIq2ylCFUfj5kdxdZSO
8uMf9ZexQ9Gz604Hbl/xDneUV8k/xu5yfrHk6BX0YRtBxtqIF8E8ZYviqagp2Dw2
Z/zdNSMIGD+j3VxaY7ixGwcHq2svHY/g6AiqUXlA4NuM6KGLO+aWRcjlErryp4gL
q5Kuz5+4UCczpj/qKuNym/6t7BKn51pzX97gZghIVM9A2R5guOW30TB5PCJvgzDN
nOR2s5TXmuVEUdfiOU7d
=D1aU
-END PGP SIGNATURE-

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20181017115522.GO18928%40konk.org.
For more options, visit https://groups.google.com/d/optout.


Re: django username and password error

2018-10-17 Thread mottaz hejaze
try this :
https://github.com/teddziuba/django-sslserver



On Wed, Oct 17, 2018 at 1:14 PM Joel  wrote:

> Yes, my server did support ssl. But on my local development environment it
> doesn't support ssl.
>
> On Wed, 17 Oct, 2018, 4:41 PM mottaz hejaze,  wrote:
>
>> does your server support SSL ? did you configure your server for SSL ?
>>
>> On Wed, Oct 17, 2018 at 12:10 PM Joel Mathew  wrote:
>>
>>> After attempting to redirect http to https by
>>> setting SECURE_SSL_REDIRECT to True and a few other changes, suddenly I
>>> found myself locked out of django login. It didnt accept my password, so I
>>> tried resetting it via manage.py passwd and manage.py changepassword. I
>>> even created a new superuser account and tried to login.
>>>
>>> I am unable to login to django admin site and to the custom login which
>>> used to work until yesterday night. I'm at a loss to think of what next to
>>> check. Any ideas?
>>>
>>>
>>> Joel G Mathew
>>>
>>> --
>>> 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 post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAA%3Diw_-Md09MU-c7s2hHJ00zEdM0w4yf7hW4t1Cr24VeCEs8-g%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAHV4E-eC2uA7uDQWHm_A0Dh_%3D1txWdqD%2B2H1S4pMT7%3DDbn043w%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAA%3Diw_-pDy8usVQL6PFeEmNArTnGQxRfUKtfhyaU%2B9C_yuOwdw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHV4E-fXCwN%2BPh%2B2H2GTqnL-Y3S5EdEsb-2GW9UJUEN78PqjSw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How express SQL query using Django ORM?

2018-10-17 Thread v . kiselicya0210 . work
Price.objects.annotate(_sel=Max('from_date')).filter(from_date=F('_sel')).values("category_id",
 
"price")

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eacda66c-51c1-4a03-997c-cf717adfafd6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Admin get_queryset by sql

2018-10-17 Thread pengheqing
When the data of my Admin list page comes from multiple data sources,
 the method I can think of is Model.objects.raw(sql), 
but when I override the get_queryset() method and return this Rawquery, 
I throw an error: 'RawQuery' object has no attribute 'filter'
If I want to implement this function, what do I need to do?

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0fd1-dfdd-40b4-9ebf-497496a67dd5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Need help in creating responsive web page using Python

2018-10-17 Thread Soumya Mishra
I am totally new to development

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b82aa641-b37d-43b4-a4ff-53e3aaf6a83f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Why Django don't cache part of the result when the queryset is partly evaluated?

2018-10-17 Thread 胡凯旋
As official document 

 said, 
the code will query database twice.

>>> queryset = Entry.objects.all()
>>> print(queryset[5]) # Queries the database
>>> print(queryset[5]) # Queries the database again


 Why don't just cache the record at index 5 of this queryset? When execute 
queryset[5] again, fetch result from cache rather than database? 

Is there any reason don't cache results of queryset partly? 

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/067a1251-955b-4cd0-a148-358179104729%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How express SQL query using Django ORM?

2018-10-17 Thread Artem Malyshev
Hi, thanks for the reply!

This gives me following query:

SELECT "example_price"."category_id",
   "example_price"."cost"
  FROM "example_price"
 GROUP BY "example_price"."id",
  "example_price"."category_id",
  "example_price"."from_date",
  "example_price"."cost",
  "example_price"."period"
HAVING "example_price"."from_date" = (MAX("example_price"."from_date"))

It's not quite right.

Is there a way to have different fields in the SELECT and in the GROUP BY?

Regards, Artem.

On Wednesday, October 17, 2018 at 4:04:04 PM UTC+3, v.kiselicy...@gmail.com 
wrote:
>
> Price.objects.annotate(_sel=Max('from_date')).filter(from_date=F('_sel')).values("category_id",
>  
> "price")
>
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2902f2f5-1733-4f16-b831-6eebee8e0a3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help in creating responsive web page using Python

2018-10-17 Thread Mikhailo Keda
It's not related to Python, check https://getbootstrap.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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e22eab40-11b4-449d-9506-bf3ecac62023%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help in creating responsive web page using Python

2018-10-17 Thread nerdfiles
Try using http://surge.sh with https://foundation.zurb.com/templates.html.


On Wednesday, October 17, 2018 at 8:04:04 AM UTC-5, Soumya Mishra wrote:
>
> I am totally new to development
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8b467115-d58b-45d8-91e4-a69a18c93aea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Creating seperate unique ids within the same table

2018-10-17 Thread Joel Mathew
I have an application which is a clinic management software which allows
login into different clinics, and needs to keep patient records of each
clinic seperately. The patient records are filed in one common model, with
a ForeignKey referring to the clinic to which a patient belongs.

Hitherto I had used the AutoField primary key of the customer model as a
hospital identification number for the patient. This number is unique and
used throughout the application to retrieve querysets related to the
customer. My problem is this. I want each patient to have a unique
automatically incrementing id which can be given to them. Obviously since
all patient records (irrespective of which clinic the patient belongs to)
are stored in one model, the ids are not seperated by clinic. cstid 1 may
be of clinic 1, cstid 5 may again be of clinic 1, but cstid 6 may be of
clinic 2.

I need patients  of one clinic to have continuous ids unique to each
clinic. What can I do to achieve this, within my defined models?

class Clinic(models.Model):
clinicid = models.AutoField(primary_key=True, unique=True)
name = models.CharField(max_length=60, unique=True)
label = models.SlugField(max_length=25, unique=True)
email = models.EmailField(max_length=50, default='')
mobile = models.CharField(max_length=15, default='')
alternate = models.CharField(max_length=15, default='', blank=True)
about = models.CharField(max_length=250, blank=True)
state = models.CharField(max_length=25)
city = models.CharField(max_length=35)
locality = models.CharField(max_length=35)
pincode = models.IntegerField(default=0)
address = models.TextField(max_length=80, default='', blank=True)
website = models.URLField(blank=True)
logo = models.ForeignKey(ProfilePic, blank=True, null=True,
on_delete=models.CASCADE)
latitude = models.FloatField(blank=True)
longitude = models.FloatField(blank=True)
placeurl = models.URLField(blank=True)
class Meta:
unique_together = ["name", "mobile", "email"]
def __str__(self):
return self.name

class customer(models.Model):
# Need autoincrement, unique and primary
cstid = models.AutoField(primary_key=True, unique=True)
name = models.CharField(max_length=35)
age=models.IntegerField()
gender_choices = (
('male', 'Male'),
('female', 'Female'),
('other', 'Something else'),
('decline', 'Decline to answer'))
gender = models.CharField(
choices=gender_choices, max_length=10, default='male')
maritalstatus_choices = (
('unmarried', 'Unmarried'),
('married', 'Married'))
maritalstatus = models.CharField(
choices=maritalstatus_choices, max_length=10,
default='Unmarried')
mobile = models.CharField(max_length=15, default='')
alternate = models.CharField(max_length=15, default='', blank=True)
email = models.CharField(max_length=50, default='', blank=True)
address = models.CharField(max_length=80, default='', blank=True)
city = models.CharField(max_length=25, default='', blank=True)
occupation = models.CharField(max_length=25, default='', blank=True)
bloodgroup_choices = (('apos', 'A+'),
('aneg', 'A-'),
('bpos', 'B+'),
('bneg', 'B-'),
('opos', 'O+'),
('oneg', 'O-'),
('abpos', 'AB+'),
('abneg', 'AB-')
)
bloodgroup = models.CharField(choices=bloodgroup_choices,
max_length=5, default='-', blank=True)
linkedclinic = models.ForeignKey(Clinic, on_delete=models.CASCADE)
class Meta:
unique_together = ["name", "mobile", "age", "linkedclinic"]
def __str__(self):
return self.name

My thoughts are on counting the number of customer objects with specific
ForeignKey of a clinic, and then updating hospital id field in the same
model. But probably there's a more logical less tedious way of doing this?
Or should I be creating seperate tables for each clinic?

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA%3Diw_98pujPThLkq6FCqGPqJYkE1U4HF1RswQaGTv8QGc7xXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Need help for sql stored proc

2018-10-17 Thread Gurmeet Kaur
Hi all,

I have a ms sql stored proc and want to use it. How can I do that? Do I
need to write the class just like a view in models.py?

Please suggest.

Thanks,
Gurmeet Kaur

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEbKJVg%3DRfXuokWh9SPakJLUq3qCVrmk-DBaFSXi3xu651fZ-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help for sql stored proc

2018-10-17 Thread Sudha Mohan
hi friends tell me future of django jobs and salaries with 2+ experience


On Wed, Oct 17, 2018 at 9:36 PM Gurmeet Kaur
 wrote:
>
> Hi all,
>
> I have a ms sql stored proc and want to use it. How can I do that? Do I need 
> to write the class just like a view in models.py?
>
> Please suggest.
>
> Thanks,
> Gurmeet Kaur
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAEbKJVg%3DRfXuokWh9SPakJLUq3qCVrmk-DBaFSXi3xu651fZ-g%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKcBU_8j73jebOuf4OQFQz-40MGdGiRZEtruu4pBzAW%3DQT8ekg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


RE: Need help for sql stored proc

2018-10-17 Thread Matthew Pava
https://docs.djangoproject.com/en/2.1/topics/db/sql/#calling-stored-procedures


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Gurmeet Kaur
Sent: Wednesday, October 17, 2018 11:06 AM
To: django-users@googlegroups.com
Subject: Need help for sql stored proc

Hi all,

I have a ms sql stored proc and want to use it. How can I do that? Do I need to 
write the class just like a view in models.py?

Please suggest.

Thanks,
Gurmeet Kaur
--
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 post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEbKJVg%3DRfXuokWh9SPakJLUq3qCVrmk-DBaFSXi3xu651fZ-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5e22807f4c0e49fd80f4ea2a7273c965%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Creating seperate unique ids within the same table

2018-10-17 Thread Matthew Pava
A number is a number, and we don’t need to attach meaning to it.
Why do you need to have continuous ids unique to each clinic?  As a developer, 
I would object to anyone forcing such a requirement.  If they insisted, then I 
would add a property that is calculated each time based on the count of 
patients in the clinic.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Joel Mathew
Sent: Wednesday, October 17, 2018 11:01 AM
To: django-users@googlegroups.com
Subject: Creating seperate unique ids within the same table

I have an application which is a clinic management software which allows login 
into different clinics, and needs to keep patient records of each clinic 
seperately. The patient records are filed in one common model, with a 
ForeignKey referring to the clinic to which a patient belongs.

Hitherto I had used the AutoField primary key of the customer model as a 
hospital identification number for the patient. This number is unique and used 
throughout the application to retrieve querysets related to the customer. My 
problem is this. I want each patient to have a unique automatically 
incrementing id which can be given to them. Obviously since all patient records 
(irrespective of which clinic the patient belongs to) are stored in one model, 
the ids are not seperated by clinic. cstid 1 may be of clinic 1, cstid 5 may 
again be of clinic 1, but cstid 6 may be of clinic 2.

I need patients  of one clinic to have continuous ids unique to each clinic. 
What can I do to achieve this, within my defined models?

class Clinic(models.Model):
clinicid = models.AutoField(primary_key=True, unique=True)
name = models.CharField(max_length=60, unique=True)
label = models.SlugField(max_length=25, unique=True)
email = models.EmailField(max_length=50, default='')
mobile = models.CharField(max_length=15, default='')
alternate = models.CharField(max_length=15, default='', blank=True)
about = models.CharField(max_length=250, blank=True)
state = models.CharField(max_length=25)
city = models.CharField(max_length=35)
locality = models.CharField(max_length=35)
pincode = models.IntegerField(default=0)
address = models.TextField(max_length=80, default='', blank=True)
website = models.URLField(blank=True)
logo = models.ForeignKey(ProfilePic, blank=True, null=True, 
on_delete=models.CASCADE)
latitude = models.FloatField(blank=True)
longitude = models.FloatField(blank=True)
placeurl = models.URLField(blank=True)
class Meta:
unique_together = ["name", "mobile", "email"]
def __str__(self):
return self.name

class customer(models.Model):
# Need autoincrement, unique and primary
cstid = models.AutoField(primary_key=True, unique=True)
name = models.CharField(max_length=35)
age=models.IntegerField()
gender_choices = (
('male', 'Male'),
('female', 'Female'),
('other', 'Something else'),
('decline', 'Decline to answer'))
gender = models.CharField(
choices=gender_choices, max_length=10, default='male')
maritalstatus_choices = (
('unmarried', 'Unmarried'),
('married', 'Married'))
maritalstatus = models.CharField(
choices=maritalstatus_choices, max_length=10, default='Unmarried')
mobile = models.CharField(max_length=15, default='')
alternate = models.CharField(max_length=15, default='', blank=True)
email = models.CharField(max_length=50, default='', blank=True)
address = models.CharField(max_length=80, default='', blank=True)
city = models.CharField(max_length=25, default='', blank=True)
occupation = models.CharField(max_length=25, default='', blank=True)
bloodgroup_choices = (('apos', 'A+'),
('aneg', 'A-'),
('bpos', 'B+'),
('bneg', 'B-'),
('opos', 'O+'),
('oneg', 'O-'),
('abpos', 'AB+'),
('abneg', 'AB-')
)
bloodgroup = models.CharField(choices=bloodgroup_choices, max_length=5, 
default='-', blank=True)
linkedclinic = models.ForeignKey(Clinic, on_delete=models.CASCADE)
class Meta:
unique_together = ["name", "mobile", "age", "linkedclinic"]
def __str__(self):
return self.name

My thoughts are on counting the number of customer objects with specific 
ForeignKey of a clinic, and then updating hospital id field in the same model. 
But probably there's a more logical less tedious way of doing this? Or should I 
be creating seperate tables for each clinic?
--
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 a

Re: Need help in creating responsive web page using Python

2018-10-17 Thread Daniel Veazey
A good place to start is the official tutorials:
https://docs.djangoproject.com/en/2.1/intro/

Incorporating Bootstrap is a good way to make your sites responsive:
https://getbootstrap.com/
https://www.w3schools.com/bootstrap4/default.asp

On Wednesday, October 17, 2018 at 8:04:04 AM UTC-5, Soumya Mishra wrote:
>
> I am totally new to development
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c53b9b5d-7f2d-4a22-8e79-e44178ccb41b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help for sql stored proc

2018-10-17 Thread Gurmeet Kaur
Thank you Matthew for sharing this link with me but my situation is:

I have some textboxes whose value I want to pass to sql query and want to
do a select *. Right now, I am doing that with the help of queryset but the
issue I am facing with this approach is that I need to do multiple ifs and
else because user is not restricted to pass values in all textboxes.

If I use cursor.callproc(), will I be able to get the data and show it on
the page? If yes then how can I do that?

Please suggest.

On Wed, Oct 17, 2018 at 12:10 PM Matthew Pava  wrote:

>
> https://docs.djangoproject.com/en/2.1/topics/db/sql/#calling-stored-procedures
>
>
>
>
>
> *From:* django-users@googlegroups.com [mailto:
> django-users@googlegroups.com] *On Behalf Of *Gurmeet Kaur
> *Sent:* Wednesday, October 17, 2018 11:06 AM
> *To:* django-users@googlegroups.com
> *Subject:* Need help for sql stored proc
>
>
>
> Hi all,
>
>
>
> I have a ms sql stored proc and want to use it. How can I do that? Do I
> need to write the class just like a view in models.py?
>
>
>
> Please suggest.
>
>
>
> Thanks,
>
> Gurmeet Kaur
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAEbKJVg%3DRfXuokWh9SPakJLUq3qCVrmk-DBaFSXi3xu651fZ-g%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5e22807f4c0e49fd80f4ea2a7273c965%40ISS1.ISS.LOCAL
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEbKJVi_GxCLB5rq%3DdWvp1QdcdFnN%3DY_cdsjz0Jb%2BdVGQoJexw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


help for a Django project

2018-10-17 Thread fatoubinetou196
Hi! I wanted to know if you could frame me on how to design my application 
of visualizations of the statutes of a payments by the owner with Django. 
Because it's my first time and I do not quite understand how to list this 
project in app.

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bd23e63b-45b2-4b4b-9d6a-448a8d7c0c67%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Creating seperate unique ids within the same table

2018-10-17 Thread Joel Mathew
A hospital id needs to be assigned to a patient and printed on their id
card. When they present their card or this number, their records can be
retrieved at any time. A checkin id is additionally generated each day
based on the date and time. A patient can have only one patient id but many
checkin ids.

What can be a good approach to solve this? Should I perhaps create another
table just to store the last patient id issued to each clinic?




On Wed, 17 Oct 2018 at 21:49, Matthew Pava  wrote:

> A number is a number, and we don’t need to attach meaning to it.
>
> Why do you need to have continuous ids unique to each clinic?  As a
> developer, I would object to anyone forcing such a requirement.  If they
> insisted, then I would add a property that is calculated each time based on
> the count of patients in the clinic.
>
>
>
> *From:* django-users@googlegroups.com [mailto:
> django-users@googlegroups.com] *On Behalf Of *Joel Mathew
> *Sent:* Wednesday, October 17, 2018 11:01 AM
> *To:* django-users@googlegroups.com
> *Subject:* Creating seperate unique ids within the same table
>
>
>
> I have an application which is a clinic management software which allows
> login into different clinics, and needs to keep patient records of each
> clinic seperately. The patient records are filed in one common model, with
> a ForeignKey referring to the clinic to which a patient belongs.
>
>
>
> Hitherto I had used the AutoField primary key of the customer model as a
> hospital identification number for the patient. This number is unique and
> used throughout the application to retrieve querysets related to the
> customer. My problem is this. I want each patient to have a unique
> automatically incrementing id which can be given to them. Obviously since
> all patient records (irrespective of which clinic the patient belongs to)
> are stored in one model, the ids are not seperated by clinic. cstid 1 may
> be of clinic 1, cstid 5 may again be of clinic 1, but cstid 6 may be of
> clinic 2.
>
>
>
> I need patients  of one clinic to have continuous ids unique to each
> clinic. What can I do to achieve this, within my defined models?
>
>
>
> class Clinic(models.Model):
>
> clinicid = models.AutoField(primary_key=True, unique=True)
>
> name = models.CharField(max_length=60, unique=True)
>
> label = models.SlugField(max_length=25, unique=True)
>
> email = models.EmailField(max_length=50, default='')
>
> mobile = models.CharField(max_length=15, default='')
>
> alternate = models.CharField(max_length=15, default='', blank=True)
>
> about = models.CharField(max_length=250, blank=True)
>
> state = models.CharField(max_length=25)
>
> city = models.CharField(max_length=35)
>
> locality = models.CharField(max_length=35)
>
> pincode = models.IntegerField(default=0)
>
> address = models.TextField(max_length=80, default='', blank=True)
>
> website = models.URLField(blank=True)
>
> logo = models.ForeignKey(ProfilePic, blank=True, null=True,
> on_delete=models.CASCADE)
>
> latitude = models.FloatField(blank=True)
>
> longitude = models.FloatField(blank=True)
>
> placeurl = models.URLField(blank=True)
>
> class Meta:
>
> unique_together = ["name", "mobile", "email"]
>
> def __str__(self):
>
> return self.name
>
>
>
> class customer(models.Model):
>
> # Need autoincrement, unique and primary
>
> cstid = models.AutoField(primary_key=True, unique=True)
>
> name = models.CharField(max_length=35)
>
> age=models.IntegerField()
>
> gender_choices = (
>
> ('male', 'Male'),
>
> ('female', 'Female'),
>
> ('other', 'Something else'),
>
> ('decline', 'Decline to answer'))
>
> gender = models.CharField(
>
> choices=gender_choices, max_length=10, default='male')
>
> maritalstatus_choices = (
>
> ('unmarried', 'Unmarried'),
>
> ('married', 'Married'))
>
> maritalstatus = models.CharField(
>
> choices=maritalstatus_choices, max_length=10,
> default='Unmarried')
>
> mobile = models.CharField(max_length=15, default='')
>
> alternate = models.CharField(max_length=15, default='', blank=True)
>
> email = models.CharField(max_length=50, default='', blank=True)
>
> address = models.CharField(max_length=80, default='', blank=True)
>
> city = models.CharField(max_length=25, default='', blank=True)
>
> occupation = models.CharField(max_length=25, default='',
> blank=True)
>
> bloodgroup_choices = (('apos', 'A+'),
>
> ('aneg', 'A-'),
>
> ('bpos', 'B+'),
>
> ('bneg', 'B-'),
>
> ('opos', 'O+'),
>
> ('oneg', 'O-'),
>
> ('abpos', 'AB+'),
>
> ('abneg', 'AB-')
>
> )
>
> bloodgroup =

Re: Creating seperate unique ids within the same table

2018-10-17 Thread Phako Perez
I suggest to use another table for visit so you can add which doctor, schedule 
time, and comments or so as a patient may have 1 visit or n...

Sent from my iPhone

> On Oct 17, 2018, at 9:59 PM, Joel Mathew  wrote:
> 
> A hospital id needs to be assigned to a patient and printed on their id card. 
> When they present their card or this number, their records can be retrieved 
> at any time. A checkin id is additionally generated each day based on the 
> date and time. A patient can have only one patient id but many checkin ids.
> 
> What can be a good approach to solve this? Should I perhaps create another 
> table just to store the last patient id issued to each clinic?
> 
> 
> 
> 
>> On Wed, 17 Oct 2018 at 21:49, Matthew Pava  wrote:
>> A number is a number, and we don’t need to attach meaning to it.
>> 
>> Why do you need to have continuous ids unique to each clinic?  As a 
>> developer, I would object to anyone forcing such a requirement.  If they 
>> insisted, then I would add a property that is calculated each time based on 
>> the count of patients in the clinic.
>> 
>>  
>> 
>> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] 
>> On Behalf Of Joel Mathew
>> Sent: Wednesday, October 17, 2018 11:01 AM
>> To: django-users@googlegroups.com
>> Subject: Creating seperate unique ids within the same table
>> 
>>  
>> 
>> I have an application which is a clinic management software which allows 
>> login into different clinics, and needs to keep patient records of each 
>> clinic seperately. The patient records are filed in one common model, with a 
>> ForeignKey referring to the clinic to which a patient belongs.
>> 
>>  
>> 
>> Hitherto I had used the AutoField primary key of the customer model as a 
>> hospital identification number for the patient. This number is unique and 
>> used throughout the application to retrieve querysets related to the 
>> customer. My problem is this. I want each patient to have a unique 
>> automatically incrementing id which can be given to them. Obviously since 
>> all patient records (irrespective of which clinic the patient belongs to) 
>> are stored in one model, the ids are not seperated by clinic. cstid 1 may be 
>> of clinic 1, cstid 5 may again be of clinic 1, but cstid 6 may be of clinic 
>> 2. 
>> 
>>  
>> 
>> I need patients  of one clinic to have continuous ids unique to each clinic. 
>> What can I do to achieve this, within my defined models?
>> 
>>  
>> 
>> class Clinic(models.Model):
>> 
>> clinicid = models.AutoField(primary_key=True, unique=True)
>> 
>> name = models.CharField(max_length=60, unique=True)
>> 
>> label = models.SlugField(max_length=25, unique=True)
>> 
>> email = models.EmailField(max_length=50, default='')
>> 
>> mobile = models.CharField(max_length=15, default='')
>> 
>> alternate = models.CharField(max_length=15, default='', blank=True)
>> 
>> about = models.CharField(max_length=250, blank=True)
>> 
>> state = models.CharField(max_length=25)
>> 
>> city = models.CharField(max_length=35)
>> 
>> locality = models.CharField(max_length=35)
>> 
>> pincode = models.IntegerField(default=0)
>> 
>> address = models.TextField(max_length=80, default='', blank=True)
>> 
>> website = models.URLField(blank=True)
>> 
>> logo = models.ForeignKey(ProfilePic, blank=True, null=True, 
>> on_delete=models.CASCADE)
>> 
>> latitude = models.FloatField(blank=True)
>> 
>> longitude = models.FloatField(blank=True)
>> 
>> placeurl = models.URLField(blank=True)
>> 
>> class Meta:
>> 
>> unique_together = ["name", "mobile", "email"]
>> 
>> def __str__(self):
>> 
>> return self.name
>> 
>> 
>> 
>> class customer(models.Model):
>> 
>> # Need autoincrement, unique and primary
>> 
>> cstid = models.AutoField(primary_key=True, unique=True)
>> 
>> name = models.CharField(max_length=35)
>> 
>> age=models.IntegerField()
>> 
>> gender_choices = (
>> 
>> ('male', 'Male'),
>> 
>> ('female', 'Female'),
>> 
>> ('other', 'Something else'),
>> 
>> ('decline', 'Decline to answer'))
>> 
>> gender = models.CharField(
>> 
>> choices=gender_choices, max_length=10, default='male')
>> 
>> maritalstatus_choices = (
>> 
>> ('unmarried', 'Unmarried'),
>> 
>> ('married', 'Married'))
>> 
>> maritalstatus = models.CharField(
>> 
>> choices=maritalstatus_choices, max_length=10, 
>> default='Unmarried')
>> 
>> mobile = models.CharField(max_length=15, default='')
>> 
>> alternate = models.CharField(max_length=15, default='', blank=True)
>> 
>> email = models.CharField(max_length=50, default='', blank=True)
>> 
>> address = models.CharField(max_length=80, default='', blank=True)
>> 
>> 

Re: Creating seperate unique ids within the same table

2018-10-17 Thread Joel Mathew
Hi Phako,
Thank you. I'm already following this practise. I have the following
additional Model:

class Checkins(models.Model):
checkinno = models.AutoField(primary_key=True, unique=True)
hospitalid = models.ForeignKey(
customer, on_delete=models.CASCADE, null=True)
date = models.DateField(default=timezone.now)
time = models.CharField(max_length=25)
consulted = models.IntegerField(default=0)
closed = models.IntegerField(default=0)
linkedclinic = models.ForeignKey(Clinic, on_delete=models.CASCADE)

Right now, the program's policy allows any doctor of that clinic to
see a patient who checked in to that clinic, so doctor is not a
ForeignKey for this. But later I may need to add this too.

What would you suggest for adding a unique number which gets
incremented for each new patient registration, and unique to each
clinic?
Sincerely yours,

Dr Joel G Mathew



On Thu, 18 Oct 2018 at 09:00, Phako Perez <13.phak...@gmail.com> wrote:
>
> I suggest to use another table for visit so you can add which doctor, 
> schedule time, and comments or so as a patient may have 1 visit or n...
>
> Sent from my iPhone
>
> On Oct 17, 2018, at 9:59 PM, Joel Mathew  wrote:
>
> A hospital id needs to be assigned to a patient and printed on their id card. 
> When they present their card or this number, their records can be retrieved 
> at any time. A checkin id is additionally generated each day based on the 
> date and time. A patient can have only one patient id but many checkin ids.
>
> What can be a good approach to solve this? Should I perhaps create another 
> table just to store the last patient id issued to each clinic?
>
>
>
>
> On Wed, 17 Oct 2018 at 21:49, Matthew Pava  wrote:
>>
>> A number is a number, and we don’t need to attach meaning to it.
>>
>> Why do you need to have continuous ids unique to each clinic?  As a 
>> developer, I would object to anyone forcing such a requirement.  If they 
>> insisted, then I would add a property that is calculated each time based on 
>> the count of patients in the clinic.
>>
>>
>>
>> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] 
>> On Behalf Of Joel Mathew
>> Sent: Wednesday, October 17, 2018 11:01 AM
>> To: django-users@googlegroups.com
>> Subject: Creating seperate unique ids within the same table
>>
>>
>>
>> I have an application which is a clinic management software which allows 
>> login into different clinics, and needs to keep patient records of each 
>> clinic seperately. The patient records are filed in one common model, with a 
>> ForeignKey referring to the clinic to which a patient belongs.
>>
>>
>>
>> Hitherto I had used the AutoField primary key of the customer model as a 
>> hospital identification number for the patient. This number is unique and 
>> used throughout the application to retrieve querysets related to the 
>> customer. My problem is this. I want each patient to have a unique 
>> automatically incrementing id which can be given to them. Obviously since 
>> all patient records (irrespective of which clinic the patient belongs to) 
>> are stored in one model, the ids are not seperated by clinic. cstid 1 may be 
>> of clinic 1, cstid 5 may again be of clinic 1, but cstid 6 may be of clinic 
>> 2.
>>
>>
>>
>> I need patients  of one clinic to have continuous ids unique to each clinic. 
>> What can I do to achieve this, within my defined models?
>>
>>
>>
>> class Clinic(models.Model):
>>
>> clinicid = models.AutoField(primary_key=True, unique=True)
>>
>> name = models.CharField(max_length=60, unique=True)
>>
>> label = models.SlugField(max_length=25, unique=True)
>>
>> email = models.EmailField(max_length=50, default='')
>>
>> mobile = models.CharField(max_length=15, default='')
>>
>> alternate = models.CharField(max_length=15, default='', blank=True)
>>
>> about = models.CharField(max_length=250, blank=True)
>>
>> state = models.CharField(max_length=25)
>>
>> city = models.CharField(max_length=35)
>>
>> locality = models.CharField(max_length=35)
>>
>> pincode = models.IntegerField(default=0)
>>
>> address = models.TextField(max_length=80, default='', blank=True)
>>
>> website = models.URLField(blank=True)
>>
>> logo = models.ForeignKey(ProfilePic, blank=True, null=True, 
>> on_delete=models.CASCADE)
>>
>> latitude = models.FloatField(blank=True)
>>
>> longitude = models.FloatField(blank=True)
>>
>> placeurl = models.URLField(blank=True)
>>
>> class Meta:
>>
>> unique_together = ["name", "mobile", "email"]
>>
>> def __str__(self):
>>
>> return self.name
>>
>>
>>
>> class customer(models.Model):
>>
>> # Need autoincrement, unique and primary
>>
>> cstid = models.AutoField(primary_key=True, unique=True)
>>
>> name = models.CharField(max_length=35)
>>
>> age=models.IntegerField()
>>
>>