Re: Questions on Django queryset iterator - wrt select_related and prefetch_related and how it works

2017-03-16 Thread Shawn Milochik
I think the benefit of using the iterator is best explained by an example: Without iterator: You loop through the queryset, using each item for whatever you're doing. As you do this, all the items are now in your local scope, using up RAM. If, after the loop, you should want to loop through the

Re: Will asgi become a PEP like wsgi is ?

2017-03-13 Thread Shawn Milochik
You don't have to subscribe. Just read it online. https://groups.google.com/forum/m/#!forum/django-developers -- 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

Re: Uplaod execl file to populate django database

2017-03-13 Thread Shawn Milochik
1. Write code that puts data into your models. Do the Django tutorial if you don't know how. 2. Write code that reads data out of your​ Excel file using the appropriate library, easily found on pypi. 3. Use them together. -- You received this message because you are subscribed to the Google

Re: Help: Data model in django

2017-03-09 Thread Shawn Milochik
Are you using PostgreSQL? Maybe you can use JSONField. https://docs.djangoproject.com/en/1.10/ref/contrib/postgres/fields/#jsonfield -- 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

Re: Advice: count hits/pageview for high traffic website

2017-03-07 Thread Shawn Milochik
On Tue, Mar 7, 2017 at 6:38 PM, carlos wrote: > Hi, > i try used django-hitcount but really not for website high traffic > any advice for count visits/hits page for 60k or 100k traffic for day > > thank any idea, link or whatever helps > > My vote would be for something

Re: Django: how to send email when the publish date is reached for a blog item

2017-03-07 Thread Shawn Milochik
There are multiple ways to do it. For example: Write a Django management command and call it from cron. Use a scheduled Celery task. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving

Re: new to Django

2017-03-06 Thread Shawn Milochik
Go here: https://code.djangoproject.com/ You'll find instructions on how to contribute, and also the bug tracker, where you can search for easy bugs to fix. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and

Re: stop backgroundworker

2017-03-06 Thread Shawn Milochik
You'll have to send something from the browser (submit a form, AXAX, or websockets) to a Django view and update something somewhere -- in Redis or your database, probably. Then have your infinite loop check that location for an updated value. I recommend Redis for this purpose. -- You received

Re: How to keep track of online users?

2017-03-02 Thread Shawn Milochik
You actually can't, unless you're using JavaScript for something like websockets or other polling. You can only track their last activity using their session. Specifically, if a user loads one of your pages, you know it. But then you won't know whether they're still reading it hours later or they

Re: Djnago User login

2017-03-01 Thread Shawn Milochik
It takes a little fiddling, but you can log in a user however you want. https://docs.djangoproject.com/en/1.10/topics/auth/default/#how-to-log-a-user-in In short, you can call django.contrib.auth.login(request, user) and force a login without any authentication if you really wanted to. Given

Re: Issues saving hex format data to binaryfield

2017-02-22 Thread Shawn Milochik
Why not base64 encode it and just store it in a charfield? There doesn't seem to be any compelling reason to store it in binary. -- 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,

Re: Implementing a basic search for my website

2017-02-20 Thread Shawn Milochik
If you want a pre-rolled solution, just use Django-haystack. It'll do exactly what you want. If you want to create your own to avoid the dependency on additional libraries and backend (you'll need something like Elasticsearch), that's easy also. Let me know if you do. I have some sample code

Re: How to integrate a python algorithm in a Django website

2017-02-15 Thread Shawn Milochik
It's not clear what aspect of this you are looking for help with. Can you be more specific? Have you written any code? If so, what is not working the way you expect it to? If you want to schedule something to run regularly, you can use Celery or make a Django management command that gets run by

Re: OpenFace Integration with Django

2017-02-15 Thread Shawn Milochik
It's probably some difference between environments. If you know your code works (it runs locally) and you're running the same versions of all your dependencies (Python, Django, Openface, etc.), then it doesn't *seem* too likely to be a major bug. It *could* be a bug -- not checking for and

