Re: Mysql GeoDjango Distance search

2016-11-28 Thread bart
Het ip adres vertelt ongeveer waar iemand woont. 
Groet,Bart


Wysłano z telefonu Samsung
 Oorspronkelijk bericht Van: Sergiy Khohlov 
 Datum: 27-11-16  20:57  (GMT+01:00) Aan: django-users 
 Onderwerp: Re: Mysql GeoDjango Distance search 
MySQL  does not have  this support. I've tested few  potential solution but 
most of them have a hige problem with performance. 

Many thanks,

Serge


+380 636150445
skype: skhohlov

On Fri, Nov 25, 2016 at 1:52 PM, Karesh Arunakirinathan  
wrote:
down votefavoriteIs there any pure Django/faster way to get the distances less 
than x km. I have the modelclass Products(models.Model):
title = models.CharField(max_length=10)
point = models.PointField(srid=32140, null=True, blank=True)So I want to 
search the products less than x km from the persons view in mysql.? Because 
distance less than is only supported in postgresql. I want to do in mysql 
database. ThanksCould anyone help please ?



-- 

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/b914da61-bffc-4591-98d3-84d919420764%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/CADTRxJP-qQy2WBCqJeHCw0Tis63CDzfKE_fCcPZMJUEhB9tpFA%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/7u1frnuw0r6ekf32lr1qysfd.1480341908686%40email.android.com.
For more options, visit https://groups.google.com/d/optout.


Re: What is the best combination of components when installing Django on Windows 10?

2016-12-26 Thread bart
Beter Linux gebruike. Windows is shit to u se Django.


Wysłano z telefonu Samsung
 Oorspronkelijk bericht Van: Varuna Seneviratna 
 Datum: 26-12-16  07:11  (GMT+01:00) Aan: 
django-users@googlegroups.com Onderwerp: What is the best combination of 
components when installing Django on Windows 10? 
Hello,         What is the best combination of components to be used when 
installing Django on Windows 10; By Components, I mean the database and the web 
Server. 

Thanks, Varuna



-- 

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/CAKW-c0wiaY%3D9viR4r_A3yvNCPSGZbN6W-C5akZ-bRLXZgbiDOg%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/258u05i5fgs3q5idwvremujg.1482778598876%40email.android.com.
For more options, visit https://groups.google.com/d/optout.


Re: What is the best combination of components when installing Django on Windows 10?

2016-12-27 Thread bart
Don't u se Windows!


Wysłano z telefonu Samsung
 Oorspronkelijk bericht Van: "Ali Rıza P. Bayrı" 
 Datum: 27-12-16  15:54  (GMT+01:00) Aan: 
django-users@googlegroups.com Onderwerp: Re: What is the best combination of 
components when installing Django on Windows 10? 
My current environment for Windows 10 :
Django 1.10Python 3.4 Visual Studio 2015 community edition with PTVSMS SQL 
Express 2012
and Azure for deployment


 Sent with Mailtrack
2016-12-26 21:56 GMT+03:00 bart :
Beter Linux gebruike. Windows is shit to u se Django.


Wysłano z telefonu Samsung
 Oorspronkelijk bericht Van: Varuna Seneviratna 
 Datum: 26-12-16  07:11  (GMT+01:00) Aan: 
django-users@googlegroups.com Onderwerp: What is the best combination of 
components when installing Django on Windows 10? 
Hello,         What is the best combination of components to be used when 
installing Django on Windows 10; By Components, I mean the database and the web 
Server. 

Thanks, Varuna



-- 

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/CAKW-c0wiaY%3D9viR4r_A3yvNCPSGZbN6W-C5akZ-bRLXZgbiDOg%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/258u05i5fgs3q5idwvremujg.1482778598876%40email.android.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/CAMCFYd3Sw9UK2OGu5V2BWQhhb_GWEeuG5j2NxLyM2ob0iZ%3D6kg%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/co2y8wh7qpryqee21ng569cn.1482857952779%40email.android.com.
For more options, visit https://groups.google.com/d/optout.


Constraints on a one-to-many relationship and related problems

2011-12-28 Thread Bart Nagel
e billing address). But at this point it's too late to 
throw pretty exceptions if something goes wrong, which is a shame.

There's another problem there too. Once the billing address is set to 
one of the addresses and then the customer's addresses are later 
edited again I get horrific errors saying that the billing address is 
set to an unacceptable option. I think what's happening is that the 
addresses are being deleted and recreated, and so the reference in the 
billing address field now points to a non-existent primary key in the 
addresses table.

