Re: Tips On Migrating DB from other website to django with Postgresql

2018-04-11 Thread tango ward
Sorry for the follow up question, when you say run migration locally, this
is running python manage.py makemigrations and python manage.py migrate,
right?  Please let me know if I got these steps correctly:

- make a postgres test db
- changed database settings in settings.py and point it to test db in
postgres
- If i run makemigrations and migrate, the only db and tables that will be
saved in test db are the ones in our models.py

Should I modify the models.py to match the fields in the dump file? or
should I just check the existing data from the dump file and see which
model and fields it fits in our existing system?

My only experience with changing backend database in Django was when I
changed one of my pet projects db from SQLite to Postgres which I did in
settings.py.

On Thu, Apr 12, 2018 at 8:59 AM, tango ward  wrote:

> At the moment, I am comparing the fields from the dump file and the fields
> in our models.py. There are fields that exist on the dump file that are not
> yet in our existing model/models that why I want to know if should I modify
> the schema of our database to match the dump file of the client. I'm lost
> on this, sorry.
>
> On Thu, Apr 12, 2018 at 8:46 AM, Mike Dewhirst 
> wrote:
>
>> On 12/04/2018 9:47 AM, tango ward wrote:
>>
>>> Hi Mike,
>>>
>>>
>>> Thanks for the advice.
>>>
>>> May I ask as well, on Django side, since we have already an existing
>>> system, how should I adjust the fields that are existing from the dump file
>>> to the Django? Should I just add fields in models.py?
>>>
>>
>> Treat that as a separate task. You can do it before the migration or
>> after. I would preferdo it afterwards because I am more comfortable with
>> Postgres. And I suspect Postgres will be a better fit with Django.
>>
>> However, I'm not sure what you mean exactly by adjusting fields. Your
>> last question above indicates you want to change the schema in an existing
>> Django project. You need to consider when the fields need to be changed in
>> the context of real-world pressures from your production system users. It
>> might need to be sooner rather than later and that may force adjustments
>> prior to the move to Postgres.
>>
>> If there are problems with the existing MySQL system it would be best to
>> fix them before switching.
>>
>> The bottom line is that preparations and testing for the move has to
>> happen in parallel with ongoing support and maintenance and possibly
>> ongoing development of the production system. When you are ready to switch
>> and happy that it will go like clockwork the actual switch can be scheduled
>> as a definable task in the ongoing workflow. All developers will have to
>> switch at the same time - or prior if they can have access to your
>> completed scripts for their personal development databases.
>>
>> hth
>>
>> Mike
>>
>>
>>> On Thu, Apr 12, 2018 at 6:42 AM, Mike Dewhirst >> > wrote:
>>>
>>> On 11/04/2018 11:40 PM, tango ward wrote:
>>>
>>> Hi there,
>>>
>>> This will be my first time to migrate a database in my first
>>> programming job. I checked the dump file today and load it in
>>> MySQL benchmark to view the ERD. The database that I need to
>>> migrate has 48 tables and has existing data already.
>>>
>>>
>>> I would like to know what are the things that I need to do
>>> first. I'm gonna test the migration first in my local machine
>>> before bringing it to live production. I am currently reading
>>> https://wiki.postgresql.org/wiki/Converting_from_other_Datab
>>> ases_to_PostgreSQL
>>> >> bases_to_PostgreSQL>.
>>>
>>>
>>>
>>>
>>> Any suggestions will be highly appreciated.
>>>
>>>
>>> 1. Do the migration locally
>>>
>>> 2. Devise some repeatable automated success tests to prove the
>>> migration works
>>>
>>> 3. Set up a new VM as an exact duplicate production machine
>>> running MySQL. Use your hosts file to put its IP address somewhere
>>> else than the DNS points to. Beware that ACLs often use IP
>>> addresses rather than host names.
>>>
>>> 4. Do the migrations and run the tests on the duplicate machine.
>>> Debug as necessary.
>>>
>>> 5. Announce to users that the system is going down for planned
>>> maintenance
>>>
>>> 6. Remove your hosts file adjustment so your system is back to
>>> looking at the real production machine
>>>
>>> 7. Take production off-line and do a pre-migration dump or backup
>>> from which you can restore if things go wrong
>>>
>>> 8. Do the migration, run the tests then restore service
>>>
>>> I have done such things in the distant past but not recently. I
>>> may have forgotten something but in my opinion items 5 and 7 above
>>> are super critical.
>>>
>>> Good luck
>>>
>>> Mike
>>>
>>>
>>>
>>> Thanks,
>>> J
>>> -- You