Re: Check if all boolean values are the same (database)

2017-02-14 Thread Shawn Milochik
I'd go with form validation -- you shouldn't allow a Purchase to be added to a transaction if a Purchase with a conflicting status is already in there, nor should a Purchase be able to be modified if it's in a transaction with another Purchase. Then you never have to check whether a transaction

Re: Formset questions: data vs. initial values

2015-10-07 Thread Shawn Milochik
You *can* use ModelForms for this. You don't need an active instance. Iterate over the days in the month, and if you have an instance in your database you instantiate a ModelForm where "instance=thing." If not, you instantiate a ModelForm that has no instance, and you send as data "" (empty

Re: Load a static file with a variable name

2015-10-06 Thread Shawn Milochik
Try this: You're embedding {{pet_name}} in a string. If this was a regular Python statement, it would be like writing "Hello, {0}" and not having a format() at the end. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from

Re: http://pastebin.com/RWt1mp7F

2015-09-27 Thread Shawn Milochik
Try running ./manage.py shell You often get a better traceback. I don't see anything wrong with the beginning of the file you posted. However, you do have dirname twice, so one is just wasted. On Sep 27, 2015 13:50, "Cai Gengyang" wrote: > http://pastebin.com/RWt1mp7F ---

Re: Django deployment

2015-09-15 Thread Shawn Milochik
It's very simple. Just follow these instructions: http://milocast.com/flasknginx.html Instead of the final line (gunicorn filename:appname -b 127.0.0.1:), use this: ./manage.py run_gunicorn -b 127.0.0.1: -- You received this message because you are subscribed to the Google Groups

Re: Receive post_save signal from another project

2015-09-03 Thread Shawn Milochik
Yes, it works. Just try it. If you put a post_save handler in any app it is called when any model is saved in any 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

Re: Moderator and publishing workflow implementation in Django

2015-08-28 Thread Shawn Milochik
One easy solution: Add an "approved_by" field, which is a ForeignKey to User. Let it be null by default. When it's approved, save the User who approved it. Then, whenever you're doing an ORM query to grab all stories to display, just filter on approved_by being not_null. Alternatively, you can

Re: Django Many-to-many Query: Publications with no Articles? Publications with some Articles?

2015-08-24 Thread Shawn Milochik
I couldn't find it in Django's documentation; just from StackOverflow and another source (both found via Google). I always used to do something like Thing.objects.filter(other__id__isnull=True) to do that, but clearly this is better. -- You received this message because you are subscribed to

Re: Django CMS or Wiki?

2015-08-24 Thread Shawn Milochik
On Mon, Aug 24, 2015 at 2:49 AM, guettli wrote: > > Has someone an advice which django application could be used? > > Regards, > Thomas Güttler > > Why does it have to be a Django application? Static site generators such as Hugo and Pelican are very popular, especially for

Re: Django Many-to-many Query: Publications with no Articles? Publications with some Articles?

2015-08-21 Thread Shawn Milochik
No articles: Publication.objects.filter(article_set=None) Has articles: Publication.objects.exclude(article_set=None) -- 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

Re: Security News?

2015-08-18 Thread Shawn Milochik
I've been using this source for over 10 years: https://www.grc.com/securitynow.htm Main page: https://twit.tv/shows/security-now -- 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,

reload_module no longer works when using caches["default"] instead of cache

2015-08-10 Thread Shawn Milochik
TL;DR; How do you modify cache settings during testing? Specifically, enable/disable (by making TIMEOUT zero or non-zero). Full question: I had some code that looked like this: from django.core.cache import cache data = cache.get(key, {}) etc. Now it looks like this: from django.core.cache

Re: problem in setting up gunicorn and django