Since the above doesn't let me warn the user if they haven't entered 
any addresses, I needed another approach to let me do that. What I 
came up with was setting up a custom ModelForm for the Customer 
object's admin interface, and checking in the clean() method there. 
The best I could think to do was to print out dir() of various things 
to find likely looking methods and to see what data I had. The only 
reference to the addresses being entered I could find was in the 
self.data dict there. And it's messy, but I got a solution 
half-working by looking at self.data["address_set-TOTAL_FORMS"] and 
checking the number. But that doesn't cover all possibilities -- it 
might not exist (easy to deal with) and, slightly harder, some of the 
forms sent might have the "delete" box checked. So I had to count up 
to the number of forms and look for "address_set-%n-DELETE" keys. It's 
a mess and there's still a case it doesn't catch -- when a form is 
sent with the default (untouched) values and so doesn't actually end 
up creating an address. I'd see it as being an address and let it 
through, but then the billing address wouldn't have anything to point 
to. I didn't try to write code to handle that case because it's just 
getting way too messy.

So this solution is not working for me.

In fact, looking back, none of my solutions for any of the problems 
are adequate. I'm stuck.

Please help! Any suggestions are appreciated. Hopefully there are just 
some really easy things I've missed in the documents which will solve 
everything, but if the solution is a bit more in depth, so be it.

--bart nagel

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Constraints on a one-to-many relationship and related problems

2011-12-29 Thread Bart Nagel
At 2011-12-28 06:21:38 -0800, Dan Gentry wrote:
> Just looking at the models, I'd like to make a couple of suggestions.
> 
> Instead of using a Foreign Key relationship in Customer to indicate
> the billing address,  I would include a flag called 'billing_address'
> in the Address table that would be set to True for the customer
> selected address.
> 
> An override of save() in the Address model is then used to enforce the
> 'only one billing address' rule.

This certainly simplifies things, but there are still a couple of 
problems.

Firstly, the user gets no warning if he checks multiple "is billing 
address" boxes on the inline forms and it doesn't seem to be totally 
predictable which of the addresses' save methods will be called, and 
then which will be called last, and therefore which will end up being 
marked as the billing address. Any suggestions? Or is there a way to 
make them show up as radio buttons?

Next, there's nothing to stop no addresses being given, or no 
addresses being marked as the billing address. I guess I could put the 
monkey patch back on so I can force the first address to be billing if 
none is. Is that the best solution to this problem? But even then the 
problem of how to stop a customer being created if no addresses are 
given remains.

Thanks.

--bart

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Constraints on a one-to-many relationship and related problems

2011-12-29 Thread Bart Nagel
At 2011-12-28 06:59:31 -0800, Jay De Lanoy wrote:
> I'd go for a separate table instead, with something like
> 
> class BillingInfo(models.Model):
> customer = models.OneToOneField(Customer)
> billing_address = models.OneToOneField(Address)
> 
> and then just have logic in the views and templates to account for
> existence/nonexistence of a given customer's billing address.

Would this approach mean implementing my own forms to populate 
customers and addresses and not using the built-in Django admin forms 
at all? They were a major draw for me to Django.

Thanks.

--bart

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-admin.py startproject will NOT work.

2011-12-31 Thread Bart Nagel
At 2011-12-31 08:40:26 -0800, Chris Kavanagh wrote:
> While looking for a solution, I found someone with a similar problem.
> he thought there was a problem with the way Python Files are
> associated. So I did what was suggested on the command line, using
> "assoc.py" and ftype Python.File. What I got back is listed below. I
> don't think this is right according to what the message said.
> According to him, it should've returned ".py=Python.File" and
> "Python.File="C:\Python25\python.exe" "%1" %*". . .Obviously mine was
> different. Any suggestions???
> 
> 
> 
> 
> C:\>assoc .py
> .py=py_auto_file
> 
> C:\>ftype python.file
> File type 'python.file' not found or no open command associated with
> it.

Try
ftype py_auto_file

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-admin.py startproject will NOT work.

2011-12-31 Thread Bart Nagel
At 2011-12-31 19:47:35 +0300, Timothy Makobu wrote:
> File associations are fine i reckon, because django-admin is giving you the
> help message because for some reason it thinks you're *giving it improper
> input*.