Re: How to formulate a query over two models?

2018-04-11 Thread Simon Charette
Hello there,

If you are using PostgreSQL you can achieve it using ArrayAgg[0]

queryset = 
MetaData.objects.annotate(values=ArrayAgg('metadatavalue__value'))
map = dict(queryset.values_list('name', 'values'))

Cheers,
Simon

[0] https://docs.djangoproject.com/en/2.0/ref/contrib/postgres/aggregates/

Le mercredi 11 avril 2018 19:06:06 UTC-4, mark a écrit :
>
> I have two models:
>
> # MetaData
> class MetaData(models.Model):
> metadata_id = models.AutoField(primary_key = True)
> name = models.CharField('metadata name', max_length=200, unique=True)
> description = models.TextField('description')
>
> def __str__(self):
> return self.name
>
> # MetaData Value
> class MetaDataValue(models.Model):
> metadata_id = models.ForeignKey(MetaData, on_delete=models.CASCADE,)
> value = models.CharField('value', max_length=200, unique=True)
>
> def __str__(self):
> return self.value
>
> I want to construct a query set such that I get a dictionary back that 
> looks like this:
>
> {name1: [value1, value2,..], name2:[value3, value4,..]..}
>
> In other words, a dictionary that has the metadata name as the key and the 
> associated values for that name in a list.
>
> I have been playing around with MetaData.objects.all(), but I don't see 
> how to relate the two models and get something close to what I want.
>
> Thanks!
>
> Mark
>
>
>

-- 
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/150f7ef8-2096-4724-8462-24c05c6de072%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Tips On Migrating DB from other website to django with Postgresql

2018-04-11 Thread tango ward
At the moment, I am comparing the fields from the dump file and the fields
in our models.py. There are fields that exist on the dump file that are not
yet in our existing model/models that why I want to know if should I modify
the schema of our database to match the dump file of the client. I'm lost
on this, sorry.

On Thu, Apr 12, 2018 at 8:46 AM, Mike Dewhirst 
wrote:

> On 12/04/2018 9:47 AM, tango ward wrote:
>
>> Hi Mike,
>>
>>
>> Thanks for the advice.
>>
>> May I ask as well, on Django side, since we have already an existing
>> system, how should I adjust the fields that are existing from the dump file
>> to the Django? Should I just add fields in models.py?
>>
>
> Treat that as a separate task. You can do it before the migration or
> after. I would preferdo it afterwards because I am more comfortable with
> Postgres. And I suspect Postgres will be a better fit with Django.
>
> However, I'm not sure what you mean exactly by adjusting fields. Your last
> question above indicates you want to change the schema in an existing
> Django project. You need to consider when the fields need to be changed in
> the context of real-world pressures from your production system users. It
> might need to be sooner rather than later and that may force adjustments
> prior to the move to Postgres.
>
> If there are problems with the existing MySQL system it would be best to
> fix them before switching.
>
> The bottom line is that preparations and testing for the move has to
> happen in parallel with ongoing support and maintenance and possibly
> ongoing development of the production system. When you are ready to switch
> and happy that it will go like clockwork the actual switch can be scheduled
> as a definable task in the ongoing workflow. All developers will have to
> switch at the same time - or prior if they can have access to your
> completed scripts for their personal development databases.
>
> hth
>
> Mike
>
>
>> On Thu, Apr 12, 2018 at 6:42 AM, Mike Dewhirst > > wrote:
>>
>> On 11/04/2018 11:40 PM, tango ward wrote:
>>
>> Hi there,
>>
>> This will be my first time to migrate a database in my first
>> programming job. I checked the dump file today and load it in
>> MySQL benchmark to view the ERD. The database that I need to
>> migrate has 48 tables and has existing data already.
>>
>>
>> I would like to know what are the things that I need to do
>> first. I'm gonna test the migration first in my local machine
>> before bringing it to live production. I am currently reading
>> https://wiki.postgresql.org/wiki/Converting_from_other_Datab
>> ases_to_PostgreSQL
>> > bases_to_PostgreSQL>.
>>
>>
>>
>>
>> Any suggestions will be highly appreciated.
>>
>>
>> 1. Do the migration locally
>>
>> 2. Devise some repeatable automated success tests to prove the
>> migration works
>>
>> 3. Set up a new VM as an exact duplicate production machine
>> running MySQL. Use your hosts file to put its IP address somewhere
>> else than the DNS points to. Beware that ACLs often use IP
>> addresses rather than host names.
>>
>> 4. Do the migrations and run the tests on the duplicate machine.
>> Debug as necessary.
>>
>> 5. Announce to users that the system is going down for planned
>> maintenance
>>
>> 6. Remove your hosts file adjustment so your system is back to
>> looking at the real production machine
>>
>> 7. Take production off-line and do a pre-migration dump or backup
>> from which you can restore if things go wrong
>>
>> 8. Do the migration, run the tests then restore service
>>
>> I have done such things in the distant past but not recently. I
>> may have forgotten something but in my opinion items 5 and 7 above
>> are super critical.
>>
>> Good luck
>>
>> Mike
>>
>>
>>
>> Thanks,
>> J
>> -- 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/CAA6wQLKcf22a
>> 