2014-03-17 Thread Shawn Milochik
It's much easier to just add gunicorn to your installed apps, and then do "./manage.py run_gunicorn" instead of "./manage.py runserver." It's pretty much takes the same options, except you'll want to add "-b" before your IP and port, like " -b 127.0.0.1:8000." -- You received this message

Re: Is there a good reason why Django querysets can't be intersected?

2014-03-16 Thread Shawn Milochik
I don't know anything about efficiency, but it works at least as far back as Django 1.3. I'd assume that, with lazy evaluation, it's probably about as efficient as anything in the ORM. -- You received this message because you are subscribed to the Google Groups "Django users" group. To

Re: Is there a good reason why Django querysets can't be intersected?

2014-03-16 Thread Shawn Milochik
It seems to work for me: a = Client.objects.filter(name__istartswith='a') b = Client.objects.filter(name__iendswith='t') print a.count() print b.count() c = a & b print

Re: [newbie] -- Regex-matching ("Tango with Django")

2014-03-14 Thread Shawn Milochik
You're meant to only have one include that redirects URLs beginning with rango to the app's urls.py. Then, the app's urls.py must not have /rango in the URLs. The idea is that all URLs starting with "rango" get the "rango" stripped off and passed to the rango app, which itself has / and /about.

Re: do I need to run syncdb when I change the default value in a field of a model?

2014-03-14 Thread Shawn Milochik
On Fri, Mar 14, 2014 at 7:19 PM, Jonathan Baker < jonathandavidba...@gmail.com> wrote: > Does that mean that the default="" functionality is implemented by the > ORM, instead of in the database layer? > > Perhaps I'm wrong -- I'm looking at my South migrations and they do pass the defaults. I

Re: do I need to run syncdb when I change the default value in a field of a model?

2014-03-14 Thread Shawn Milochik
No, no syncdb required. The default applies to newly-created instances, not existing ones. -- 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

Re: Can please someone explain this code from the docs?

2014-03-14 Thread Shawn Milochik
That's just the syntax for calling a method on the base class. 1. MultiEmailField is a subclass of forms.Field. 2. forms.Field has a method named validate. 3. MultiEmailField also has a method named validate, so it overrides the one on forms.Field. So, for MultiEmailField to call its parent's

Re: ForeignKey Field does not exist?

2014-03-13 Thread Shawn Milochik
On Thu, Mar 13, 2014 at 7:27 PM, wasingej wrote: > > When I go to grab information about the list with 'l = > OwnerEntry(name='wasingej')', intuition would tell me that 'l' would be a > list of entries with the name 'wasingej'. However, when I try to access > the

Re: Self referencing models initialization

2014-03-13 Thread Shawn Milochik
On Thu, Mar 13, 2014 at 1:07 PM, Santiago Palacio Gómez wrote: > Ok, just did that and it worked (had to delete and re-create the db). > Thank you very much for your quick reply. > > One last question though, just for curiosity, is there no way to create > such cyclic

Re: Different URLCONF for different domains

2014-03-12 Thread Shawn Milochik
URLs will be processed in the order they appear in your urls.py file. If one of your first entries in urls.py is an "include" that handles all URLs that start with "/a/", then all those requests will be handled by the URL patterns in the included URLs.py. Then, all URLs that don't get "caught"

Re: A subprocess call fails, but only under Django

2014-03-11 Thread Shawn Milochik
On Tue, Mar 11, 2014 at 8:07 PM, Shawn Milochik <shawn.m...@gmail.com>wrote: > > I tried to circumvent the entire problem by adding an "if __name__ == > '__main__'" block to the script and having it take a command-line argument > via argparse and print th

Re: A subprocess call fails, but only under Django

2014-03-11 Thread Shawn Milochik
Hi Russ, thanks for the reply. What I mean by "under Django" is if I call it from within a view or with "manage.py shell" I get the problem. On the system in question, "manage.py shell" does in fact invoke iPython. However, invoking iPython manually (without manage.py) works. Executing the script

Re: A subprocess call fails, but only under Django