What about other Python programs? Do they have the same problem?

Put this next paragraph in a file and run it with different numbers of 
arguments and see what happens.

import sys
print "%d arguments" % len(sys.argv)

Save it as args.py

Run
python args.py
python args.py arg1
python args.py arg1 arg2

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-admin.py startproject will NOT work.

2011-12-31 Thread Bart Nagel
At 2011-12-31 15:01:39 -0800, Chris Kavanagh wrote:
> On Dec 31, 11:58 am, Bart Nagel  wrote:
> > What about other Python programs? Do they have the same problem?
> >
> > Put this next paragraph in a file and run it with different numbers of
> > arguments and see what happens.
> >
> > import sys
> > print "%d arguments" % len(sys.argv)
> >
> > Save it as args.py
> >
> > Run
> >     python args.py
> >     python args.py arg1
> >     python args.py arg1 arg2
> 
> As far as other programs, I'm not sure. I'm not a programmer (just
> learned Python over the last few months) so I haven't tried any other
> programs yet.
> 
> Ok, so save the paragraph in a file, then run the commands from the
> command line EXACTLY as you have them? In other words, from command
> line, type in Python args.py, then python args.py arg1, and python
> args.py arg 2??
> 
> Forgive my ignorance, working from the command line with this stuff is
> new to me. And I've never understood exactly what command line args
> are. . .But I'm learning.

The command line is the dream, you'll come to love it. Well, maybe not 
the Windows one.

I guess first up just run
python
and see if you get the interactive Python shell. Or maybe you need
python.exe
since you're on Windows? Anyway, if you get the shell, the python 
executable is in your path and works to at least some extent. If you 
don't get the shell, and you get "command not found" or something (I 
don't have a Windows box so I don't know exactly what it would look 
like) you may need to use the full path to the executable, as people 
before have suggested.

So those two lines ("import..." and "print...") make a very simple 
Python script which just outputs the number of arguments it thinks it 
was given.

Invoke the script with Python just as you're meant to do for the 
Django script. On linux I just run
python args.py
and it tells me "1 arguments". If I run
python args.py something
it tells me "2 arguments" and so on.

What behaviour do you get?

The point of this is that if this python script can see the arguments 
then I can see absolutely no reason why your django-admin.py script 
would not see them, and I would be stumped.

--bart

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-admin.py startproject will NOT work.

2011-12-31 Thread Bart Nagel
At 2011-12-31 15:43:36 -0800, Chris Kavanagh wrote:
> Ok, I CAN start the Python Interpreter from the command line by just
> typing "python" then "enter".
> 
> I saved the file "args.py" in the Python Scripts folder. When I try to
> run it from command prompt, I get the message  "python: can't open
> file 'args.py': [Errno 2] No such file or directory".
> 
> The only way I CAN get it to open, is to change (cd into) into the
> python scripts folder (where I saved args.py) then run it (type
> "python args.py" in command prompt). So, obviously something is wrong.

No, that's not wrong, that's how it should be. The python interpreter 
is in your path, but you're telling the interpreter which file to run. 
If you tell it to run a file args.py and there is no such file in the 
current directory, it's correct to give you an error message.

Does this little script tell you correctly the number of arguments you 
pass to it?

--bart

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-admin.py startproject will NOT work.

2011-12-31 Thread Bart Nagel
At 2011-12-31 16:00:44 -0800, Chris Kavanagh wrote:
> On Dec 31, 6:48 pm, Bart Nagel  wrote:
> > Does this little script tell you correctly the number of arguments you
> > pass to it?
> 
> Yes, it tells me the number of args.

Okay, in that case the arguments should also be getting to the 
django-admin script. To give you the help message it must not be able 
to read the "startproject" argument, since the name of the project 
shouldn't matter to it. Perhaps something bad is happening to it, 
possibly due to the registry stuff you folks were talking about 
earlier, or some other Windows sorcery.

Change args.py a little to this:

import sys
print "%d arguments: %s" % (len(sys.argv), sys.argv)

And now run it with the arguments you were trying to give to 
django-admin:
python args.py startproject mysite

When I run that I get
3 arguments: ['args.py', 'startproject', 'mysite']

Paste your own output.

--bart

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-admin.py startproject will NOT work.

