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
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
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
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
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
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
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
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
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
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
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,
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
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
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
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
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
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
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 ---
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
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
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
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
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
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
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,
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
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
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
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
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.
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
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
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
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
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
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"
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
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
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
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
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
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
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
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
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
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
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
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
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
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:
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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,
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,
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
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
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
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 (
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.
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
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
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
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
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",
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
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
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
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
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 - 100 of 1237 matches
Mail list logo