2014-03-11 Thread Shawn Milochik
On Tue, Mar 11, 2014 at 9:24 PM, Nick Santos wrote: > Hey Shawn, > > What does your web stack and environment look like? If it's failing during > a fork with an out of memory, that makes me wonder if the host process for > django is consuming a chunk of memory for some

Re: A subprocess call fails, but only under Django

2014-03-11 Thread Shawn Milochik
On Tue, Mar 11, 2014 at 9:06 PM, Drew Ferguson wrote: > Hi > > Could your problem be some SELINUX issue? > > Perhaps disable SELINUX temporarily and see if the problem persists. > > How would selinux cause the problem to only happen under certain conditions? I don't

A subprocess call fails, but only under Django

2014-03-11 Thread Shawn Milochik
Hi everybody. I have a weird problem. I have a small script that does a subprocess call. It works. It works when run via iPython. It blows up when run in manage.py shell or under Django with OSError: [Errno 12] Cannot allocate memory. Does anyone have any idea on how to fix this? It's not

Re: Atomic test/set/get using django cache API?

2013-05-14 Thread Shawn Milochik
I love and recommend Redis. If you can use a Redis key instead of Django's cache, you can call get() on the key. If the result is not None, now you have it. If it is None, you know it didn't exist, so you can set it. I don't think it's possible to have it work the way you want with the default

Re: help regarding celery implementation with django

2013-05-14 Thread Shawn Milochik
I think your question boils down to "How do I use Redis from Python." The answer is 'pip install redis' and play with it. Figure out which commands you'll need by looking at them in the Redis docs. The docs are good. http://redis.io/commands At the top of the page you can filter by type. I'd

Re: Redirect specific username upon login to email change page

2013-05-13 Thread Shawn Milochik
Use a combination of the redirect() shortcut and request.user. https://docs.djangoproject.com/en/1.5/topics/http/shortcuts/#redirect -- 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

Re: Django with 2 subapps with same name

2013-05-10 Thread Shawn Milochik
It is not possible. https://groups.google.com/forum/#!msg/django-users/AMYLfQo6Ba4/Y-57B0i7qy4J -- 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

Re: middleware

2013-05-09 Thread Shawn Milochik
In your middleware you'll have access to the request object, so you can easily check the URL, user, etc. -- 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

Re: Some basic questions from somebody learning Django/Python

2013-05-07 Thread Shawn Milochik
Coincidentally, Russell just gave the answer to that question less than an hour ago, so I'll just refer you to his reply: https://groups.google.com/d/msg/django-users/AMYLfQo6Ba4/Y-57B0i7qy4J -- You received this message because you are subscribed to the Google Groups "Django users" group. To

Re: Accessing django development server using internet

2013-05-07 Thread Shawn Milochik
pip install gunicorn, then run python manage.py run_gunicorn instead of runserver. Ensure that the port you're running your app on is being handled properly by your Web server app (nginx or Apache). This means that hits to your URL hit the Web server and are being directed internally at your

Re: Django html input error

2013-05-06 Thread Shawn Milochik
No, it's a bad solution because it only fixes *some* unicode errors, and only on your single machine. See this. In my opinion it's the easiest Python unicode explanation to understand: http://farmdev.com/talks/unicode/ -- You received this message because you are subscribed to the Google Groups

Re: Noobie questions about Django and Databases

2013-05-06 Thread Shawn Milochik
In that case, you'd just add a 'model number' field to your table. In the Django ORM, each Model instance relates to a table. So you aren't going to want to have more than one to write your code against. Just read through these two pages and everything should make sense:

Re: Postgres/psycopg2 setup error

2013-05-06 Thread Shawn Milochik
I see you posted the question on StackOverflow as well. A quick search turned up the same problem there, with a solution that allegedly works: http://stackoverflow.com/questions/14863723/psycopg2-import-error-due-to-failure-to-load-libraries -- You received this message because you are