2011-12-31 Thread Bart Nagel
At 2011-12-31 18:47:13 -0800, Chris Kavanagh wrote:
> Forgive my ignorance, but if that's the way it's supposed to work
> (script must be in current dir) then how would Python know to run
> django-admin.py if I'm NOT in the same directory it is
> (Python27\Scripts\)??? In other words, the tutorial says to create a
> mysite dir somewhere, NOT in the Python27\Scripts dir. So how would it
> work then if  Python27\Scripts\ isn't my current working dir (ie:
> mysite isn't in the Scripts dir)??

Three options:

Either you run
python C:\path\to\django-admin.py startproject mysite
from whatever directory you want, to run an arbitrary Python script 
anywhere on your machine.

Or, with other scripts, from the directory where the Python script is, 
you can generally do
python some-script.py C:\path\to\some\target
depending how the script itself is set up -- the django-admin.py 
doesn't let you do this, it wants only to create a project in the 
current directory.

Or (what you're encouraged to do in this case) the django-admin.py 
script is set up somewhere in your lookup PATH. The lookup PATH is the 
list of directories in which commands live, and so when asked to run a 
particular command the shell looks in those directories and if it 
finds the command you wanted runs it, no matter where you are. To get 
the django-admin.py script in the PATH so you can run it from anywhere 
without a full path either you install the script to a directory which 
is already in your PATH (I think on Windows C:\windows\system32 is one 
such directory) or the Django directory containing the script is added 
to your PATH.

There might have been instructions to do that when you installed 
Django, or perhaps it was done as part of an installation script.

The fact that this path exists is the reason you can run commands like 
"python" itself from anywhere, if it's set up properly.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-admin.py startproject will NOT work.

2011-12-31 Thread Bart Nagel
At 2011-12-31 18:56:14 -0800, Chris Kavanagh wrote:
> Ok I've had a breakthrough (I guess,lol). I started a command prompt
> from my Python Scripts folder (C:\Python27\Scripts\), typed in "Python
> django-admin.py startproject mysite", and it worked!! I now have the
> "mysite" folder with appropriate subfolders (__init__.py,
> manage.py,settings.py,urls.py).

It still doesn't make sense that it wasn't working before. Did you try 
the modified args.py script I sent you?

> Is this working correctly?? Should I have to create Projects in the
> Python Scripts Folder?? Should it work from another (any misc dir)
> dir??

If Python itself and the django-admin.py script were being found 
properly (and they were when you were getting the help message), yes, 
you should be able to do that from any directory.

> And, can I leave it in the Scripts Folder or should I move it?? If I
> do move it, will that cause other problems??

You should probably move it. It should work anywhere, again, as long 
as it can find Python properly.

--bart

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-admin.py startproject will NOT work.

2012-01-01 Thread Bart Nagel
At 2012-01-01 01:12:27 -0800, Chris Kavanagh wrote:
> On Dec 31 2011, 7:13 pm, Bart Nagel  wrote:
> > When I run that I get
> >     3 arguments: ['args.py', 'startproject', 'mysite']
> >
> > Paste your own output.
> 
> I get the same as you:
> 
> C:\Python27\Scripts>python args.py startproject mysite
> 3 arguements: ['args.py', 'startproject', 'mysite']

What's with the spelling error?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-admin.py startproject will NOT work.

2012-01-01 Thread Bart Nagel
At 2012-01-01 14:23:50 -0800, Chris Kavanagh wrote:
> On Jan 1, 4:44 am, Bart Nagel  wrote:
> > At 2012-01-01 01:12:27 -0800, Chris Kavanagh wrote:
> >
> > > On Dec 31 2011, 7:13 pm, Bart Nagel  wrote:
> > > > When I run that I get
> > > > 3 arguments: ['args.py', 'startproject', 'mysite']
> >
> > > > Paste your own output.
> >
> > > I get the same as you:
> >
> > > C:\Python27\Scripts>python args.py startproject mysite
> > > 3 arguements: ['args.py', 'startproject', 'mysite']
> >
> > What's with the spelling error?
> 
> LOL, well apparently I don't know how to spell 'argument'.
> 
> However, I still got the same output as you (except for correct
> spelling).
> 
> What exactly were we (you) looking for in this test??

I explained that in a previous post. Afraid I can't help you any 
further, though I'm glad you eventually got it working.

--bart

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Custom storage question

2013-01-23 Thread Bart Grantham
Hello, I'm working on a project that has specific, but not terribly 
complex, file management needs and I think I may need to write a custom 
Storage backend.  But I'm not totally sure, so let me explain my problem 
before I ask any specific questions.

I am migrating a large set of files into this new Django project and I need 
to have these files private (ie. not in MEDIA_ROOT, and with url() not 
implemented).  The file metadata such as name, md5, the uploading user, 
file size, etc. need to be maintained in the database, presumably computed 
on the fly on saving the file.  The scheme used in the current system, 
which is so-so but I'm ok with perpetuating, is to have the files stored as 
(file_id % 100)/file_id, so that file_id==12345 would be stored in 
45/12345.  Disregarding the lack of merit in such a scheme, let's just take 
that as part of the exercise I'm trying to achieve here.

I have already implemented a mediocre solution with just building a file 
metadata model, having one of the attributes be a FileField, and overriding 
save() to manage the files properly, but that feels really clunky.

The documentation is pretty unhelpful in understanding when my custom 
Storage class really comes into play, if I should be subclassing File, how 
this all interacts with FileField, or if the solution lies elsewhere.  For 
example, the docs give the impression that by overriding Storage.path() you 
can mangle file names however you'd like, but that doesn't seem to have any 
effect on the FileField of my model.  It would help if there was a diagram 
or even several sentences that talked about how these classes fit together 
to produce Django's file management (ex. which class is authoritative for 
what information and what time in the file upload/save/retrieval process).