Re: Tips On Migrating DB from other website to django with Postgresql

2018-04-11 Thread Mike Dewhirst

On 12/04/2018 9:47 AM, tango ward wrote:

Hi Mike,


Thanks for the advice.

May I ask as well, on Django side, since we have already an existing 
system, how should I adjust the fields that are existing from the dump 
file to the Django? Should I just add fields in models.py?


Treat that as a separate task. You can do it before the migration or 
after. I would preferdo it afterwards because I am more comfortable with 
Postgres. And I suspect Postgres will be a better fit with Django.


However, I'm not sure what you mean exactly by adjusting fields. Your 
last question above indicates you want to change the schema in an 
existing Django project. You need to consider when the fields need to be 
changed in the context of real-world pressures from your production 
system users. It might need to be sooner rather than later and that may 
force adjustments prior to the move to Postgres.


If there are problems with the existing MySQL system it would be best to 
fix them before switching.


The bottom line is that preparations and testing for the move has to 
happen in parallel with ongoing support and maintenance and possibly 
ongoing development of the production system. When you are ready to 
switch and happy that it will go like clockwork the actual switch can be 
scheduled as a definable task in the ongoing workflow. All developers 
will have to switch at the same time - or prior if they can have access 
to your completed scripts for their personal development databases.


hth

Mike



On Thu, Apr 12, 2018 at 6:42 AM, Mike Dewhirst > wrote:


On 11/04/2018 11:40 PM, tango ward wrote:

Hi there,

This will be my first time to migrate a database in my first
programming job. I checked the dump file today and load it in
MySQL benchmark to view the ERD. The database that I need to
migrate has 48 tables and has existing data already.


I would like to know what are the things that I need to do
first. I'm gonna test the migration first in my local machine
before bringing it to live production. I am currently reading

https://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL

.



Any suggestions will be highly appreciated.


1. Do the migration locally

2. Devise some repeatable automated success tests to prove the
migration works

3. Set up a new VM as an exact duplicate production machine
running MySQL. Use your hosts file to put its IP address somewhere
else than the DNS points to. Beware that ACLs often use IP
addresses rather than host names.

4. Do the migrations and run the tests on the duplicate machine.
Debug as necessary.

5. Announce to users that the system is going down for planned
maintenance

6. Remove your hosts file adjustment so your system is back to
looking at the real production machine

7. Take production off-line and do a pre-migration dump or backup
from which you can restore if things go wrong

8. Do the migration, run the tests then restore service

I have done such things in the distant past but not recently. I
may have forgotten something but in my opinion items 5 and 7 above
are super critical.

Good luck

Mike



Thanks,
J
-- 
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/CAA6wQLKcf22aXXKd6xUn%3DT6HOxHLBN7u1xcn%3DOXO3DdL%3D54XSg%40mail.gmail.com



>.
For more options, visit https://groups.google.com/d/optout
.

Re: How to formulate a query over two models?

2018-04-11 Thread Christophe Pettus

> On Apr 11, 2018, at 16:19, Mark Phillips  wrote:
> 
> Thanks for the link - I have read it before. I need to stay with these 
> models, so is there a simple query to get my result, or do I have to make 
> multiple queries and combine the data in python?

If you are using PostgreSQL, you can do it as a raw SQL query; otherwise, 
you'll need to transform the data in Python.

--
-- Christophe Pettus
   x...@thebuild.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/C504BED8-2CD3-4873-A1EB-E7AD00FA6353%40thebuild.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to formulate a query over two models?

2018-04-11 Thread Mark Phillips
Thanks for the link - I have read it before. I need to stay with these
models, so is there a simple query to get my result, or do I have to make
multiple queries and combine the data in python?

Thanks,

Mark

On Wed, Apr 11, 2018 at 4:14 PM, Christophe Pettus  wrote:

>
> > On Apr 11, 2018, at 16:05, Mark Phillips 
> wrote:
> >
> > I have two models:
> >
> > # MetaData
> > # MetaData Value
>
> First, you might want to make sure this is *really* the best way of
> representing your data:
>
> http://karwin.blogspot.com/2009/05/eav-fail.html
>
> That being said, you might consider getting rid of the MetaDataValue
> table, and putting the values in as a JSON field on MetaData.
>
> --
> -- Christophe Pettus
>x...@thebuild.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/8B07A737-9B74-4389-8423-A6CD3C7BCA58%40thebuild.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/CAEqej2Mrc7skJGzL%3DM42Zjm5W0tAVoLuz8p%2BuCQQTCxm_vT-QQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to formulate a query over two models?

2018-04-11 Thread Christophe Pettus

> On Apr 11, 2018, at 16:05, Mark Phillips  wrote:
> 
> I have two models:
> 
> # MetaData
> # MetaData Value

First, you might want to make sure this is *really* the best way of 
representing your data:

http://karwin.blogspot.com/2009/05/eav-fail.html

That being said, you might consider getting rid of the MetaDataValue table, and 
putting the values in as a JSON field on MetaData.

--
-- Christophe Pettus
   x...@thebuild.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/8B07A737-9B74-4389-8423-A6CD3C7BCA58%40thebuild.com.
For more options, visit https://groups.google.com/d/optout.


How to formulate a query over two models?

2018-04-11 Thread Mark Phillips
I have two models:

# MetaData
class MetaData(models.Model):
metadata_id = models.AutoField(primary_key = True)
name = models.CharField('metadata name', max_length=200, unique=True)
description = models.TextField('description')

def __str__(self):
return self.name

# MetaData Value
class MetaDataValue(models.Model):
metadata_id = models.ForeignKey(MetaData, on_delete=models.CASCADE,)
value = models.CharField('value', max_length=200, unique=True)

def __str__(self):
return self.value

I want to construct a query set such that I get a dictionary back that
looks like this:

{name1: [value1, value2,..], name2:[value3, value4,..]..}

In other words, a dictionary that has the metadata name as the key and the
associated values for that name in a list.

I have been playing around with MetaData.objects.all(), but I don't see how
to relate the two models and get something close to what I want.

Thanks!

Mark

-- 
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/CAEqej2MHC2BzZe3ptP7fgwAFB-SvuH7ffBTZfZLe%2BVjxQBvQ5A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Tips On Migrating DB from other website to django with Postgresql

2018-04-11 Thread Mike Dewhirst

On 11/04/2018 11:40 PM, tango ward wrote:

Hi there,

This will be my first time to migrate a database in my first 
programming job. I checked the dump file today and load it in MySQL 
benchmark to view the ERD. The database that I need to migrate has 48 
tables and has existing data already.



I would like to know what are the things that I need to do first. I'm 
gonna test the migration first in my local machine before bringing it 
to live production. I am currently reading 
https://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL. 




Any suggestions will be highly appreciated.


1. Do the migration locally

2. Devise some repeatable automated success tests to prove the migration 
works


3. Set up a new VM as an exact duplicate production machine running 
MySQL. Use your hosts file to put its IP address somewhere else than the 
DNS points to. Beware that ACLs often use IP addresses rather than host 
names.


4. Do the migrations and run the tests on the duplicate machine. Debug 
as necessary.


5. Announce to users that the system is going down for planned maintenance

6. Remove your hosts file adjustment so your system is back to looking 
at the real production machine


7. Take production off-line and do a pre-migration dump or backup from 
which you can restore if things go wrong


8. Do the migration, run the tests then restore service

I have done such things in the distant past but not recently. I may have 
forgotten something but in my opinion items 5 and 7 above are super 
critical.


Good luck

Mike




Thanks,
J
--
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/CAA6wQLKcf22aXXKd6xUn%3DT6HOxHLBN7u1xcn%3DOXO3DdL%3D54XSg%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/7934f43b-cd7f-7bf5-a88d-cbd8961d5741%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


How do you handle removal of unwanted content (urls, html) from user input?

2018-04-11 Thread Mateusz Kurowski
I would like to remove URLs and HTML from user input. For HTML there is *bleach 
 *library that someone linked today on 
IRC. I made a little formmixin for this.
But now i wonder, maybe you have better ways to do it? Some ready 
solutions? I would like to strip all HTTP and https links from the input as 
well. Should i just run a simple regex and remove all occurrences? Like:

result = re.sub(r"http\S+", "", text)