Re: Some basic questions from somebody learning Django/Python

2013-05-06 Thread Shawn Milochik
Hi Christopher. In general, you don't install a Django app -- you just run it with ./manage.py runserver. If it's a "pluggable app" it should have an installer. If it needs to be installed and the author hasn't provided an easy way for you to do it, it's probably better to learn from code written

Re: a simple form confirmation before commit instance to database

2013-05-06 Thread Shawn Milochik
That feels like the wrong place to do it. The simplest thing would be to just pop up a JavaScript dialog that intercepts the form POST, and ask then. This does exactly what you want with the exception that it'll ask them whether or not the form is valid, but I think that's irrelevant. If you do

Re: Django - Query

2013-05-05 Thread Shawn Milochik
On Sun, May 5, 2013 at 3:29 PM, Hélio Miranda wrote: > How do I get the two? > > -- > > Use .filter() instead of .get(). -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving

Re: Admin module - modify SQL Query used for Edit and Save Models

2013-05-03 Thread Shawn Milochik
On Fri, May 3, 2013 at 10:22 AM, Marc wrote: Thanks. I understood and that doesn't work for my project as python/django > can't handle the returned bytes I need to use. > my project requires that the values are stored using the result of > aes_encrypt from MySQL because other

Re: Admin module - modify SQL Query used for Edit and Save Models

2013-05-03 Thread Shawn Milochik
On Fri, May 3, 2013 at 8:37 AM, Marc wrote: So Tom: i can't use those methods Shawn pointed out? What I was hoping I > can do is override the code that builds the SQL query. > Further looking I think thats correct; as I did get a module working I > found and played with which

Re: Admin module - modify SQL Query used for Edit and Save Models

2013-05-03 Thread Shawn Milochik
On Fri, May 3, 2013 at 8:06 AM, Marc wrote: Thanks, i'll play with that and see what I can come up with. > Docs are good, but sometimes really hard to read/find what you need :) > > > > Oh come on, you mean "get_prep_value" and "to_python" weren't obvious? ;o) -- You received

Re: Admin module - modify SQL Query used for Edit and Save Models

2013-05-03 Thread Shawn Milochik
https://docs.djangoproject.com/en/1.5/howto/custom-model-fields/#converting-database-values-to-python-objects https://docs.djangoproject.com/en/1.5/howto/custom-model-fields/#converting-python-objects-to-query-values Have a look at these two methods of a custom field. You can pretty easily make

Re: Akiban + Django

2013-05-02 Thread Shawn Milochik
The short answer is that if you can use it in Python, you can use it in Django. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: Need explanation of the flow of info between my javascript, my View, and my template, trying to diagnose my current roadblock.

2013-04-30 Thread Shawn Milochik
You're welcome. You may be new to it, but you ask better questions than most I see. When I see "How do I do X?" I usually ignore it. When I see "Here's what I did. It's not working for some reason" then I try to help if I can. Keep up the good work. Shawn -- You received this message because

Re: Need explanation of the flow of info between my javascript, my View, and my template, trying to diagnose my current roadblock.

2013-04-30 Thread Shawn Milochik
If I understand your question and your code properly, the problem is that you are expecting a redirect, but what's happening is that the raw HTML from the view is being returned to your JavaScript function, which does nothing with it. It seems like what you should do is just do a normal HTML form

Re: Little help needed writing models for star-ratings app

2013-04-29 Thread Shawn Milochik
I reiterate: Please read the ORM documentation. That will answer all of your questions. Once you understand how to do queries in the ORM (and which queries are easier than others) then you will know how to design your models so that they'll be easy to work with. As you're reading, make notes about

Re: Newbie: trying to get an existing project running on a different machine

2013-04-29 Thread Shawn Milochik
Do you have piston installed in the virtualenv where you're trying to test this? Check for any "local settings" on the production server that it may be using but which aren't available through the repository. -- You received this message because you are subscribed to the Google Groups "Django