There's two other problems besides the mechanics of file system management. 
 One is that the model that contains the file is itself a member of another 
model, making form management more laborious than it could be (I think). 
 Second, I need to import a few thousand files via an import script and it 
doesn't seem quite right that I would just manually set the FileField's 
value (not a serious problem, it's just import, but it seems to indicate a 
deeper misstep).  Surely there's a simpler way of having database-backed 
file metadata than what I've hacked here.

I think what would be ideal is if I could subclass models.Model and 
files.File together, but that seems inadvisable.  Are there any simple 
examples of people doing the kind of thing I'm doing?  Or is there 
somewhere in the docs or mailing list that I missed that has the one or two 
sentences that I need to read that will clear it all up?  It doesn't seem 
complex, but it's turning out that way.

Bart

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/xmVUt1NBmfkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: send_mail error

2019-10-18 Thread Bart Jonkers
You need to set
https://www.dev2qa.com/how-do-i-enable-less-secure-apps-on-gmail/

Bart

Op vr 18 okt. 2019 om 17:33 schreef James Gutu :

> What error are you getting? Look at the traceback, or even copy paste it
> here.
> Ensure you have set the EMAIL_HOST_USER, EMAIL_HOST_PASSWORD,
> EMAIL_HOST_PORT correctly in the settings.py file.
>
> On Thu, Oct 17, 2019 at 3:27 PM challa.Harikrishna chowdary <
> challahari0...@gmail.com> wrote:
>
>> Hi
>>
>>   i am sending the mail from front end to gmail account please help he
>>
>>
>>
>>
>> thanks and  regards
>> ch.Hari
>>
>> --
>> 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/f7cf2f08-86f8-4d53-9c31-1066a4bf1476%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/f7cf2f08-86f8-4d53-9c31-1066a4bf1476%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
>
> --
> Regards,
> James Gutu
>
> --
> 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/CAOnWGOLN%3Dcugc59Z1AfNOfi4p7_nueHfoq_NAbFXCXefA3vRuw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAOnWGOLN%3Dcugc59Z1AfNOfi4p7_nueHfoq_NAbFXCXefA3vRuw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAN_VHze1%3DXp5uxa14zLkOvi6SJ3dy20MVrxWUVfQcmUEZQjjAw%40mail.gmail.com.


link multiple files to model

2019-12-29 Thread Bart Jonkers
Hi,

I have a question about one-to-many relations in models
What is best to use? ForeignKey of many to ManyToManyField?

I want to attach files to a model. 

The *ForeignKey* is easy to use. 
class Feed(models.Model):
user=models.ForeignKey(User, on_delete=models.CASCADE, 
related_name='feeds')
text=models.TextField(blank=False, max_length=500)

class FeedFile(models.Model):
file = models.FileField(upload_to="files/%Y/%m/%d")
feed = models.ForeignKey(Feed, on_delete=models.CASCADE, 
related_name='files')

But retrieving all objects (for a listview) with all files included the 
object is challenging. I
 tried subqueries, prefetch_related...
How can I do this?
AllFeeds = Feed.objects.all() 