class UntrustedFormMixin:
"""
Delete values from input fields.
"""
html_strip_fields = []  # list of field names to clean html from
html_allowed_tags = []
html_allowed_attributes = {}
html_allowed_css_styles = []
html_allowed_protocols = []

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# 
https://bleach.readthedocs.io/en/latest/clean.html#bleach.sanitizer.Cleaner
self.HTML_cleaner = bleach.Cleaner(
tags=self.html_allowed_tags,
attributes=self.html_allowed_attributes,
styles=self.html_allowed_css_styles,
protocols=self.html_allowed_protocols,
)

def clean(self):
super().clean()
for key in self.html_strip_fields:
value = self.cleaned_data.get(key)
if value is not None:
self.cleaned_data[key] = self.HTML_cleaner.clean(value)
self.cleaned_data[key] = self.cleaned_data[key]


 

-- 
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/5d676cac-6a99-4797-bff8-f2eac3b67d83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Ann: django-rest-framework-datatables 0.2.1 released

2018-04-11 Thread izi
Hello,

I'm happy to announce the availability of the version 0.2.1 of 
django-rest-framework-datatables:

https://pypi.org/project/djangorestframework-datatables/

Django-rest-framework-datatables is a third party app that provides 
seamless integration between Django Rest Framework and Datatables 
(https://datatables.net).
Install django-rest-framework-datatables, call your API with 
"?format=datatables" and it will return a JSON structure that is fully 
compatible with what Datatables expects.
It handles searching, filtering, ordering and most usecases you can imagine 
with Datatables.

The great benefit of django-rest-framework-datatables is that you don’t 
have to create a different API, your API still work exactly the same unless 
you specify the datatables format on your request.

Links:
Github: https://github.com/izimobil/django-rest-framework-datatables
Documentation: 
http://django-rest-framework-datatables.readthedocs.io/en/latest/

Regards,

-- 
David Jean Louis

-- 
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/1bdcd0e9-1046-4b1b-882c-d467f51886d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: username and allowed alphanumeric, why?

2018-04-11 Thread Melvyn Sopacua
On dinsdag 10 april 2018 11:10:33 CEST Stefano Tranquillini wrote:

> mostly curiosity, why does the username
> https://docs.djangoproject.com/en/1.11/ref/contrib/auth/#django.contrib.auth
> .models.User.username allow only _, @, +, . and - characters?
> is there a reason for that?

Yeah. It's explained a few lines below in the box titled "Usernames and 
unicode". The special chars mentioned are just as random I presume.


-- 
Melvyn Sopacua

-- 
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/3678794.KDA58l0WCV%40fritzbook.
For more options, visit https://groups.google.com/d/optout.


Tips On Migrating DB from other website to django with Postgresql

2018-04-11 Thread tango ward
Hi there,

This will be my first time to migrate a database in my first programming
job. I checked the dump file today and load it in MySQL benchmark to view
the ERD. The database that I need to migrate has 48 tables and has existing
data already.


I would like to know what are the things that I need to do first. I'm gonna
test the migration first in my local machine before bringing it to live
production. I am currently reading
https://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL
.


Any suggestions will be highly appreciated.


Thanks,
J

-- 
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/CAA6wQLKcf22aXXKd6xUn%3DT6HOxHLBN7u1xcn%3DOXO3DdL%3D54XSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to achieve wildcard search using haystack in django

2018-04-11 Thread Gabriel - Iulian Dumbrava
Please note that there are a few considerations when using wildcards.
First, there are some issues with haystack and woosh, as the one here 
. 
Wildcards work by default with autosearch, otherwise you'll have to compile 
the query yourself.

On the other hand, you must consider the backend haystack uses. I haven't 
used Whoosh recently, but I know that other backends, like solr, for 
example uses by default a minimum of 3 character 'groups' when generating 
search items, so it may also be the case that the search you are doing does 
not fall into any of those groups.

marți, 10 aprilie 2018, 22:28:29 UTC+3, shaw...@gmail.com a scris:
>
> I am currently working on haystack search in django. I met 2 problems, 
> first, when I use 'Whoosh' engine, the search can only return the result 
> that match exactly the same with my search key, for example if I type 
> 'ABC', it cannot match 'ABCD' Secondly, how can I achieve wildcard search 
> using haystack? For example, if I type'A*C', it can return 'ABC', 'ABCCC' 
> 'AC' and so one. Or other method just to achieve the same result(Basically, 
> return the result that contains the key word in same order)
>
>

-- 
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/f36e2281-bd1f-48e8-8b77-ca655f7a16a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.