Re: Little help needed writing models for star-ratings app

2013-04-29 Thread Shawn Milochik
It looks like you're not looking for a "little help." You're looking for someone to do the work for you. You'll get the best help if you try something, get stuck, and explain what you tried and what the error is. Here is the documentation for using the ORM. This is not a snarky response -- I

Re: quick problem with str and int

2013-04-29 Thread Shawn Milochik
How about adding a get_absolute_url method to your model? Then you can take care of the logic there, instead of the template. https://docs.djangoproject.com/en/1.5/ref/models/instances/#get-absolute-url Worst-case, you can just do the conversion in your view and assign it as a new property to

Re: Store arbitrary key-value pairs in model?

2013-04-29 Thread Shawn Milochik
A Django app sometimes benefits from a "No-SQL" database on the side. You could do what you want using a text field and storing JSON or a pickled value, but I advise against it. It's hard to query and de-duplicate. -- You received this message because you are subscribed to the Google Groups

Re: django-filetransfers and HttpResponseRedirect

2013-04-29 Thread Shawn Milochik
Use HttpResponseRedirect, as you mention in your subject line. -- 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

Re: Blog writen by django?

2013-04-27 Thread Shawn Milochik
Do a Google search. There are thousands. -- 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

Re: Django admin error : coercing to Unicode: need string or buffer, NoneType found

2013-04-24 Thread Shawn Milochik
Ah, I missed that point. You could temporarily create an __init__ override in your model and put the code there. -- 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

Re: Django admin error : coercing to Unicode: need string or buffer, NoneType found

2013-04-24 Thread Shawn Milochik
w wich field and how to find out > > > 2013/4/24 Shawn Milochik <sh...@milochik.com> > >> Try iterating through your output in the view and look at field, >> field.content, and if field.help_text. Somewhere you have a null value >> which is None in Python. >&g

Re: Django admin error : coercing to Unicode: need string or buffer, NoneType found