the *manytomany-solution:*
class Feed(models.Model):
user=models.ForeignKey(User, on_delete=models.CASCADE, 
related_name='feeds')
text=models.TextField(blank=False, max_length=500)
files=models.ManyToManyField(FeedFile)

class FeedFile(models.Model):
file = models.FileField(upload_to="files/%Y/%m/%d")
Is not so intuitive for the user, but I can get the correct queryset.

Any advise on good practise?

Bart



-- 
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/e9ff73b1-bf2f-462a-98f3-da46793c54da%40googlegroups.com.


Re: link multiple files to model

2019-12-31 Thread Bart Jonkers
My quick solution:

I'm using django-sql-utils to get SubqueryAggregate.
I annotate 2 array's: one for the filelink and one for the filedescription.
In a custom template tag I merge the two arrays and render download buttons.

It would be great to annotate lists from an other model, but need more time 
to figure this out.

Bart



Op zondag 29 december 2019 22:26:35 UTC+1 schreef Bart Jonkers:
>
> Hi,
>
> I have a question about one-to-many relations in models
> What is best to use? ForeignKey of many to ManyToManyField?
>
> I want to attach files to a model. 
>
> The *ForeignKey* is easy to use. 
> class Feed(models.Model):
> user=models.ForeignKey(User, on_delete=models.CASCADE, 
> related_name='feeds')
> text=models.TextField(blank=False, max_length=500)
>
> class FeedFile(models.Model):
> file = models.FileField(upload_to="files/%Y/%m/%d")
> feed = models.ForeignKey(Feed, on_delete=models.CASCADE, 
> related_name='files')
>
> But retrieving all objects (for a listview) with all files included the 
> object is challenging. I
>  tried subqueries, prefetch_related...
> How can I do this?
> AllFeeds = Feed.objects.all() 
>
> the *manytomany-solution:*
> class Feed(models.Model):
> user=models.ForeignKey(User, on_delete=models.CASCADE, 
> related_name='feeds')
> text=models.TextField(blank=False, max_length=500)
> files=models.ManyToManyField(FeedFile)
>
> class FeedFile(models.Model):
> file = models.FileField(upload_to="files/%Y/%m/%d")
> Is not so intuitive for the user, but I can get the correct queryset.
>
> Any advise on good practise?
>
> Bart
>
>
>
>

-- 
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/b68b340c-f96b-4d40-ba35-c6e191c278ab%40googlegroups.com.


Form/widget Media urls not using the hashed names from ManifestStaticStorage?

2015-11-18 Thread Bart van der Schoor
I'm trying to upgrade an existing application to use a Manifest based 
StaticStorage so we can leverage long-term caching.

It works as expected for files included with the `static from staticfiles` 
template tag: my app shows the hashed names for the standard admin 
javascript/css files and they all resolve correctly.

But for (admin) widgets that add extra media files using the Media class 
<https://docs.djangoproject.com/en/1.8/topics/forms/media/> I still get the 
plain (non-hash) filenames in my HTML.

I tried this with both the bundled ManifestStaticStorage as well as 
ManifestStaticS3Storage from django-s3-storage. 
<https://github.com/etianen/django-s3-storage>

Curiously the URLs are formed differently: for example: the ones from the 
template tags have different URLS then the ones from Media classes:

https://s3-eu-west-1.amazonaws.com:443/my-project/static/admin/js/actions.min.2893760b9e40.js"</a>;>
https://s3-eu-west-1.amazonaws.com/my-project/static/js/my_custom_scipt.js"</a>;>

The second one corresponds with what I have set as STATIC_URL, while to 
first one seems to be generated by the S3 storage (it has an explicit port 
number). I see these non-transformed URLs for all media attached by myself 
or third-party widgets.


Next I looked into the source on Github, and this confirms my fear that 
form-media urls are simply joined to the STATIC_URL instead of passed 
through the staticfiles manifest mechanism.

For example: 
https://github.com/django/django/blob/f59a0401e5d0e19568a038f2a50954d1a9a1526f/django/forms/widgets.py#L80-L85


Doesn't this kinda defeats the purpose of using the staticfiles app and 
Manifest Storage if a fair part of our static files are not processed by 
it? Or do I miss some override or setting?

All this was using Django 1.8.6 with Python 3.4 on Ubuntu.


Any ideas what is intended here?


Bart

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a25d23df-5012-4054-b991-68114713a5f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.