2013-04-24 Thread Shawn Milochik
Try iterating through your output in the view and look at field, field.content, and if field.help_text. Somewhere you have a null value which is None in Python. Since the traceback you posted (if it's complete) is all from Django's code and not yours, then the error must be in your data. -- You

Re: Upload csv file

2013-04-24 Thread Shawn Milochik
http://docs.python.org/2/library/csv.html#csv.DictReader -- 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

Re: Upload csv file

2013-04-23 Thread Shawn Milochik
MongoDB documents are practically indistinguishable from Python dictionaries. You can use the csv module (csv.DictReader) to read in the CSV file and the pymongo library to write those dicts to Mongo. This really has nothing at all to do with Django. -- You received this message because you

Re: I have searched and searched for a CSV Importer that does the following.

2013-04-23 Thread Shawn Milochik
On Tue, Apr 23, 2013 at 10:37 AM, Derek wrote: > > Yes, this is what I did; it is a significant amount of work to create such > a facility and I would have been glad if someone had done this already! > > Of course, linking fields to column headers is the very simple part of

Re: logging within celery processes

2013-04-20 Thread Shawn Milochik
I don't know the solution, but we had the same problem. We ended up dumping Celery in favor of rq. It's much easier to work with and we were already using Redis as a back-end. If you do figure out the solution to this, please post it here. Also, consider rq. We used Celery quite a bit and the

Re: Is it possible to create website like Squarespace or Wix in django?

2013-04-20 Thread Shawn Milochik
I don't think there's any kind of site you *can't* make with Django. It's a Web framework, not a CMS. It's definitely possible (and trivial) to offer a wide variety of templates. It's also possible to allow a user to customize and save a template, but that comes with a whole host of security

Re: How many workers do you run on one machine using django celery?

2013-04-20 Thread Shawn Milochik
In addition to Michael's good comments: I suspect you won't have 100,000 tasks coming in every second of every day. If you have to send out SMS messages and some of them take a few minutes to go out, that should be fine for most purposes. In addition, some SMS services have some limit per

Re: django-newsletter, cron job not working

2013-04-18 Thread Shawn Milochik
Here's an example of something taken straight from my crontab from a WebFaction account: 44 * * * * cd ~/webapps/awstats_milocast;./update_awstats.sh This runs on minute 44 of every hour. There are five "time" parameters. The first one is "minute." If you set a number there, it'll run on that

Re: Help interpreting profiler results (or: why is my app so slow?)

2013-04-18 Thread Shawn Milochik
Hit send too soon: https://docs.djangoproject.com/en/dev/topics/cache/#template-fragment-caching On Thu, Apr 18, 2013 at 8:39 AM, Shawn Milochik <sh...@milochik.com> wrote: > Yes, it does look like template tags are taking some time. Is the page > huge? Are you doing a ton o

Re: Help interpreting profiler results (or: why is my app so slow?)

2013-04-18 Thread Shawn Milochik
Yes, it does look like template tags are taking some time. Is the page huge? Are you doing a ton of formatting? Is there something you could maybe move to server-side? Also, this might help with caching bits of your output: On Thu, Apr 18, 2013 at 6:17 AM, Matt Andrews

Re: What is Model Manager?

2013-04-17 Thread Shawn Milochik
https://docs.djangoproject.com/en/1.5/topics/db/managers/ This should explain everything. On Wed, Apr 17, 2013 at 8:10 PM, cha wrote: > Hello how are you > I want to explain to me what is **"*Model Managers*"** in django ??? and > What are the useful ? > > -- > You

Re: Help interpreting profiler results (or: why is my app so slow?)

2013-04-17 Thread Shawn Milochik
When you print those out with pstats, sort by cumtime. cumtime = cumulative time That will tell you almost exactly (and maybe really exactly) which code is slow. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group

Re: django-newsletter, cron job not working

2013-04-17 Thread Shawn Milochik
It's almost certainly an environment issue, such as an issue with your PATH or PYTHONPATH. Just add to the command so that it puts all standard output and standard error to a file to read what the message is. your_command &> /tmp/broken_cron.log Then rig your cron job to run ASAP and read the

Re: VirtualEnv After the Fact

2013-04-13 Thread Shawn Milochik
You don't have to do anything differently than if you were starting out fresh. A virtualenv is a self-contained thing. Here's a recent blog post I wrote that might help: http://milocast.com/virtualenv.html You don't need to uninstall anything at all. However, you will need to install them again,

Re: New to testing

2013-04-10 Thread Shawn Milochik
Create a function with a name that *doesn't* start with "test" and you can easily do what you want. Then both tests can call it. -- 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,

Re: Deploying: Desktop to server

2013-04-08 Thread Shawn Milochik
It should be fine, unless you're using encrypted fields, using the SECRET_KEY setting as the key, and have a different key in production. Of course, if you want to keep the databases in sync after that, that's another issue. On Apr 8, 2013 5:09 PM, "Tim Johnson" wrote: > FYI

Re: djano user registration form and login(full example)

2013-04-06 Thread Shawn Milochik
I've seen some situations where it looked like signals are received multiple times. However, you can easily fix that by checking for the existence of the user in your function, or a try/except that handles the integrity error. Also, if you're starting a new project, consider upgrading to Django

Re: djano user registration form and login(full example)

2013-04-01 Thread Shawn Milochik
Don't even worry about factories. They're for when you want a bunch of forms for the same model on the page at once. Use the UserCreationForm in django.contrib.auth.forms. It only accepts a username and password, so you can either subclass it to add the fields or make your own form and add it to

Re: FileField delete and update handling

2013-03-30 Thread Shawn Milochik
You could remember the old path by saving it as a variable in your model's __init__ function. Something like this: self._old_file_path = self.file_path Then in your save(): #only if there was a non-blank path to begin with, and it changed if self._old_file_path and (

Re: Doubt regarding JSON/SQL in Django

2013-03-30 Thread Shawn Milochik
On Sat, Mar 30, 2013 at 9:42 AM, Alexis Roda wrote: > Yes, just import json and work with it, but be aware that you'll loose most > of the functionality that makes django so productive: no ModelForms, no > ORM/Querysets, no admin for tasks, ... > That's true.

Re: Doubt regarding JSON/SQL in Django

2013-03-30 Thread Shawn Milochik
Django is just Python, so yes. Just use the json module in the standard library. On Mar 30, 2013 9:23 AM, "Parin Porecha" wrote: > Hi, > > I have just started using Django. I want to create a to-do task > manager application. Users would register, login and can work with

Re: Is there a plan for Django to handle NoSQL databases natively?

2013-03-27 Thread Shawn Milochik
Another point is one made by Alex Gaynor at PyCon 2012. Too often, people ask "How do I do X in Django," when they should be asking "How do I do X in Python," or "Does Django have something for X." The first question is too limiting. Remember that Django is just some Python code. The second

Re: Avoiding Sessions

2013-03-27 Thread Shawn Milochik
Some clients may not allow cookies, which would be a problem if that's your full session strategy. If you're storing nothing but the default information in the cookie then there shouldn't be any risk, and in any case the cookie is encrypted with the SECRET_KEY from your settings. If you store

Re: Navigation Bar

2013-03-27 Thread Shawn Milochik
If you put these links in your base template it will appear on every page. If you wrap some of those links with template if/endif syntax and check request.user to see if they have permission, you can hide individual links, change their CSS classes, or replace them with a something else. -- You

Re: Avoiding Sessions

2013-03-27 Thread Shawn Milochik
Use django-redis-sessions as a back end instead of the database. On Mar 27, 2013 9:35 AM, "Venkatraman S" wrote: > So, if i am right, usage of sessions makes an extra call to the DB for > every view with login_required. > > SELECT "auth_user"."id", "auth_user"."password",

Re: [django-users] Limit uploaded image properties

2013-03-25 Thread Shawn Milochik
It's easy to do it by file size in your server config. For example, in nginx or Apache. You shouldn't have to set it in Django, and I don't believe Django provides any ability to cap it. https://docs.djangoproject.com/en/dev/topics/http/file-uploads/ -- You received this message because you are

Re: What are the steps to build a website?

2013-03-25 Thread Shawn Milochik
On Mon, Mar 25, 2013 at 3:16 PM, Benjamin Marsili wrote: > I am afraid to make mistakes ;). Since there is only one correct way to do > things in Python, I don't want to hack my way around and waste my time after > a few weeks. When there's only "one correct

Re: Python path in new 1.4 project structure?

2013-03-25 Thread Shawn Milochik
On Mon, Mar 25, 2013 at 12:56 PM, Carsten Fuchs wrote: >> !!! PONTIFICATION ALERT !!! >> Don't do that. > > Uhh, about the first word, I didn't find it in any dictionary. > Is this somehow related to pope Franziskus? ;-) > >From

Re: What are the steps to build a website?

2013-03-25 Thread Shawn Milochik
On Mon, Mar 25, 2013 at 8:03 AM, Frankline wrote: > My advice: Stop making resolutions and just start something. You will be > happier if you do. Along the way, you'll have gained an understanding of > your project to so much more. That is how I learned. > > Do not be afraid

Re: first steps with django

2013-03-24 Thread Shawn Milochik
On Sun, Mar 24, 2013 at 11:21 AM, Jeffrey Black wrote: > Give this a look first. > > http://www.jeffknupp.com/blog/2012/10/24/starting-a-django-14-project-the-right-way/ > > jb That's a good post. I give a hearty +1 to virtualenv, South, Fabric, and git. -- You

  1   2   3   4   5   6   7   8   9   10   >