Design question: Is it really a good idea for models having “side effects”?

2015-02-20 Thread Gergely Polonkai
Hello,

I’m currently implementing a finite state machine in my application using 
Django FSM[1]. In the Usage section of the README the author said that 
“This function may contain side-effects, like updating caches, notifying 
users, etc.”

Opposing this statement, the Symfony PHP framework’s authors say that 
models should never have such side effects.

Thus, I was wondering what is the case with Django in this topic. Should I 
really do such things, like notifying users, in the model’s code?

Best,
Gergely


[1] https://github.com/kmmbvnr/django-fsm

-- 
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/69272d49-de97-40a0-9682-430f28f38663%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django and pydoc - ImproperlyConfigured

2015-02-24 Thread Gergely Polonkai
Hello,

I'm trying to document my own webpage's code so I will remember each piece
if I have to touch it later. I added docstrings to several functions
already, and while this is generally enough, I couldn't help but tried
pydoc blog.models.Post

What I got instead of the craved documents was an ImuroperlyConfigured
exception. I found some clues that defining a settings module via the
DJANGO_SETTINGS_MODULE  environment variable would help (and it does), but
it just doesn't sound right to me. Isn't there an easier solution? (Note
that I don't count putting this env variable to the virtualenv's activate
scripts as an easier method :)

Best,
Gergely

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


Re: Migrations force me to have, forever, any name/reference I use in field validators=, choices=, whatever, valid forever (even if the requirements change).

2015-02-27 Thread Gergely Polonkai
Hello,

another solution may be to patch your models in the migration module or
class, like:

import myapp.models

myapp.models.valid_identifier = something_acceptable()

Although it seems a bit ugly, I just tested it, and it works. This way
valid_identifier will live during the migration only.

Best,
Gergely
On 27 Feb 2015 21:17, "Luis Masuelli"  wrote:

> Thanks :D Did not think about squashing migrations as solution for this
> problem! But it does the job.
> OTOH the fact about historical models has nothing to do with my problem
> (since it is not related at all with instancing a model, but just about the
> definition and not getting a NameError).
>
> --
> 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/15bb8a96-18a5-432c-afeb-7a3299ca7a4d%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUJz9A%2ByKxTkP-prtfXihoSudM6V0HLD_mXUZTu2yQqjkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to get/assign the contents of the app code directory into my Django project

2015-03-10 Thread Gergely Polonkai
Hello,

this pretty much depends on your environment. I, personally, use virtualenv
and pip, so most likely will install such an external app like this:

pip install git://my.favourite.provider/awesome/app.git

If you use your system python, with a system-wide installed django, then
you may either want to install this new app into a system-wide python
directory, or simply inject it into your application's structure (which, in
turn, may mess up your version control system, if you use any; and you
should).

Best,
Gergely
On 10 Mar 2015 22:47, "jaisol"  wrote:

> Hi,
>
> Sorry to ask such a silly question I just cloned a Django app via git
> and I want to get the contents of the app code directory into my Django
> project.
>
> The Readme.md says the following but I don't get it :-(
>
> Folder Structure
>
> You will need to get the contents of the src/idea directory into your
> Django project. The simplest way to do this might be a symbolic link.
>
> mydjango_project/
>   |- idea/  (includes models.py, views.py, etc.)
>   |- mydjango_project/ (settings.py, url.py, etc.)
>   |- manage.py
>   |- etc etc etc
>
> Any advice or guidance would be greatly appreciated !!
>
> Thanks!
>
> --
> 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/b5f3a14a-a487-4459-843f-ca7d560beff9%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBU%2B5SRKRncZmQfh7gapjXeQOVwc_-kjt8ro_ZAzOcxiD7w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to get/assign the contents of the app code directory into my Django project

2015-03-10 Thread Gergely Polonkai
Hello,

as you didn't say which module you downloaded from GitHub, I cannot give
you exact information. Most Python modules have a ”setup” system, which
will copy all installable components to their place. If you can't (or don't
want to) install a module, you have to copy these files manually.

>From your question I guess that this module has all its files under
appname/src, so I think it will be enough to copy the src folder next to
your app directory, with a sane name (e.g. extmodule). After this step, you
can use extmodule as if it were your own app, like inserting it into
INSTALLED_APPS, etc.

However, the way you want to do it can really mess up things, especially
when a new version of this app gets released. You should install (and I
mean install, not just copy) the app system-wide, or into your own home
directory (and in this case add the location to PYTHONPATH). I personally
suggest to use virtualenv, which makes this above process a child's play :)

Best,
Gergely
On 11 Mar 2015 00:09, "jaisol"  wrote:

> Thanks for your quick response.
>
> Ok. I'm using my system python with a system-wide installed django.
>
> I ran git clone:
> git clone https://github.com/provider/app.git and it created the folder
> structure of the django app I think.
>
> what I don't get is how to complete your advice ("or simply inject it into
> your application's structure") within the downloaded app.
> I mean, after downloading the app via git clone... should I create/edit
> some configuration file to get the contents of the "src/idea" app directory
> into my django project? and how? :-(
>
> Thanks again!
>
>
> On Tuesday, March 10, 2015 at 4:03:55 PM UTC-6, Gergely Polonkai wrote:
>>
>> Hello,
>>
>> this pretty much depends on your environment. I, personally, use
>> virtualenv and pip, so most likely will install such an external app like
>> this:
>>
>> pip install git://my.favourite.provider/awesome/app.git
>>
>> If you use your system python, with a system-wide installed django, then
>> you may either want to install this new app into a system-wide python
>> directory, or simply inject it into your application's structure (which, in
>> turn, may mess up your version control system, if you use any; and you
>> should).
>>
>> Best,
>> Gergely
>> On 10 Mar 2015 22:47, "jaisol"  wrote:
>>
>>> Hi,
>>>
>>> Sorry to ask such a silly question I just cloned a Django app via
>>> git and I want to get the contents of the app code directory into my Django
>>> project.
>>>
>>> The Readme.md says the following but I don't get it :-(
>>>
>>> Folder Structure
>>>
>>> You will need to get the contents of the src/idea directory into your
>>> Django project. The simplest way to do this might be a symbolic link.
>>>
>>> mydjango_project/
>>>   |- idea/  (includes models.py, views.py, etc.)
>>>   |- mydjango_project/ (settings.py, url.py, etc.)
>>>   |- manage.py
>>>   |- etc etc etc
>>>
>>> Any advice or guidance would be greatly appreciated !!
>>>
>>> Thanks!
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@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/b5f3a14a-a487-4459-843f-ca7d560beff9%
>>> 40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/b5f3a14a-a487-4459-843f-ca7d560beff9%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7c4520d1-d6ce-4905-bb32-284e18bfc382%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/7c4520d1-d6ce-4905-bb32-28

Re: Generic Relation in Legacy Database?

2015-03-11 Thread Gergely Polonkai
Hello,

sure, I can do that as soon as I get home in the evening (timezone CET).
Maybe we can patch up some helper class for anyone who wants to migrate
from eloquent, although I don't think many devs who use an ORM already
would want to transition to another, but hey, who knows? :)

Best,
Gergely
On 11 Mar 2015 02:07,  wrote:

>
> Thanks, Gergely — it’s actually Eloquent, which handles GFKs a little more
> similarly to Django than Doctrine does, AFAICT.
>
> Would you mind sharing your GFK changes-in-progress?  Maybe we could
> collaborate on a broader solution.
>
>
> On Mar 10, 2015, at 3:30 PM, Gergely Polonkai  wrote:
>
> Hello,
>
> By taking a quick glance on I'm afraid that a GFK subclass is your best
> bet. I was experimenting with a Doctrine DB (based on your description my
> guess was that your old ORM may be that). A little bit of change to GFK
> made the query working, although I haven't solved the insert/update problem
> yet.
>
> Best,
> Gergely
> On 10 Mar 2015 15:57,  wrote:
>
>>
>> Avraham, are you at all familiar with Django’s GenericForeignKey model
>> field?
>>
>> It relies on *two* fields in the model.  Django resolves a generic
>> foreign key by looking up the content type (a FK to the content types
>> table) to figure out what table to look for the object ID in.  Then it
>> looks for the object ID (what would normally be the foreign key) in the
>> table in question.
>>
>> The problem is not the object ID.  The problem is that my table does not
>> reference Django’s content types table and thus does not conform to what
>> Django expects from a GenericForeignKey.  Django then won’t be able to tell
>> which table to look up the object ID in.
>>
>> And I’m using Postgres, but that shouldn’t matter in this case.
>>
>>
>> On Mar 10, 2015, at 10:47 AM, Avraham Serour  wrote:
>>
>> for each field in the model you can specify the column name un the db, it
>> does have a default way of calculating that, but you can specify
>>
>> in any case you can tell the django ORM that this field is not an int, it
>> is actually a foreign key, let me know if that works
>>
>> what DB are you using? mysql?
>>
>> On Tue, Mar 10, 2015 at 2:59 PM, Nan  wrote:
>>
>>>
>>> Thanks, Avraham -- I was planning to use inspectdb as a first step, and
>>> it's very handy in streamlining building models!
>>>
>>> But that doesn't even begin to solve the problem of how a GFK modeled
>>> differently than Django's ORM does can be used as an actual foreign key.
>>>
>>>
>>> On Sunday, March 8, 2015 at 1:07:56 PM UTC-4, Avraham Serour wrote:
>>>>
>>>> use inspectdb to start
>>>>
>>>> On Sun, Mar 8, 2015 at 5:31 PM, Nan  wrote:
>>>>
>>>>>
>>>>> Hi folks --
>>>>>
>>>>> I'm building out Django models to represent a legacy PHP app's
>>>>> database in order to throw together a quick admin panel.  Everything's
>>>>> working great except that the ORM of the other application represents
>>>>> generic relations slightly differently than Django's does.  I can't modify
>>>>> the DB schema because the legacy application has to continue to run.
>>>>>
>>>>> Django uses:
>>>>>
>>>>> int content_type_id
>>>>> int object_id
>>>>>
>>>>> The existing DB essentially uses:
>>>>>
>>>>> string model_class_name
>>>>> int object_id
>>>>>
>>>>> Is there a way to get Django's ORM to use these fields to represent a
>>>>> GFK relationship so I can use it in the admin?  I can add tables, just not
>>>>> modify existing ones.  Maybe an extra 1-to-1 mapping content types to
>>>>> legacy model names would help?  Maybe writing a GenericForeignKey
>>>>> subclass?  A quick look at the source suggests there are a lot of methods
>>>>> that will need to be overridden (by copy-pasting 40 lines and changing
>>>>> one), which doesn't sound like fun to maintain in the long run.
>>>>>
>>>>> Just wondering if anyone's done this before or has any tips before I
>>>>> dive in.
>>>>>
>>>>> Thanks!
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Dja

Re: Generic Relation in Legacy Database?

2015-03-12 Thread Gergely Polonkai
Hello,

By taking a quick glance on I'm afraid that a GFK subclass is your best
bet. I was experimenting with a Doctrine DB (based on your description my
guess was that your old ORM may be that). A little bit of change to GFK
made the query working, although I haven't solved the insert/update problem
yet.

Best,
Gergely
On 10 Mar 2015 15:57,  wrote:

>
> Avraham, are you at all familiar with Django’s GenericForeignKey model
> field?
>
> It relies on *two* fields in the model.  Django resolves a generic foreign
> key by looking up the content type (a FK to the content types table) to
> figure out what table to look for the object ID in.  Then it looks for the
> object ID (what would normally be the foreign key) in the table in question.
>
> The problem is not the object ID.  The problem is that my table does not
> reference Django’s content types table and thus does not conform to what
> Django expects from a GenericForeignKey.  Django then won’t be able to tell
> which table to look up the object ID in.
>
> And I’m using Postgres, but that shouldn’t matter in this case.
>
>
> On Mar 10, 2015, at 10:47 AM, Avraham Serour  wrote:
>
> for each field in the model you can specify the column name un the db, it
> does have a default way of calculating that, but you can specify
>
> in any case you can tell the django ORM that this field is not an int, it
> is actually a foreign key, let me know if that works
>
> what DB are you using? mysql?
>
> On Tue, Mar 10, 2015 at 2:59 PM, Nan  wrote:
>
>>
>> Thanks, Avraham -- I was planning to use inspectdb as a first step, and
>> it's very handy in streamlining building models!
>>
>> But that doesn't even begin to solve the problem of how a GFK modeled
>> differently than Django's ORM does can be used as an actual foreign key.
>>
>>
>> On Sunday, March 8, 2015 at 1:07:56 PM UTC-4, Avraham Serour wrote:
>>>
>>> use inspectdb to start
>>>
>>> On Sun, Mar 8, 2015 at 5:31 PM, Nan  wrote:
>>>

 Hi folks --

 I'm building out Django models to represent a legacy PHP app's database
 in order to throw together a quick admin panel.  Everything's working great
 except that the ORM of the other application represents generic relations
 slightly differently than Django's does.  I can't modify the DB schema
 because the legacy application has to continue to run.

 Django uses:

 int content_type_id
 int object_id

 The existing DB essentially uses:

 string model_class_name
 int object_id

 Is there a way to get Django's ORM to use these fields to represent a
 GFK relationship so I can use it in the admin?  I can add tables, just not
 modify existing ones.  Maybe an extra 1-to-1 mapping content types to
 legacy model names would help?  Maybe writing a GenericForeignKey
 subclass?  A quick look at the source suggests there are a lot of methods
 that will need to be overridden (by copy-pasting 40 lines and changing
 one), which doesn't sound like fun to maintain in the long run.

 Just wondering if anyone's done this before or has any tips before I
 dive in.

 Thanks!

 --
 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...@googlegroups.com.
 To post to this group, send email to django...@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/3ec838f1-34ff-46f1-9b94-d3b9ac905d19%
 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 http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/65c6f173-b407-465c-aecf-0c0a018050c6%40googlegroups.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/CRGUNH0DkhU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> djang

Testing template context processors

2015-03-17 Thread Gergely Polonkai
Hello,

I wrote a context processor which makes some global variables of mine
available for templates. I cannot find a good (cough… any) article on how
to test such processors. Could you give me some directions on where to
start with writing one?

Thanks in advance!

Best,
Gergely

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


Re: Testing template context processors

2015-03-17 Thread Gergely Polonkai
Hello,

My processor sets some template variables based on request.user and some
DB/redis query results, which are displayed on each page on a header bar,
so I only need to create a mocked request with user set to something
(AnonymousUser or a valid user object).

I'm already using Mock[2] for middleware testing, funny that I didn't think
of this way (especially as I implemented it today), so thanks for pointing
out!

[2] https://pypi.python.org/pypi/mock
On 17 Mar 2015 17:59, "Carl Meyer"  wrote:

> Hi Gergely,
>
> On 03/17/2015 10:52 AM, Gergely Polonkai wrote:
> > I wrote a context processor which makes some global variables of mine
> > available for templates. I cannot find a good (cough… any) article on
> > how to test such processors. Could you give me some directions on where
> > to start with writing one?
>
> Writing a unit test for a context processor is quite simple. Construct a
> fake request (you can use RequestFactory, though if your context
> processor only accesses one or two attributes of the request, it might
> be simpler to just build a custom fake or use a library like pretend
> [1]), then call the context processor function in your test, passing in
> the fake request, and assert that the returned dictionary contains what
> you expect.
>
> If your templates require the values from the context processor in order
> to render correctly, you can also write a higher-level integration or
> functional test by using the test client to access a view that renders a
> template that needs the context processor, and then assert the right
> value is found in the rendered HTML.
>
> Carl
>
>   [1] https://pypi.python.org/pypi/pretend
>
> --
> 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/55085D7A.5040007%40oddbird.net
> .
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUK0Q%2BriJZ9FNBxDvXAHHUAVNVh8tamCPbqCeQFr__UgTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Testing migrations

2015-03-20 Thread Gergely Polonkai
Hello,

I just wrote a migration class with RunPython. When I run my tests, my
coverage value drops to to ninety-something percents, because the initial
database created by the test runner is (obviously) empty, thus, my
migration function’s for iteration won’t run.

Is there a way to test such migrations? Not just because of coverage
values, but I’d like to check if my migration function runs correctly.
Basically I create a new column which will have a generated initial value
based on other fields.

Thanks in advance!

Best,
Gergely

-- 
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/CACczBUKBu-8W7hS6b4_EXGnZGGq1jYuDshOU8q4NPbvp%2B_wVOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re-run only tests that failed last time

2015-03-24 Thread Gergely Polonkai
Hello,

I have a pretty extended test suite for my application, which can run for
about 15 minutes. Now when I introduce an error, I will be notified of it
pretty late, and a one-liner fix needs another 15 minutes to check. Of
course if only one of my tests fail, I can add the name of the test case as
a parameter to manage.py test, but in case of many failures it’s pretty
hard to do the same.

Is there a way to run only the tests that failed last time, even if I have
to install a separate app/module for that? A quick Google search gave me no
usable results.

Best,
Gergely

-- 
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/CACczBU%2B-SR3uASD_eQc_c%2BKFp%3DvCgaWga6pfUgA%2BJHr5HgkCHQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Re-run only tests that failed last time

2015-03-24 Thread Gergely Polonkai
@Erik: On the CI side, certainly, I will run all the tests upon each
commit. I want to utilize this thing only on my developer machine, so I can
do a quick run after I think I fixed a problem. Naturally, if those failing
tests are green, I will run the whole suite again.

Separating/tweaking my current tests is not really an option; the whole
project is pretty big, with some large apps (yes, those must be cut in
smaller pieces, but that’s not today’s work yet). It will happen, though,
but thanks for pointing it out!

@Ramiro Morales: This juno test runner seems promising, thank you for the
link!

On 24 March 2015 at 15:08, Ramiro Morales  wrote:

> On Tue, Mar 24, 2015 at 7:27 AM, Gergely Polonkai 
> wrote:
> > Hello,
> >
> > I have a pretty extended test suite for my application, which can run for
> > about 15 minutes. Now when I introduce an error, I will be notified of it
> > pretty late, and a one-liner fix needs another 15 minutes to check. Of
> > course if only one of my tests fail, I can add the name of the test case
> as
> > a parameter to manage.py test, but in case of many failures it’s pretty
> hard
> > to do the same.
> >
> > Is there a way to run only the tests that failed last time, even if I
> have
> > to install a separate app/module for that? A quick Google search gave me
> no
> > usable results.
>
> Mine found:
>
> https://pypi.python.org/pypi/django-juno-testrunner
>
> http://nose.readthedocs.org/en/latest/plugins/testid.html#looping-over-failed-tests
> plus https://github.com/django-nose/django-nose
>
> --
> Ramiro Morales
> @ramiromorales
>
> --
> 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/CAO7PdF_-Km0%2BHC9jcJ%3DfvFJEJZqQoA_Xp_uSL6r0cTCSXjhN%2Bg%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBU%2B3gm7COWJnJqCd80u12Upk%3DhFnfjpZGF7D1MnJfMb9WQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Re-run only tests that failed last time

2015-03-24 Thread Gergely Polonkai
Hello Russ,

I've already installed the juno test runner, but a graphical tool cannot
hurt locally 😃 I'll check it out tomorrow, thanks for the link!

Best,
Gergely
On 24 Mar 2015 23:22, "Russell Keith-Magee"  wrote:

> Hi Gergely,
>
> One option is to use a test suite GUI tool, like cricket:
>
> http://pybee.org/cricket
>
> Cricket lets you view your entire test suite as a tree, select subsets of
> the suite to run, see test results as the suite executes, and re-run the
> failures from the previous execution.
>
> Yours,
> Russ Magee %-)
>
>
> On Tue, Mar 24, 2015 at 6:27 PM, Gergely Polonkai 
> wrote:
>
>> Hello,
>>
>> I have a pretty extended test suite for my application, which can run for
>> about 15 minutes. Now when I introduce an error, I will be notified of it
>> pretty late, and a one-liner fix needs another 15 minutes to check. Of
>> course if only one of my tests fail, I can add the name of the test case as
>> a parameter to manage.py test, but in case of many failures it’s pretty
>> hard to do the same.
>>
>> Is there a way to run only the tests that failed last time, even if I
>> have to install a separate app/module for that? A quick Google search gave
>> me no usable results.
>>
>> Best,
>> Gergely
>>
>> --
>> 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/CACczBU%2B-SR3uASD_eQc_c%2BKFp%3DvCgaWga6pfUgA%2BJHr5HgkCHQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CACczBU%2B-SR3uASD_eQc_c%2BKFp%3DvCgaWga6pfUgA%2BJHr5HgkCHQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJxq84-hZn2VOe_dHRS63BXTmFJ8h3pbdsuKgQE1uFJo6csBZw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAJxq84-hZn2VOe_dHRS63BXTmFJ8h3pbdsuKgQE1uFJo6csBZw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBULt18gAbJT1-1OWEd2Xy%2Bsk-201%3D%2Bs1EYgJ9zveyo-Uaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Re-run only tests that failed last time

2015-03-25 Thread Gergely Polonkai
Hello Carl,

thanks, I will take a look at this, too!

Best,
Gergely

On 24 March 2015 at 23:33, Carl Meyer  wrote:

> Hi Gergely,
>
> On 03/24/2015 04:27 AM, Gergely Polonkai wrote:
> > I have a pretty extended test suite for my application, which can run
> > for about 15 minutes. Now when I introduce an error, I will be notified
> > of it pretty late, and a one-liner fix needs another 15 minutes to
> > check. Of course if only one of my tests fail, I can add the name of the
> > test case as a parameter to manage.py test, but in case of many failures
> > it’s pretty hard to do the same.
> >
> > Is there a way to run only the tests that failed last time, even if I
> > have to install a separate app/module for that? A quick Google search
> > gave me no usable results.
>
> I use py.test [1], another test runner which has plugins that offer this
> feature. The pytest-django [2] plugin provides the necessary integration
> to make py.test able to run a normal Django test suite. Then the
> pytest-cache [3] plugin offers an ``--lf`` (last-failed) option to run
> only the tests that failed in the last run, and the pytest-xdist [4]
> plugin offers the even-more-advanced ``--looponfail`` option, which "run
> your tests repeatedly in a subprocess. After each run py.test waits
> until a file in your project changes and then re-runs the previously
> failing tests. This is repeated until all tests pass after which again a
> full run is performed."
>
> If you're interested in advanced Python testing, I think py.test is near
> the top of the list of tools you should at least take for a spin.
>
> Carl
>
> [1] http://pytest.org/latest/
> [2] https://pypi.python.org/pypi/pytest-django/
> [3] https://pypi.python.org/pypi/pytest-cache
> [4] https://bitbucket.org/pytest-dev/pytest-xdist
>
> --
> 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/5511E627.8090409%40oddbird.net
> .
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUL4JS184G5Fx_kLQx59i2FVwhgcnp5K0nMD5uHGh3sppQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django accepting other applications ports

2015-03-25 Thread Gergely Polonkai
Hello,

Please share the rest of this Apache config; from what you copied, it's
impossible to tell.

Best,
Gergely
On 25 Mar 2015 17:12, "Sven Mäurer"  wrote:

> I have two applications on my apache. Why is my Django application running
> accepting the connection also of port ?
>
> Listen 8787
> 
>
>
> The other application:
>
> Listen 
> 
>
> --
> 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/f512ca44-b7fc-4e26-8c56-7cb325e1f6dd%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUKqGqwr1uOAQoBbsa743mnKCAKvUAqOWsfEaf_S2-zFhA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Inserting literal % sign in QuerySet.extra()

2015-03-27 Thread Gergely Polonkai
Hello,

I’d like to execute the following code:

Booking.objects.filter(start_ts__isnull = False, end_ts__isnull =
False).extra(select = {'amount': "strftime('%s', end_ts) - strftime('%s',
start_ts)"})

However, in the shell, I get the following error:

Traceback (most recent call last): File "", line 1, in 
File
"/home/polesz/Projects/duckbook/venv/lib/python3.4/site-packages/django/db/models/query.py",
line 835, in extra clone.query.add_extra(select, select_params, where,
params, tables, order_by) File
"/home/polesz/Projects/duckbook/venv/lib/python3.4/site-packages/django/db/models/sql/query.py",
line 1744, in add_extra entry_params.append(next(param_iter)) StopIteration

I have tried doubling the percent signs (%%s) and escaping them with a
backslash (\%s), but neither helped. I also looked at this answer
[1], but that solution doesn’t
work with QuerySet.extra() (or I just miss the point).

What is the correct way to solve this?

I also tried to use select_params like this:

Booking.objects.filter(start_ts__isnull = False, end_ts__isnull =
False).extra(select = {'amount': "strftime('%s', end_ts) - strftime(%s,
start_ts)"}, select_params = ['%s', '%s'])

but regardless the usage of quote signs, the resulting query has \'%s\',
which gives an SQL error, of course.

Best,
Gergely

[1] http://stackoverflow.com/a/18143147/1305139

-- 
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/CACczBULm5dPUvYc4Me-yNqsC%3DgS1grpa4Q%2BMVtPnHVEOCrzfcQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Inserting literal % sign in QuerySet.extra()

2015-03-27 Thread Gergely Polonkai
Great, thank you!

Although I'm more than willing to upgrade, I still wonder if this fix will
be backported to 1.7…
On 28 Mar 2015 02:15, "Tim Graham"  wrote:

> This is fixed in Django 1.8. See the fifth item in
> https://docs.djangoproject.com/en/dev/releases/1.8/#models.
>
> On Friday, March 27, 2015 at 5:38:15 PM UTC-4, Gergely Polonkai wrote:
>>
>> Hello,
>>
>> I’d like to execute the following code:
>>
>> Booking.objects.filter(start_ts__isnull = False, end_ts__isnull =
>> False).extra(select = {'amount': "strftime('%s', end_ts) - strftime('%s',
>> start_ts)"})
>>
>> However, in the shell, I get the following error:
>>
>> Traceback (most recent call last): File "", line 1, in 
>> File "/home/polesz/Projects/duckbook/venv/lib/python3.4/
>> site-packages/django/db/models/query.py", line 835, in extra
>> clone.query.add_extra(select, select_params, where, params, tables,
>> order_by) File "/home/polesz/Projects/duckbook/venv/lib/python3.4/
>> site-packages/django/db/models/sql/query.py", line 1744, in add_extra
>> entry_params.append(next(param_iter)) StopIteration
>>
>> I have tried doubling the percent signs (%%s) and escaping them with a
>> backslash (\%s), but neither helped. I also looked at this answer
>> <http://stackoverflow.com/a/18143147/1305139>[1], but that solution
>> doesn’t work with QuerySet.extra() (or I just miss the point).
>>
>> What is the correct way to solve this?
>>
>> I also tried to use select_params like this:
>>
>> Booking.objects.filter(start_ts__isnull = False, end_ts__isnull =
>> False).extra(select = {'amount': "strftime('%s', end_ts) - strftime(%s,
>> start_ts)"}, select_params = ['%s', '%s'])
>>
>> but regardless the usage of quote signs, the resulting query has \'%s\',
>> which gives an SQL error, of course.
>>
>> Best,
>> Gergely
>>
>> [1] http://stackoverflow.com/a/18143147/1305139
>>
>  --
> 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/fa509ee1-6bb2-43c8-a1a1-e12ad70a123f%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/fa509ee1-6bb2-43c8-a1a1-e12ad70a123f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBU%2B8FvXtCHe1bLUYjU51OU8JV4bxEXThQcWMxL5euc44gg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django TCP Socket Communication

2015-03-28 Thread Gergely Polonkai
Hello,

it's a bit hard to understand what you exactly want to achieve. How can you
communicate with the microcontroller? Do you connect to one of its TCP
ports, and send it data, I assume. Is it done with a well-known protocol,
like HTTP, or some custom one?

You say that it opens a port every 5 seconds to a server. Where is that
server? Is it on the same machine as you Django based application? How does
the microcontroller and the server communicate with each other?

There are so many architectural questions here before you get to a web
application, and I'm afraid you original question cannot be answered before
we see the whole picture.

Best,
Gergely
On 28 Mar 2015 11:06, "bobdxcool"  wrote:

> But is that compatible with django ?
>
> On Sat, Mar 28, 2015 at 1:24 AM, François Schiettecatte [via Python] <[hidden
> email] > wrote:
>
>> Have you looked at the ‘socket’ python library ?
>>
>> François
>>
>> > On Mar 27, 2015, at 3:05 PM, bobdxcool <[hidden email]
>> > wrote:
>> >
>> > I am new to TCP socket programming. I have a django based server
>> > communicating with a microcontroller. Now, I want to implement TCP
>> based
>> > socket on the server side in order to communicate with the TCP socket
>> on the
>> > microcontroller. Can anyone give me an idea on how to do this ? What
>> > libraries should I use on my django server The microprocessor basically
>> > opens the socket every 5 seconds and sends a notification to the
>> server. I
>> > on the server side should be able to read this and pump data back to
>> the
>> > microprocessor using this socket which was opened by the
>> microprocessor.
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> http://python.6.x6.nabble.com/Django-TCP-Socket-Communication-tp5090792.html
>> > Sent from the django-users mailing list archive at Nabble.com.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an email to [hidden email]
>> .
>> > To post to this group, send email to [hidden email]
>> .
>> > 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/1427483125637-5090792.post%40n6.nabble.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 [hidden email]
>> .
>> To post to this group, send email to [hidden email]
>> .
>> 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/DAE16363-2EEE-4E0F-A230-A31BB270E2F9%40gmail.com.
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>>  If you reply to this email, your message will be added to the
>> discussion below:
>>
>> http://python.6.x6.nabble.com/Django-TCP-Socket-Communication-tp5090792p5090799.html
>>  To unsubscribe from Django TCP Socket Communication, click here.
>> NAML
>> 
>>
>
>
> --
> View this message in context: Re: Django TCP Socket Communication
> 
> Sent from the django-users mailing list archive
>  at Nabble.com.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAGpTunuCPXJZo82m1nefz_tvbQJ9Y3-S3en1GZj3aFHsMx7fHg%40mail.gmail.com
> 
> .
> For more options, visit https://

Re: Strange deployment problem

2015-03-28 Thread Gergely Polonkai
Hello,

do you have command line access on that machine? If so, can you connect to
the database using the credentials in the settings file?

Best,
Gergely
On 28 Mar 2015 14:21, "Anderson Resende" 
wrote:

>
> I don't used mysql,but in postgres for you write in a database your user
> db needs permission to write.
> Check that!
>
> --
> 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/b0eba252-8c3e-4b51-ab38-ea7f04df3a69%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBU%2BZN5B9UZK%2B0pgsOk3YULwgoOkLObGmV7%2Bc8eA3_MdqdA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: GUI with web-browser using Django, Python 3

2015-05-04 Thread Gergely Polonkai
Hello,

you should walk through the Django tutorial[1] to get as idea on how to use
it. However, if this is the sole problem, I think Django is overkill, a
pure WSGI page would suffice.

Best,
Gergely

[1] https://docs.djangoproject.com/en/1.8/intro/tutorial01/
On 4 May 2015 17:28, "Aura"  wrote:

> I want to make a py-file by GUI. The GUI I want is based on web-browser
> (chrome, safari). So I use Django.
>
> The step-by-step idea is:
>
>1.
>
>I open the web-browser (as GUI, not to access internet). On the
>web-browser, there are two blanks and a "Generate" button, like
>
>a = ??
>
>filename = ??
>
>"Generate"
>
>(Here ?? is blank waiting for filling.)
>2.
>
>I fill like: a = [1,2,3,4], and filename = MyFile
>3.
>
>Click the "Generate" button
>
>Then A py-file "MyFile.py" is generated in an aimed folder. In the
>file, there is a python code
>
>a = [1,2,3,4]
>
>4.
>
>I plot a figure by
>
>import matplotlib.pyplot as plt
>plt.plot(a,a)
>
>It will generate a figure. I want this figure to be shown on the
>web-browser.
>
> I am using Python 3.
>
> Can you please show me how to do the 4 steps with Django? Thanks!
>
> --
> 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/d4a8bc37-a838-40a1-ac21-48ebd335d8d8%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUKG73S-DPWpMibwas3hSyPn4i%2Buj1p_o64bQfzmzZ8yFA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Generic template; determining information about calling view/app

2015-05-10 Thread Gergely Polonkai
Hello,

I wrote a middleware[1] for my old blog engine; here, view_func.__module__
is the app’s name. It is not really sophisticated, though, but it may
provide a good start.

About the URL namespace, I don’t think it’s easy to do. An app doesn’t have
a namespace; you can include an url definition file multiple times with
different namespaces.

Best,
Gergely

[1]
https://github.com/gergelypolonkai/gergelypolonkaiweb/blob/master/gergelypolonkaiweb/middleware/viewname.py

2015-05-08 18:11 GMT+02:00 David :

> Hi
>
> Sorry if this is confusing, it's the best I can describe.
>
> I have been separating my templates for inheritance clarity. I have a
> generic template 'category_list.html'. This can be used by different apps
> because the layout is the same.
>
> What I need to do in order to use appropriate links in the template is to
> find out:
>
> a) the name of the application calling it
> b) the namespace of the application url so I can use a dynamic {% url %}
> tag
>
> Firstly, I guess, is this possible?
>
> Yes, I can inherit the templates further and pass info directly from the
> views, but the creation of extra templates just for these 2 things seemed
> like I was doing something wrong.
>
> Many thanks for any assistance.
>
> --
> 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/64637401-2cbd-4f8c-b7c0-4910aeceeb84%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBU%2B3dakJnzTkHpfdU_BhvEacxABohNb6t0Rv%3DUtXq5aCPQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Interaction of Python Code with Django.

2015-05-12 Thread Gergely Polonkai
The tricky part here is providing the input for the interactive tool. For
shell scripts there is a software called expect, you may want to look for
Python alternatives. Of course, if this interactive tool reads sequential
input from stdin and sends output to stdout, there are much easier
solutions, as in this case you can simply use a subprocess (which in itself
can be tricky, if the tool is not well tested for malicious input).
On 12 May 2015 16:59, "SUBHABRATA BANERJEE" 
wrote:

> Dear Group,
>
> I want to integrate an interactive Python code, (it takes user input,
> processes input and gives output), with Django.
> I am new to Django, using Python2.7.9 on Windows 7 Professional.
>
> I am researching on it, but as it is a room for Django experts, I am
> trying to post this
> question, if anyone may kindly suggest how may I proceed? An example or
> web based tutorial would be great.
>
> Regards,
> Subhabrata Banerjee.
>
>  --
> 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/10699b8a-3e40-42e6-a131-85d78e55a5ec%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUJoAND1Yx6Skm3BVY6Fn4xaVprLDfZqQs-5VSqJk777%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to load an object created from a model outside the project ?

2015-05-13 Thread Gergely Polonkai
Hello,

if you don't have to modify the object, I would suggest using serialization
instead of pickling.

Best,
Gergely
On 13 May 2015 16:01, "Matthieu"  wrote:

> Hi,
>
> I saved with pickle an object created from a Django model :
>
> class Country(models.Model):
> code = models.IntegerField(primary_key=True)
> name = models.CharField(max_length=30)
> def __str__(self):
> return (self.name)
>
> england = Country(code=1, name="England")
> pickle.dump(england, open( "england.p", "wb" ))
>
> And I'm trying to access it outside Django, directly with Python :
> england = pickle.load(open( "england.p", "rb" ))
>
> But if fails :
> ImproperlyConfigured: You must either define the environment variable
> DJANGO_SETTINGS_MODULE or call settings.configure() before accessing
> settings
>
> My question is : how can i read this object (and access to its attributes)
> with Python without Django ?
>
> Thanks for your help,
> Matthieu
>
> --
> 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/ec42d8bc-cecf-4583-b808-6832fa30706b%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUKuYqZynfjUgnMASS%2BOzT0rZYhCHqcyk8Z6BDyKNj%2BV%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Global Variable Neded? - Python 2.7.8 / Django 1.7

2015-05-13 Thread Gergely Polonkai
Hello,

I think the source of your frustration is that you started on the wrong
track. If you create a global variable here, *all* your users will see the
same fields. I guess it’s not really the thing you want.

You have several other options here:

1) Add a user setting in the database

If you create a separate model with your User model as its primary key
(thus, creating a OneToOne relation between a User and Setting), you can
store these values in the database, this way persisting it between user
sessions

2) Session variables

You can use Django’s session framework. Here[1] is some help on this.

3) Cache

This can be similar to 1) or 2), or somewhat the combination of the two.
This way you store such values in a cache, like MemCached. This solves some
possible garbage collection problems and database storage issues. More on
accessing the cache here[2].

Hope this helps.

Best,
Gergely

[1]
https://docs.djangoproject.com/en/1.7/topics/http/sessions/#using-sessions-in-views
[2]
https://docs.djangoproject.com/en/1.8/topics/cache/#the-low-level-cache-api

2015-05-13 23:13 GMT+02:00 Henry Versemann :

> I have a list of one or more items being returned back to my application
> as a response from a call to an API. In this particular part of the process
> depending on the data keys selected by the user, if any some data fields
> will be formatted automatically. When that happens I need to add the keys
> to those new automatically-generated fields to the list of data keys
> originally entered by the user. In the case where there's only one item
> being returned, this isn't a problem, but when I get back multiple objects
> in my response I only want to add the new data field keys to the display
> key list once. The flag will be initialized to false at the beginning of
> the process which processes all of the responses. So the only way I could
> think of to do this would be to setup some kind of global variable that can
> be checked and when set to "false" then and only then update the display
> key list with the keys to the new data fields. Then also at the same time
> set the flag to "true", so the update doesn't happen again for each and
> every subsequent item in the list of response objects. At least not until
> the next request is sent and its response is being processed.
>
> So what are my options for creating a global Boolean variable(or any other
> global variable type for that matter), for accomplishing the above task?
>
> So far I've tried using a "global" keyword when setting up a variable, as
> well as declaring a variable in a globalvars.py file, importing the
> file and trying to reference it something like this:
>
> globalvars.display_key_list_updated = True or False
>
> But I keep getting errors of one sort or another with each way I've tried
> so far (mostly exceptions.NameError).
>
> This is my first attempt at trying to setup and use some kind of a global
> variable, so its kind of frustrating, and I'm probably making it harder
> than it is, but my lack of experience is getting in the way.
>
> Thanks for the help. It is much appreciated.
>
> Henry
>
>  --
> 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/8a1f173b-de34-4e34-8c34-e1512b46a05d%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBU%2BxAcmgAuxw9spYAZ2L2-EaQ%2BDBNSM9eLFxnMoDT9sq8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to load an object created from a model outside the project ?

2015-05-14 Thread Gergely Polonkai
Hello,

depends on what exactly you want to do. You can take a look at Django’s own
serialization solution[1], or, if you want to build a REST framework based
on this, you may want to look at [2] or [3].

Best,
Gergely

[1] https://docs.djangoproject.com/en/1.8/topics/serialization/
[2] https://django-restless.readthedocs.org/en/latest/
[3] http://www.django-rest-framework.org/

2015-05-14 12:06 GMT+02:00 Matthieu :

> Hi Gergely,
>
> Thanks for you answer.
> I don't need to modify the object. I also tried with "dill" package but
> it's not working either. How can I use serialization with my example ?
>
> --
> 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/b260b072-3a28-4ef3-97a7-d419e401ca80%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUJSJ_tZBZ04N_O8_8h0G0r3MHk9A6uNNf9GJGm8eP4eqg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Logout user on tab closing

2015-05-19 Thread Gergely Polonkai
Well, onunload can be used if you are creating a one-page app, e.g. by
using AngularJS. With multipage apps, this is of no use.
On 19 May 2015 16:54, "Javier Guerra Giraldez"  wrote:

> On Tue, May 19, 2015 at 8:23 AM, Miloš Milovanović
>  wrote:
> > I want to logout a user from application when the application tab is
> closed.
>
>
> the browser doesn't notify the server when the tab (or window) is closed.
>
> remember that the original web architecture was simply about
> downloading HTML documents and showing to the user.  Once the download
> has happened, we're done with the server.
>
> the whole concept of "web application" is javascript running in the
> context of a web page, so you need the application itself (not the
> browser) to notify the server.  You can use the "on-unload" event; for
> example with jQuery's .unload() event hook.  Note that this event
> fires every time the page is unloaded, not only when the window or tab
> is closed, but also if the user navigates to another page (either via
> the URL bar or by clicking any link), uses the 'back' or 'forward'
> buttons, or even when reloading.
>
> that's why most web applications rely on timeout and not on trying to
> detect the user leaving the application.
>
> --
> Javier
>
> --
> 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/CAFkDaoQumw7hWa6DKL-WTAx%2BLyjWciMCgxuBDyC2H5HB_kBGdw%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBULmFuvg8NqL%3DZ147cyy1g9TM1eMEekbuZmysGQXbDmrmw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to get a application-formpost in django view? Get QueryDict variables.

2015-05-21 Thread Gergely Polonkai
Assuming your QueryDict is called my_post_data, use
my_post_data.get('data[id]').
On 21 May 2015 15:28, "Fellipe Henrique"  wrote:

> Hello,
>
> I need to get one application-form-post content from one server. This
> server isn't mine.
>
> They send to me this application-form-post, and in Django View I receive
> this:
>
>  'data[status]': ['paid'], 'event': ['invoice']}>
>
> I need to get: data['id'], data['status']  and event variables..
>
> How I do this in django? Because I can't work with QueryDict... I try to
> transform in python dict, in python list, but anyone works...
>
> Any idea for these problem?
>
> Regards,
>
>
> T.·.F.·.A.·. S+F
> *Fellipe Henrique P. Soares*
>
> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \
> 's/(.)/chr(ord($1)-2*3)/ge'
> *Blog: http://fhbash.wordpress.com/ *
> *GitHub: https://github.com/fellipeh *
> *Twitter: @fh_bash*
>
> --
> 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/CAF1jwZFv5zwKHaDAFOz06n_%2B4EiNzzFoYx9t_MfTNnEFranAWg%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBULAgWb%3D6sn1JHxeg_nq%2BO%3DwR9bTBNR69QsUSKog1FB%3DKw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to get a application-formpost in django view? Get QueryDict variables.

2015-05-21 Thread Gergely Polonkai
I don't think so, maybe the post request is poorly formatted. Can you
somehow catch the raw http request for analyzing?
On 22 May 2015 00:14, "Vijay Khemlani"  wrote:

> Maybe the brackets confuse the querydict, try calling its items method (to
> convert it into a list of tuples) or its dict method (to turn it into a
> normal python dict)
>
> On Thu, May 21, 2015 at 3:34 PM, Fellipe Henrique 
> wrote:
>
>> Any ideas?
>>
>> I finish all my possibilities in these problem.. :( and no solution...
>>
>> T.·.F.·.A.·. S+F
>> *Fellipe Henrique P. Soares*
>>
>> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \
>> 's/(.)/chr(ord($1)-2*3)/ge'
>> *Blog: http://fhbash.wordpress.com/ <http://fhbash.wordpress.com/>*
>> *GitHub: https://github.com/fellipeh <https://github.com/fellipeh>*
>> *Twitter: @fh_bash*
>>
>> On Thu, May 21, 2015 at 10:23 AM, Fellipe Henrique 
>> wrote:
>>
>>> Thanks, I try that! but show me None as value...
>>>
>>> I think, that's because the QueryDict is showed in this way:
>>>
>>> >> 'data[status]': ['paid'], 'event': ['invoice.status_changed']": ['']}>
>>>
>>> I think the django takes
>>>
>>> 'data[id]': ['83A0C50B5A0A43AD8F60C1066B16A163'], 'data[status]':
>>> ['paid'], 'event': ['invoice.status_changed']
>>>
>>> as the "key"...
>>>
>>> :(
>>>
>>> T.·.F.·.A.·. S+F
>>> *Fellipe Henrique P. Soares*
>>>
>>> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \
>>> 's/(.)/chr(ord($1)-2*3)/ge'
>>> *Blog: http://fhbash.wordpress.com/ <http://fhbash.wordpress.com/>*
>>> *GitHub: https://github.com/fellipeh <https://github.com/fellipeh>*
>>> *Twitter: @fh_bash*
>>>
>>> On Thu, May 21, 2015 at 10:15 AM, Gergely Polonkai 
>>> wrote:
>>>
>>>> Assuming your QueryDict is called my_post_data, use
>>>> my_post_data.get('data[id]').
>>>> On 21 May 2015 15:28, "Fellipe Henrique"  wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I need to get one application-form-post content from one server. This
>>>>> server isn't mine.
>>>>>
>>>>> They send to me this application-form-post, and in Django View I
>>>>> receive this:
>>>>>
>>>>> >>>> 'data[status]': ['paid'], 'event': ['invoice']}>
>>>>>
>>>>> I need to get: data['id'], data['status']  and event variables..
>>>>>
>>>>> How I do this in django? Because I can't work with QueryDict... I try
>>>>> to transform in python dict, in python list, but anyone works...
>>>>>
>>>>> Any idea for these problem?
>>>>>
>>>>> Regards,
>>>>>
>>>>>
>>>>> T.·.F.·.A.·. S+F
>>>>> *Fellipe Henrique P. Soares*
>>>>>
>>>>> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \
>>>>> 's/(.)/chr(ord($1)-2*3)/ge'
>>>>> *Blog: http://fhbash.wordpress.com/ <http://fhbash.wordpress.com/>*
>>>>> *GitHub: https://github.com/fellipeh <https://github.com/fellipeh>*
>>>>> *Twitter: @fh_bash*
>>>>>
>>>>> --
>>>>> 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/CAF1jwZFv5zwKHaDAFOz06n_%2B4EiNzzFoYx9t_MfTNnEFranAWg%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/django-users/CAF1jwZFv5zwKHaDAFOz06n_%2B4EiNzzFoYx9t_MfTNnEFranAWg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>

Re: Migrating from sqllite3 to postgres

2015-05-22 Thread Gergely Polonkai
I will also have to do this in the near future (same reason), and already
have some untested ideas. My guess is to add a second database in
settings.DATABASES, fetch all the model instances from my original db and
save them in the other. But if anyone has a better solution, let us know!
On 22 May 2015 09:19, "jaspinder singh"  wrote:

> I have developed an app using sqllite. But my Heroku doesn't support
> sqllite and the data keeps leaking every 24 hours. Can someone list the
> steps how to change from sqllite3 to postgres
>
> --
> 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/7fc71178-9609-42c2-8c39-e6c5d132ffdc%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBULGjE0OW3yCNZrRtOQS0JRXjryNGgLB7wzeuiATYSNS9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Address book using django

2015-05-22 Thread Gergely Polonkai
Hello,

besides that it sounds like a homework to me, I don't see why you need an
admin module, as Django already has one.

For everything else, if you walk through the tutorial app, you should get
most of the ideas from there.

Best,
Gergely
On 22 May 2015 09:19, "Preeti"  wrote:

> I have to create an address book using django
> it should contain two modules-user and admin
>
> the user is allowed to write his/her first name/last name, add the
> picture, lists the social media links, should add a 4-digit PIN .
>
> the other user can use that 4-digit PIN to add a particular contact in his
> list.
>
> I'm using Django 1.8, python 3.3
> and the database I prefer is MySql
>
> Please guide how can I proceed with my application..
>
> --
> 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/849c3f71-c5ad-4b62-b9d6-0012505a2201%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUJZfk%3D33nFmQrnDHosn3xUEgBXn_ZL7cz%2BTb7pGLrCy5A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to get a application-formpost in django view? Get QueryDict variables.

2015-05-22 Thread Gergely Polonkai
Actually, it is Django that handles it right. Where there are colons (,),
there should be equation signs. This is not really HTTP compliant, so I'm
afraid you must process the incoming data (i.e. request.body) yourself.
On 22 May 2015 15:46, "Fellipe Henrique"  wrote:

> Here is the request.body:
>
> b"'data[id]', ['83A0C50B5A0A43AD8F60C1066B16A163']&'data[status]',
> ['paid']&'event',['invoice.status_changed']"
>
> I think, maybe, something is wrong in Django, because these same POST is
> easy to get using PHP or Rails.. in PHP I get with these:
>  $_POST['data']['id']
>
> Maybe, something in django isn't implemented yet for these kind POST.
>
> T.·.F.·.A.·. S+F
> *Fellipe Henrique P. Soares*
>
> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \
> 's/(.)/chr(ord($1)-2*3)/ge'
> *Blog: http://fhbash.wordpress.com/ <http://fhbash.wordpress.com/>*
> *GitHub: https://github.com/fellipeh <https://github.com/fellipeh>*
> *Twitter: @fh_bash*
>
> On Fri, May 22, 2015 at 2:53 AM, Gergely Polonkai 
> wrote:
>
>> I don't think so, maybe the post request is poorly formatted. Can you
>> somehow catch the raw http request for analyzing?
>> On 22 May 2015 00:14, "Vijay Khemlani"  wrote:
>>
>>> Maybe the brackets confuse the querydict, try calling its items method
>>> (to convert it into a list of tuples) or its dict method (to turn it into a
>>> normal python dict)
>>>
>>> On Thu, May 21, 2015 at 3:34 PM, Fellipe Henrique 
>>> wrote:
>>>
>>>> Any ideas?
>>>>
>>>> I finish all my possibilities in these problem.. :( and no solution...
>>>>
>>>> T.·.F.·.A.·. S+F
>>>> *Fellipe Henrique P. Soares*
>>>>
>>>> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \
>>>> 's/(.)/chr(ord($1)-2*3)/ge'
>>>> *Blog: http://fhbash.wordpress.com/ <http://fhbash.wordpress.com/>*
>>>> *GitHub: https://github.com/fellipeh <https://github.com/fellipeh>*
>>>> *Twitter: @fh_bash*
>>>>
>>>> On Thu, May 21, 2015 at 10:23 AM, Fellipe Henrique 
>>>> wrote:
>>>>
>>>>> Thanks, I try that! but show me None as value...
>>>>>
>>>>> I think, that's because the QueryDict is showed in this way:
>>>>>
>>>>> >>>> 'data[status]': ['paid'], 'event': ['invoice.status_changed']": ['']}>
>>>>>
>>>>> I think the django takes
>>>>>
>>>>> 'data[id]': ['83A0C50B5A0A43AD8F60C1066B16A163'], 'data[status]':
>>>>> ['paid'], 'event': ['invoice.status_changed']
>>>>>
>>>>> as the "key"...
>>>>>
>>>>> :(
>>>>>
>>>>> T.·.F.·.A.·. S+F
>>>>> *Fellipe Henrique P. Soares*
>>>>>
>>>>> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \
>>>>> 's/(.)/chr(ord($1)-2*3)/ge'
>>>>> *Blog: http://fhbash.wordpress.com/ <http://fhbash.wordpress.com/>*
>>>>> *GitHub: https://github.com/fellipeh <https://github.com/fellipeh>*
>>>>> *Twitter: @fh_bash*
>>>>>
>>>>> On Thu, May 21, 2015 at 10:15 AM, Gergely Polonkai <
>>>>> gerg...@polonkai.eu> wrote:
>>>>>
>>>>>> Assuming your QueryDict is called my_post_data, use
>>>>>> my_post_data.get('data[id]').
>>>>>> On 21 May 2015 15:28, "Fellipe Henrique"  wrote:
>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> I need to get one application-form-post content from one server.
>>>>>>> This server isn't mine.
>>>>>>>
>>>>>>> They send to me this application-form-post, and in Django View I
>>>>>>> receive this:
>>>>>>>
>>>>>>> >>>>>> 'data[status]': ['paid'], 'event': ['invoice']}>
>>>>>>>
>>>>>>> I need to get: data['id'], data['status']  and event variables..
>>>>>>>
>>>>>>> How I do this in dja

Re: Address book using django

2015-05-22 Thread Gergely Polonkai
You say that your backend is ready. Does this mean you have created your
models and can access them from the shell (pythen manage.py shell, see the
first chapter of the tutorial, section Playing with the API)?

If so, what parts of the frontend creation you don't understand? Is it view
creation or templates, or maybe something else?
On 23 May 2015 08:09, "Preeti"  wrote:

> Hi James,
>
> I started learning Django this week.
> My code isn't on Github.
>
>  I learnt building the app, and the backend work but I'm not able to
> understand how to connect front-end with the framework.
>
> I have enclosed a copy of what I want in my app. Please go through it, and
> guide.
>
> Thanks
>
> On Friday, May 22, 2015 at 9:51:05 PM UTC+5:30, James Brewer wrote:
>>
>> Hey Preeti,
>>
>> Glad you're getting into Django! It's a fantastic framework. (I'm kind of
>> biased.)
>>
>> With that said, we need more information to know how to help you. What
>> have you tried? Is your code available on Github? The "Where do I start?"
>> question is too broad for anyone to give an answer more effective than
>> "read the docs".
>>
>> Happy Friday!
>>
>> James
>>
>>  --
> 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/0f1d0d85-2aa7-4790-b721-5a217cfae32c%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBU%2BjskmoLbkC9UKAa4CzH25%2BSiwzBYt_VGStLTNu2YTCEA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Address book using django

2015-05-23 Thread Gergely Polonkai
The error message is somewhat clear on this: there is no such module as
django.contrib.staticfilesdjango. The django at the end seems to be the
cause to me.
On 23 May 2015 20:19, "Preeti"  wrote:

> this is the error I find.. [kindly check the attachment]
>
> --
> 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/ebe2cbae-8313-4d7e-9f16-71941ede06f8%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBU%2B1N_73eT6DXprns2GwomDD7LmgC1X2-2-7Y6LmwFvB%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Changing a form field's value during cleaning

2015-05-26 Thread Gergely Polonkai
Hello,

I'm currently having hard times changing a form field's value from within
the form's clean() method. I have already tried setting
self.initial[field_id] and manipulating the cleaned data by calling super's
clean method, change the required field (cleaned_data[field_id]) and
returning the modified dict, but all for no effect. Trying to change
self.data threw me an error saying data is immutable. Question is, is it
even possible, even if I had to tamper with ”protected/private”
properties/methods?

Should I be on the wrong track, I try to outline the problem:

I have a form with fields added programmatically in __init__(). The value
of these fields come from one of my models. It is highly possible that
another user puts one of the fields in approved state. If this happens, I
don't want the current user to be able to change its value, hence I raise a
validation error in the field's validate() method.

Now comes the tricky part. In this particular case I want three things to
happen:

• warn the user about the fact that the field has already been approved
(i.e. display the validation error message)
• render the input field as read only so the user can't modify it (well, at
least not in a trivial way)
• and revert the field's value to the one in the database

However, in case of a validation error the field's value remains the
”illegal” one the user just entered, and, as the input field is rendered
read only, there's no way for him to change it. Thus, I am trying to set it
during MyForm.clean() by walking through field errors looking form the
proper error code ('already_approved'), and once found, set it back to its
database value. This way I hope that my ValidationError remains (hence the
warning on the page) while resetting the unchangeable value so at the time
of the next submit it won't cause a problem.

Kind regards,
Gergely

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


Re: Changing a form field's value during cleaning

2015-05-26 Thread Gergely Polonkai
Because it is possible that user A will load the page, and user B will
approve the field.
On 27 May 2015 03:38, "Vijay Khemlani"  wrote:

> If some of the fields are "already approved" and thus they can't be
> edited, why are you rendering those as editable form fields in the first
> place?
>
> On Tue, May 26, 2015 at 9:55 PM, Gergely Polonkai 
> wrote:
>
>> Hello,
>>
>> I'm currently having hard times changing a form field's value from within
>> the form's clean() method. I have already tried setting
>> self.initial[field_id] and manipulating the cleaned data by calling super's
>> clean method, change the required field (cleaned_data[field_id]) and
>> returning the modified dict, but all for no effect. Trying to change
>> self.data threw me an error saying data is immutable. Question is, is it
>> even possible, even if I had to tamper with ”protected/private”
>> properties/methods?
>>
>> Should I be on the wrong track, I try to outline the problem:
>>
>> I have a form with fields added programmatically in __init__(). The value
>> of these fields come from one of my models. It is highly possible that
>> another user puts one of the fields in approved state. If this happens, I
>> don't want the current user to be able to change its value, hence I raise a
>> validation error in the field's validate() method.
>>
>> Now comes the tricky part. In this particular case I want three things to
>> happen:
>>
>> • warn the user about the fact that the field has already been approved
>> (i.e. display the validation error message)
>> • render the input field as read only so the user can't modify it (well,
>> at least not in a trivial way)
>> • and revert the field's value to the one in the database
>>
>> However, in case of a validation error the field's value remains the
>> ”illegal” one the user just entered, and, as the input field is rendered
>> read only, there's no way for him to change it. Thus, I am trying to set it
>> during MyForm.clean() by walking through field errors looking form the
>> proper error code ('already_approved'), and once found, set it back to its
>> database value. This way I hope that my ValidationError remains (hence the
>> warning on the page) while resetting the unchangeable value so at the time
>> of the next submit it won't cause a problem.
>>
>> Kind regards,
>> Gergely
>>
>> --
>> 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/CACczBUK2EEaHBaS7bS%3DJF8Ce35MBkrwugtRvZCJC9E_Ovk2Rqg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CACczBUK2EEaHBaS7bS%3DJF8Ce35MBkrwugtRvZCJC9E_Ovk2Rqg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALn3ei2dZX1KWd-SQ1S9VJ%3DbK8bN9Xj1MKvb7jS-zNyvxSz3Aw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALn3ei2dZX1KWd-SQ1S9VJ%3DbK8bN9Xj1MKvb7jS-zNyvxSz3Aw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUJ32cOC09_oJ8WyZ_VciA9-tQgQ1T2MF4QMCf4QZ5qqnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Changing a form field's value during cleaning

2015-05-27 Thread Gergely Polonkai
Hello,

although the data is from the database, the form itself is not a ModelForm
derivative. Also, this code you suggest will only modify the model handling
part of the form, thus, the user will see a value he entered, although the
database holds a different one.

Best,
Gergely

2015-05-27 9:16 GMT+02:00 Klaas Feenstra :

> Hi,
>
> Maybe you can solve this in the views.py with commit=False
>
> https://docs.djangoproject.com/en/1.8/topics/forms/modelforms/
>
> And from here you can render the new form with the initial data
>
> # Create a form instance with POST data.>>> f = AuthorForm(request.POST)
> # Create, but don't save the new author instance.>>> new_author = 
> f.save(commit=False)
> # Modify the author in some way.>>> new_author.some_field = 'some_value'
> # Save the new instance.>>> new_author.save()
>
>
> On Wed, May 27, 2015 at 2:55 AM, Gergely Polonkai 
> wrote:
>
>> Hello,
>>
>> I'm currently having hard times changing a form field's value from within
>> the form's clean() method. I have already tried setting
>> self.initial[field_id] and manipulating the cleaned data by calling super's
>> clean method, change the required field (cleaned_data[field_id]) and
>> returning the modified dict, but all for no effect. Trying to change
>> self.data threw me an error saying data is immutable. Question is, is it
>> even possible, even if I had to tamper with ”protected/private”
>> properties/methods?
>>
>> Should I be on the wrong track, I try to outline the problem:
>>
>> I have a form with fields added programmatically in __init__(). The value
>> of these fields come from one of my models. It is highly possible that
>> another user puts one of the fields in approved state. If this happens, I
>> don't want the current user to be able to change its value, hence I raise a
>> validation error in the field's validate() method.
>>
>> Now comes the tricky part. In this particular case I want three things to
>> happen:
>>
>> • warn the user about the fact that the field has already been approved
>> (i.e. display the validation error message)
>> • render the input field as read only so the user can't modify it (well,
>> at least not in a trivial way)
>> • and revert the field's value to the one in the database
>>
>> However, in case of a validation error the field's value remains the
>> ”illegal” one the user just entered, and, as the input field is rendered
>> read only, there's no way for him to change it. Thus, I am trying to set it
>> during MyForm.clean() by walking through field errors looking form the
>> proper error code ('already_approved'), and once found, set it back to its
>> database value. This way I hope that my ValidationError remains (hence the
>> warning on the page) while resetting the unchangeable value so at the time
>> of the next submit it won't cause a problem.
>>
>> Kind regards,
>> Gergely
>>
>> --
>> 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/CACczBUK2EEaHBaS7bS%3DJF8Ce35MBkrwugtRvZCJC9E_Ovk2Rqg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CACczBUK2EEaHBaS7bS%3DJF8Ce35MBkrwugtRvZCJC9E_Ovk2Rqg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJcivacMBoNMG4OMwwkg7CDyYzOccXjz-3it5OdD_Au0r0trzg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAJcivacMBoNMG4OMwwkg7CDyYzOccXjz-3it5OdD_Au0r0trzg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBULF%2BDGgK1Rm%2BLJEsujO0ENZ9SDWvpBqZwog9zczG4C3_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Changing a form field's value during cleaning

2015-05-27 Thread Gergely Polonkai
In this case the problem comes if the user also filled the other ~60
non-approved fields and has to start over, which makes this approach a
no-go for me :(

2015-05-27 10:25 GMT+02:00 James Schneider :

> If you are able to catch the validation error, then perhaps you can
> redirect users back to the original form URL (since the form should have
> the new correct values on the next load).
>
> Check out the form.invalid() when working with the form directly or
> form_invalid() for CBV's. If you catch that specific error in
> form_invalid(), you can redirect the users back to the original form URL
> (hopefully with a message explaining what happened), which should display
> the form with the correct new value(s). However, this will also lose any
> other changes the user may have submitted.
>
> Alternatively, you can render the invalid form with updated values using
> the techniques you described, but you may need to do some dictionary
> digging to figure out where to change the value of the form. I'm on my
> phone so I can't check really, but I think changing the 'value' attribute
> on the failed form may work.
>
> Redirecting back to a clean version of the form with an error message is
> probably easiest, and can serve as a stop gap until you figure out the more
> desirable behavior.
>
> -James
> On May 27, 2015 12:47 AM, "Gergely Polonkai"  wrote:
>
>> Hello,
>>
>> although the data is from the database, the form itself is not a
>> ModelForm derivative. Also, this code you suggest will only modify the
>> model handling part of the form, thus, the user will see a value he
>> entered, although the database holds a different one.
>>
>> Best,
>> Gergely
>>
>> 2015-05-27 9:16 GMT+02:00 Klaas Feenstra :
>>
>>> Hi,
>>>
>>> Maybe you can solve this in the views.py with commit=False
>>>
>>> https://docs.djangoproject.com/en/1.8/topics/forms/modelforms/
>>>
>>> And from here you can render the new form with the initial data
>>>
>>> # Create a form instance with POST data.>>> f = AuthorForm(request.POST)
>>> # Create, but don't save the new author instance.>>> new_author = 
>>> f.save(commit=False)
>>> # Modify the author in some way.>>> new_author.some_field = 'some_value'
>>> # Save the new instance.>>> new_author.save()
>>>
>>>
>>> On Wed, May 27, 2015 at 2:55 AM, Gergely Polonkai 
>>> wrote:
>>>
>>>> Hello,
>>>>
>>>> I'm currently having hard times changing a form field's value from
>>>> within the form's clean() method. I have already tried setting
>>>> self.initial[field_id] and manipulating the cleaned data by calling super's
>>>> clean method, change the required field (cleaned_data[field_id]) and
>>>> returning the modified dict, but all for no effect. Trying to change
>>>> self.data threw me an error saying data is immutable. Question is, is it
>>>> even possible, even if I had to tamper with ”protected/private”
>>>> properties/methods?
>>>>
>>>> Should I be on the wrong track, I try to outline the problem:
>>>>
>>>> I have a form with fields added programmatically in __init__(). The
>>>> value of these fields come from one of my models. It is highly possible
>>>> that another user puts one of the fields in approved state. If this
>>>> happens, I don't want the current user to be able to change its value,
>>>> hence I raise a validation error in the field's validate() method.
>>>>
>>>> Now comes the tricky part. In this particular case I want three things
>>>> to happen:
>>>>
>>>> • warn the user about the fact that the field has already been approved
>>>> (i.e. display the validation error message)
>>>> • render the input field as read only so the user can't modify it
>>>> (well, at least not in a trivial way)
>>>> • and revert the field's value to the one in the database
>>>>
>>>> However, in case of a validation error the field's value remains the
>>>> ”illegal” one the user just entered, and, as the input field is rendered
>>>> read only, there's no way for him to change it. Thus, I am trying to set it
>>>> during MyForm.clean() by walking through field errors looking form the
>>>> proper error code ('already_approved'), and once found, set it back to its
>>>

Re: Django Test Coverage

2015-05-28 Thread Gergely Polonkai
Hello,

IMHO it is much better to see the coverage values for everything (even
tests.py). Your actual case, for example, shows that only 98 lines are
running from your 100 lines long tests.py. This may mean that there is a
condition somewhere in your test cases that never evaluates to true.

If you want to see the lines that are not covered, assuming you are using
the “standard” coverage.py tool, you can use the command `coverage html` so
it will generate a HTML version of the coverage info. In case you can’t
access such HTML files, you can use either `coverage report --show-missing`
to see line numbers that are not covered, or `coverage annotate modulename`
to create an annotated version of your module file that will show you
different execution information in your source files.

Kind regards,
Gergely

2015-05-28 13:18 GMT+02:00 Dharmit Shah :

> Hello all,
>
> I have a django app which is full REST APIs created using Django Rest
> Framework.
>
> In tests.py, I am testing fthe APIs using self.client.post and
> self.clilent.get. I use coverage tool to figure out the test coverage
> but it seems to check the coverage in a way I don't really understand.
>
> When I check test coverage for just views.py file, it says 37% and
> when I do that for tests.py, it says 98%.
>
> Is there a way to determine test coverage only by looking at views.py
> and checking how many of the views in it are tested in tests.py?
>
> Or is it an unreasonable expectation?
>
> Regards,
> Dharmit.
>
> --
> 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/CAJQZradk25770YeOGjHT4tBRaJsrexo578pt7xnHFRKZ0hAWFg%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUJZ6r6KEWg8Q7DWWVeC79hYSi9J3L%2BfEUTk87N4APUwnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: CSRF verification failed when I use smart phone

2015-05-31 Thread Gergely Polonkai
I had this error when I had two Django application with the same domain and
both with the same (default) CSRF cookie name. Changing the cookie name to
something different solved the issue.
On 30 May 2015 22:30, "Michael Greer"  wrote:

> We have started seeing this behavior occasionally. No code change in this
> area, but sometimes (esp on phones) the CSRF cookie is wrong.
>
> Our guess is too many cookies on the domain, but it is difficult to prove
> this. Indeed, opening a new browser session resolves it... temporarily.
>
> -Mike
>
> On Tuesday, January 6, 2015 at 3:09:46 AM UTC-6, Sugita Shinsuke wrote:
>>
>> Hello.
>>
>> When I use Django via my smart phone Android and iOS.
>> The error sometimes occurred.
>>
>> Forbidden (403)
>> CSRF verification failed. Request aborted.
>> Help
>> Reason given for failure:
>> CSRF token missing or incorrect.
>>
>> In general, this can occur when there is a genuine Cross Site Request
>> Forgery, or when Django's CSRF mechanism has not been used correctly. For
>> POST forms, you need to ensure:
>> Your browser is accepting cookies.
>> The view function uses RequestContext for the template, instead of
>> Context.
>> In the template, there is a {% csrf_token %} template tag inside each
>> POST form that targets an internal URL.
>> If you are not using CsrfViewMiddleware, then you must use csrf_protect
>> on any views that use the csrf_token template tag, as well as those that
>> accept the POST data.
>> You're seeing the help section of this page because you have DEBUG = True
>> in your Django settings file. Change that to False, and only the initial
>> error message will be displayed.
>> You can customize this page using the CSRF_FAILURE_VIEW setting.
>>
>> I append django.middleware.csrf.CsrfViewMiddleware', of
>> MIDDLEWARE_CLASSES in settings.py
>>
>> I use
>> Python 2.7.5
>> Django 1.6.4
>>
>> Anyone who know this matter, please help.
>>
>>  --
> 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/89d20584-d3bf-4104-b642-0f519c4deb10%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBULNhCDS_w4YvaUb%2Byn0MjEosq6sR6TvmSSYJ7XbxCDHDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: why i failed to install django?

2015-06-02 Thread Gergely Polonkai
This doesn’t seem to be a Django issue to me… Can you install any other
packages with pip?

2015-06-02 20:12 GMT+02:00 mnz hz :

>
>
> IOError: [Errno 22] invalid mode ('wb')
>
>
> detailed error message is as follows:
>
>
> http://pastie.org/10219723#1,21
>
>  --
> 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/ce682fe6-1151-49e3-857d-cb8244491b6d%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBU%2BJCM1PmrPFUrgFVXqVyOY3XCKpvKP4KSGHzRP27HmxRg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to get get-pip.py

2015-06-05 Thread Gergely Polonkai
Hello,

it seems that the user running pip doesn’t have write access to the temp
directory. You should check the permissions of
C:\Users\SteveB\AppData\Local\Temp and its subdirectories as you can see in
the PermissionError line (just change the double backslashes (\\) to single
ones (\).

Is it possible that you run pip with a user other than the one you used to
install Python?

Best,
Gergely

2015-06-05 18:41 GMT+02:00 Steve Burrus :

> well moknte I got good/bad news for you! The GOOD news is that I finally
> got pip installed successfully but the BAD news is that I wasn't able to
> upgrade pip. Here is the resulting error when I tried to do that :
>
> "C:\Users\SteveB>pip install --upgrade pip
> You are using pip version 6.0.8, however version 7.0.3 is available.
> You should consider upgrading via the 'pip install --upgrade pip' command.
> Collecting pip from
> https://pypi.python.org/packages/py2.py3/p/pip/pip-7.0.3-py2.py3-none-any.whl#md5=6950e1d775fea7ea50af690f72589dbd
>   Using cached pip-7.0.3-py2.py3-none-any.whl
> Installing collected packages: pip
>   Found existing installation: pip 6.0.8
> Uninstalling pip-6.0.8:
>   Successfully uninstalled pip-6.0.8
>   Exception:
>   Traceback (most recent call last):
> File "C:\Python34\lib\shutil.py", line 371, in _rmtree_unsafe
> os.unlink(fullname)
>   PermissionError: [WinError 5] Access is denied:
> 'C:\\Users\\SteveB\\AppData\\Local\\Temp\\pip-xfly9791-uninstall\\python34\\scripts\\pip.exe'
>
>   During handling of the above exception, another exception occurred:
>
>   Traceback (most recent call last):
> File "C:\Python34\lib\site-packages\pip\basecommand.py", line 232, in
> main
>   return PREVIOUS_BUILD_DIR_ERROR
> File "C:\Python34\lib\site-packages\pip\commands\install.py", line
> 347, in run
>   if os.path.islink(target_item_dir):
> File "C:\Python34\lib\site-packages\pip\req\req_set.py", line 560, in
> install
>   self.successfully_downloaded.append(req_to_install)
> File "C:\Python34\lib\site-packages\pip\req\req_install.py", line 680,
> in commit_uninstall
> File "C:\Python34\lib\site-packages\pip\req\req_uninstall.py", line
> 153, in commit
>   rmtree(self.save_dir)
> File "C:\Python34\lib\site-packages\pip\_vendor\retrying.py", line 49,
> in wrapped_f
>   return Retrying(*dargs, **dkw).call(f, *args, **kw)
> File "C:\Python34\lib\site-packages\pip\_vendor\retrying.py", line
> 212, in call
>   raise attempt.get()
> File "C:\Python34\lib\site-packages\pip\_vendor\retrying.py", line
> 247, in get
>   six.reraise(self.value[0], self.value[1], self.value[2])
> File "C:\Python34\lib\site-packages\pip\_vendor\six.py", line 659, in
> reraise
>   raise value
> File "C:\Python34\lib\site-packages\pip\_vendor\retrying.py", line
> 200, in call
>   attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
> File "C:\Python34\lib\site-packages\pip\utils\__init__.py", line 61,
> in rmtree
>   try:
> File "C:\Python34\lib\shutil.py", line 478, in rmtree
>   return _rmtree_unsafe(path, onerror)
> File "C:\Python34\lib\shutil.py", line 368, in _rmtree_unsafe
>   _rmtree_unsafe(fullname, onerror)
> File "C:\Python34\lib\shutil.py", line 368, in _rmtree_unsafe
>   _rmtree_unsafe(fullname, onerror)
> File "C:\Python34\lib\shutil.py", line 373, in _rmtree_unsafe
>   onerror(os.unlink, fullname, sys.exc_info())
> File "C:\Python34\lib\site-packages\pip\utils\__init__.py", line 73,
> in rmtree_errorhandler
>   raise
>   PermissionError: [WinError 5] Access is denied:
> 'C:\\Users\\SteveB\\AppData\\Local\\Temp\\pip-xfly9791-uninstall\\python34\\scripts\\pip.exe'
>  "
>
> Now what's wrong?
>
> On Fri, Jun 5, 2015 at 10:51 AM, Steve Burrus 
> wrote:
>
>> Okay Monte I will certsainly "man up" and start over and try to do what
>> you said. Incidentally I have done the "Add python.exe to the PATH" thing
>> that you suggested but it still failed! I have done all of the
>> configuration the right way but I still simply cannot type "pip" [into the
>> command line] and get all of the pip commands.
>>
>> On Thursday, June 4, 2015 at 10:30:36 PM UTC-5, Monte Milanuk wrote:
>>>
>>> Stop.
>>>
>>> Uninstall python (whatever version(s) you have).
>>>
>>> Re-install python (3.4.3), but this time when you get to the screen
>>> telling you what all is going to be installed, scroll down and enable
>>> the last item "Add python.exe to the PATH".
>>>
>>> Python commands (including pip) should work from the command line with
>>> no problem.  I did *exactly* this as a test this afternoon, and told you
>>> so earlier. Quit flailing about and start over.
>>>
>>>
>>>
>>>
>>>
>  --
> 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 dja

Re: how to get get-pip.py

2015-06-05 Thread Gergely Polonkai
It seems the very first thing you should do is make pip (and with that,
Python) work. For this, you may want to go to a Python related mailing
list, although I’m sure there are many overlapping between the Django list
and that one.

2015-06-05 20:05 GMT+02:00 Steve Burrus :

> well tqhat's okay. I was absolutely struggling to get pip installed
> correctly for quite a long time! I need to see more videos on how to start
> to work with Django. You have any tips about t hat?
>
> On Fri, Jun 5, 2015 at 12:43 PM, DHaval Joshi 
> wrote:
>
>> sry dear i don't know about windows installation.
>>
>> On Fri, Jun 5, 2015 at 10:20 PM, Gergely Polonkai 
>> wrote:
>>
>>> Hello,
>>>
>>> it seems that the user running pip doesn’t have write access to the temp
>>> directory. You should check the permissions of
>>> C:\Users\SteveB\AppData\Local\Temp and its subdirectories as you can see in
>>> the PermissionError line (just change the double backslashes (\\) to single
>>> ones (\).
>>>
>>> Is it possible that you run pip with a user other than the one you used
>>> to install Python?
>>>
>>> Best,
>>> Gergely
>>>
>>> 2015-06-05 18:41 GMT+02:00 Steve Burrus :
>>>
>>>> well moknte I got good/bad news for you! The GOOD news is that I
>>>> finally got pip installed successfully but the BAD news is that I wasn't
>>>> able to upgrade pip. Here is the resulting error when I tried to do that :
>>>>
>>>> "C:\Users\SteveB>pip install --upgrade pip
>>>> You are using pip version 6.0.8, however version 7.0.3 is available.
>>>> You should consider upgrading via the 'pip install --upgrade pip'
>>>> command.
>>>> Collecting pip from
>>>> https://pypi.python.org/packages/py2.py3/p/pip/pip-7.0.3-py2.py3-none-any.whl#md5=6950e1d775fea7ea50af690f72589dbd
>>>>   Using cached pip-7.0.3-py2.py3-none-any.whl
>>>> Installing collected packages: pip
>>>>   Found existing installation: pip 6.0.8
>>>> Uninstalling pip-6.0.8:
>>>>   Successfully uninstalled pip-6.0.8
>>>>   Exception:
>>>>   Traceback (most recent call last):
>>>> File "C:\Python34\lib\shutil.py", line 371, in
>>>> _rmtree_unsafe os.unlink(fullname)
>>>>   PermissionError: [WinError 5] Access is denied:
>>>> 'C:\\Users\\SteveB\\AppData\\Local\\Temp\\pip-xfly9791-uninstall\\python34\\scripts\\pip.exe'
>>>>
>>>>   During handling of the above exception, another exception occurred:
>>>>
>>>>   Traceback (most recent call last):
>>>> File "C:\Python34\lib\site-packages\pip\basecommand.py", line 232,
>>>> in main
>>>>   return PREVIOUS_BUILD_DIR_ERROR
>>>> File "C:\Python34\lib\site-packages\pip\commands\install.py", line
>>>> 347, in run
>>>>   if os.path.islink(target_item_dir):
>>>> File "C:\Python34\lib\site-packages\pip\req\req_set.py", line 560,
>>>> in install
>>>>   self.successfully_downloaded.append(req_to_install)
>>>> File "C:\Python34\lib\site-packages\pip\req\req_install.py", line
>>>> 680, in commit_uninstall
>>>> File "C:\Python34\lib\site-packages\pip\req\req_uninstall.py", line
>>>> 153, in commit
>>>>   rmtree(self.save_dir)
>>>> File "C:\Python34\lib\site-packages\pip\_vendor\retrying.py", line
>>>> 49, in wrapped_f
>>>>   return Retrying(*dargs, **dkw).call(f, *args, **kw)
>>>> File "C:\Python34\lib\site-packages\pip\_vendor\retrying.py", line
>>>> 212, in call
>>>>   raise attempt.get()
>>>> File "C:\Python34\lib\site-packages\pip\_vendor\retrying.py", line
>>>> 247, in get
>>>>   six.reraise(self.value[0], self.value[1], self.value[2])
>>>> File "C:\Python34\lib\site-packages\pip\_vendor\six.py", line 659,
>>>> in reraise
>>>>   raise value
>>>> File "C:\Python34\lib\site-packages\pip\_vendor\retrying.py", line
>>>> 200, in call
>>>>   attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
>>>> File "C:\Python34\lib\site-packages\pip\utils\__init__.py", line
>>>> 61, in rmtree
>>>>   try:
>>>> File "C:\Python

Re: how to get get-pip.py

2015-06-05 Thread Gergely Polonkai
So it doesn’t work :) I’m not very familiar with Python on Windows (or
Windows, in general), but this really seems to be a problem related to this.

Have you also checked the permissions on the directory mentioned in the
PermissionDenied message?

2015-06-05 23:53 GMT+02:00 Steve Burrus :

> oh I thought tha t I told you thsat I *was *able to make python/pip work!
> It's just this little thing about not being able to upgrade pip which
> bothers me, just a little bit. and I am not trying to run pip with any
> other User other than myself.
>
> On Fri, Jun 5, 2015 at 1:50 PM, Gergely Polonkai 
> wrote:
>
>> It seems the very first thing you should do is make pip (and with that,
>> Python) work. For this, you may want to go to a Python related mailing
>> list, although I’m sure there are many overlapping between the Django list
>> and that one.
>>
>> 2015-06-05 20:05 GMT+02:00 Steve Burrus :
>>
>>> well tqhat's okay. I was absolutely struggling to get pip installed
>>> correctly for quite a long time! I need to see more videos on how to start
>>> to work with Django. You have any tips about t hat?
>>>
>>> On Fri, Jun 5, 2015 at 12:43 PM, DHaval Joshi 
>>> wrote:
>>>
>>>> sry dear i don't know about windows installation.
>>>>
>>>> On Fri, Jun 5, 2015 at 10:20 PM, Gergely Polonkai 
>>>> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> it seems that the user running pip doesn’t have write access to the
>>>>> temp directory. You should check the permissions of
>>>>> C:\Users\SteveB\AppData\Local\Temp and its subdirectories as you can see 
>>>>> in
>>>>> the PermissionError line (just change the double backslashes (\\) to 
>>>>> single
>>>>> ones (\).
>>>>>
>>>>> Is it possible that you run pip with a user other than the one you
>>>>> used to install Python?
>>>>>
>>>>> Best,
>>>>> Gergely
>>>>>
>>>>> 2015-06-05 18:41 GMT+02:00 Steve Burrus :
>>>>>
>>>>>> well moknte I got good/bad news for you! The GOOD news is that I
>>>>>> finally got pip installed successfully but the BAD news is that I wasn't
>>>>>> able to upgrade pip. Here is the resulting error when I tried to do that 
>>>>>> :
>>>>>>
>>>>>> "C:\Users\SteveB>pip install --upgrade pip
>>>>>> You are using pip version 6.0.8, however version 7.0.3 is available.
>>>>>> You should consider upgrading via the 'pip install --upgrade pip'
>>>>>> command.
>>>>>> Collecting pip from
>>>>>> https://pypi.python.org/packages/py2.py3/p/pip/pip-7.0.3-py2.py3-none-any.whl#md5=6950e1d775fea7ea50af690f72589dbd
>>>>>>   Using cached pip-7.0.3-py2.py3-none-any.whl
>>>>>> Installing collected packages: pip
>>>>>>   Found existing installation: pip 6.0.8
>>>>>> Uninstalling pip-6.0.8:
>>>>>>   Successfully uninstalled pip-6.0.8
>>>>>>   Exception:
>>>>>>   Traceback (most recent call last):
>>>>>> File "C:\Python34\lib\shutil.py", line 371, in
>>>>>> _rmtree_unsafe os.unlink(fullname)
>>>>>>   PermissionError: [WinError 5] Access is denied:
>>>>>> 'C:\\Users\\SteveB\\AppData\\Local\\Temp\\pip-xfly9791-uninstall\\python34\\scripts\\pip.exe'
>>>>>>
>>>>>>   During handling of the above exception, another exception occurred:
>>>>>>
>>>>>>   Traceback (most recent call last):
>>>>>> File "C:\Python34\lib\site-packages\pip\basecommand.py", line
>>>>>> 232, in main
>>>>>>   return PREVIOUS_BUILD_DIR_ERROR
>>>>>> File "C:\Python34\lib\site-packages\pip\commands\install.py",
>>>>>> line 347, in run
>>>>>>   if os.path.islink(target_item_dir):
>>>>>> File "C:\Python34\lib\site-packages\pip\req\req_set.py", line
>>>>>> 560, in install
>>>>>>   self.successfully_downloaded.append(req_to_install)
>>>>>> File "C:\Python34\lib\site-packages\pip\req\req_install.py", line
>>>>>> 680, in commit_uninstall
>>>>>> File "C:\Python34\li

Re: Command line script > Ensure that its module, "models", is located inside an installed app. error

2015-06-07 Thread Gergely Polonkai
Hello,

you should remove the sys.path.append() line, and use from .models import
MyichiTickers.

Also, it seems that you are writing a custom python script instead of
implementing it in your project. If I were you, I would create a
django-admin command, so it would work like

python manage.py historic_data_collector

You can find more info on this at [1]

Best,
Gergely

[1] https://docs.djangoproject.com/en/1.8/howto/custom-management-commands/

2015-06-07 13:01 GMT+02:00 Oscar Buijten :

> Hi There,
>
> For various reasons I recently started efforts to covert an existing .php
> application to pyhton + django.
> There are quite a few scripts that are executed through cron and so from
> the command line while coding.
>
> I did find some info on how to setup the start of the script, but keep
> running into an error I haven't been able to resolve so far.
>
> Using Python 2.7.x and django 1.8.x + postresql
>
> Script is starting with this:
>
> --  snip  --
> import os,sys
> sys.path.append('/home/oscar/django/trading/myichimoku')
> os.environ['DJANGO_SETTINGS_MODULE']='myichimoku.settings'
> from models import MyichiTickers
> --  snip  --
>
> The script lives in /home/oscar/django/trading/myichimoku/data in which
> the models.py lives as well
>
> The error I get:
>
> --  snip  --
> Traceback (most recent call last):
>   File "historic_data_collector.py", line 4, in 
> from models import MyichiTickers
>   File "/home/oscar/django/trading/myichimoku/data/models.py", line 4, in
> 
> class AuthGroup(models.Model):
>   File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py",
> line 131, in __new__
> 'app.' % (new_class.__name__, model_module.__name__)
> django.core.exceptions.ImproperlyConfigured: Unable to detect the app
> label for model "AuthGroup." Ensure that its module, "models", is located
> inside an installed app.
> --  snip  --
>
> AuthGroup is the 1st table class in models.py
>
> My settings.py lives in: /home/oscar/django/trading/myichimoku/myichimoku/
>
> Here a snippet from the file:
> --  snip  --
> # Application definition
>
> INSTALLED_APPS = (
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'data',
> )
> --  snip  --
>
>
> So the question is: how can I ensure to execute this script from the
> command line with something like: python mycoolscript.py ?
>
> Any help greatly appreciated.
>
> Thanks!
> Oscar
>
> --
> 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/e72dbbe3-b6fb-4294-b4bc-04d5881b2f8a%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUJ0_zvgepbwZrRnpVdyCxi6nvB2AWKZbpwkWs-7GB-m5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Command line script > Ensure that its module, "models", is located inside an installed app. error

2015-06-07 Thread Gergely Polonkai
Hello,

Sorry, I forgot that relative imports don’t work in standalone scripts,
just modules. In this case, yes, you should go on with the original import
line of yours, and modify the loading path. However, if you want to use
your models outside of Django, that is 1) pretty much unsupported and 2)
you must initialize your app (I hope someone can point to a document that
shows how; I have no knowledge on this. I guess you will have to mess
around with django.apps).

Well, all this is unless you create a django-admin command, which will do
all this for you (the application/model initialization). When you invoke a
command like “python manage.py migrate”, all your apps in INSTALLED_APPS
get loaded, and thus, initialized. After that, in the command’s handle()
method, you can do whatever you want. Also another thing you win is that
the maintenance scripts will be actually integrated into your application
and you can even write tests for them.

Best,
Gergely

2015-06-07 15:18 GMT+02:00 Oscar Buijten :

> Thanks Gergely! :-)
>
> I followed your suggestions and it does seem to improve behaviour,
> however, I now get a new error...
>
> --  snip  --
> Traceback (most recent call last):
>   File "historic_data_collector.py", line 4, in 
> from .models import MyichiTickers
> ValueError: Attempted relative import in non-package
> --  snip  --
>
> I've done a quick google on it but didn't see anything that would help me
> out.
> Any suggestions?
>
> Also, I had a look at your suggestion to create a django-admin command
> last night (but ran into similar issues).
> Besides a solution in itself would you mind giving some feedback on why
> that would be better? I didn't get that (yet).
>
> FYI: there are several scripts running on regular interval updating data
> in a database that the web application then uses to show to the end user. I
> now just am converting to python/django
>
> Thanks again,
> Oscar
>
>
>
> Le dimanche 7 juin 2015 14:26:39 UTC+2, Oscar Buijten a écrit :
>>
>> Hi There,
>>
>> For various reasons I recently started efforts to covert an existing .php
>> application to pyhton + django.
>> There are quite a few scripts that are executed through cron and so from
>> the command line while coding.
>>
>> I did find some info on how to setup the start of the script, but keep
>> running into an error I haven't been able to resolve so far.
>>
>> Using Python 2.7.x and django 1.8.x + postresql
>>
>> Script is starting with this:
>>
>> --  snip  --
>> import os,sys
>> sys.path.append('/home/oscar/django/trading/myichimoku')
>> os.environ['DJANGO_SETTINGS_MODULE']='myichimoku.settings'
>> from models import MyichiTickers
>> --  snip  --
>>
>> The script lives in /home/oscar/django/trading/myichimoku/data in which
>> the models.py lives as well
>>
>> The error I get:
>>
>> --  snip  --
>> Traceback (most recent call last):
>>   File "historic_data_collector.py", line 4, in 
>> from models import MyichiTickers
>>   File "/home/oscar/django/trading/myichimoku/data/models.py", line 4, in
>> 
>> class AuthGroup(models.Model):
>>   File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py",
>> line 131, in __new__
>> 'app.' % (new_class.__name__, model_module.__name__)
>> django.core.exceptions.ImproperlyConfigured: Unable to detect the app
>> label for model "AuthGroup." Ensure that its module, "models", is located
>> inside an installed app.
>> --  snip  --
>>
>> AuthGroup is the 1st table class in models.py
>>
>> My settings.py lives in: /home/oscar/django/trading/myichimoku/myichimoku/
>>
>> Here a snippet from the file:
>> --  snip  --
>> # Application definition
>>
>> INSTALLED_APPS = (
>> 'django.contrib.admin',
>> 'django.contrib.auth',
>> 'django.contrib.contenttypes',
>> 'django.contrib.sessions',
>> 'django.contrib.messages',
>> 'django.contrib.staticfiles',
>> 'data',
>> )
>> --  snip  --
>>
>>
>> So the question is: how can I ensure to execute this script from the
>> command line with something like: python mycoolscript.py ?
>>
>> Any help greatly appreciated.
>>
>> Thanks!
>> Oscar
>>
>  --
> 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/c1c6c75f-28c1-46b0-9b79-581edd7cd17e%40googlegroups.com
> 

Re: Command line script > Ensure that its module, "models", is located inside an installed app. error

2015-06-08 Thread Gergely Polonkai
Hello,

This SO answer[1] will provide you with decent answer on what this *args
and **kwargs things are. Hope that helps!

Best,
Gergely

[1] http://stackoverflow.com/a/3394898

2015-06-08 15:03 GMT+02:00 felix :

>  El 08/06/15 08:23, Oscar Buijten escribió:
>
>  Just to let you know that I got this snippet working now Gergely :-)
> Thanks again for putting me on the right track.
> What I didn't get though is why I need the " *args, **options".
> I read the doc but didn't grasp the why...
> Cheers,
> Oscar
>
>  I'm a newbie. I guess that *args, **options will keep your script
> working no matter how many positional or keyword arguments your command or
> the base command may have in the future.
>
> Cheers,
> Felix.
>
> --
> 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/557592A0.1060202%40epepm.cupet.cu
> 
> .
>
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUKDuUUKhmZ7f4z-ixAdxSqQZEbuM5-vpxuDA0%3DR%2BWXF2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Simulating REMOTE_USER login with the test server

2015-06-09 Thread Gergely Polonkai
Hello,

I’m about to use the test server with REMOTE_USER based logins. I already
know how to set it up with my Apache based server, but I can see no way of
doing the same with the dev server (manage.py runserver). I have tried
setting the environment variable REMOTE_USER to a desired value, as I saw
some env vars in request.META earlier, but it doesn’t seem to help. Does
anybody know if this is possible, and if so, how?

Best,
Gergely

-- 
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/CACczBU%2BX%2BHESqWb7P17LdmBB%2BysMZFo42ab_AsoerMBELp1_OQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Simulating REMOTE_USER login with the test server

2015-06-10 Thread Gergely Polonkai
That’s exactly what I was doing, just haven’t had the time yet to share my
experience :)

2015-06-10 11:55 GMT+02:00 'Tom Evans' via Django users <
django-users@googlegroups.com>:

> On Tue, Jun 9, 2015 at 10:07 PM, Gergely Polonkai 
> wrote:
> > Hello,
> >
> > I’m about to use the test server with REMOTE_USER based logins. I already
> > know how to set it up with my Apache based server, but I can see no way
> of
> > doing the same with the dev server (manage.py runserver). I have tried
> > setting the environment variable REMOTE_USER to a desired value, as I saw
> > some env vars in request.META earlier, but it doesn’t seem to help. Does
> > anybody know if this is possible, and if so, how?
> >
> > Best,
> > Gergely
> >
>
> Write a piece of custom middleware that is only active with DEBUG=True
> that sets the REMOTE_USER you desire.
>
> Cheers
>
> Tom
>
> --
> 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/CAFHbX1Lv6XyBuj6_Xy%3DGSC3g-tndH77Z9oD3QdPUNHk9PLqLqA%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBU%2Bu_h1d5F2qBYWfvHgB_Tgc2NoDNkcw1WPXs_ww0Y%3DXww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Test cases fail with authentication against REMOTE_USER with normal auth fallback

2015-06-10 Thread Gergely Polonkai
Hello,

I was trying to follow
https://docs.djangoproject.com/en/1.8/howto/auth-remote-user/.

If I enable django.contrib.auth.middleware.RemoteUserMiddleware, even if I
set AUTHENTICATION_BACKEND to contain both RemoteUserBackend and
ModelBackend, my test cases stop working. However, using the runserver
environment, everything looks just fine regardless if I have REMOTE_USER
set (and I get logged in successfully with REMOTE_USER set to the correct
value).

Do I have to change anything in my tests for this to work?

For the record, I use django_webtest for most of my tests.

Best,
Gergely

-- 
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/CACczBUJAoqnEPY4z0yKqHN74fJOxCrrdhb_GtAQY7WTxc%2B3u%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple User Roles design

2015-06-13 Thread Gergely Polonkai
Hello,

if you create groups, you don’t have to create different models for
different roles (well, unless you have different data to store for Students
and Instructors). Just connect the correct User object with the correct
Group.

Another method is to use the Permission handling system of Django, although
it is a bit more complex.

Best,
Gergely

2015-06-13 10:22 GMT+02:00 Frankline :

> *Hi all,*
>
> *I am creating a project that will require two different user roles: An
> Instructor role and a Student role. Both will use a common login form. An
> Instructor can assign a Student to a Course. Both will have access to
> different parts of the system.*
>
> *I wish to know the best way to model this. Currently I'm thinking of the
> following:*
>
> *1) Use a single User model having a user_type field*
>
> *2) Create Instructor and Student model that both inherit from base User
> model.*
>
> *3) Create an Instructor and a Student group and then assign people to the
> correct group based on some value at the time of registration.*
>
> *Is there a better way to handle this apart from the above? What are the
> best practices to follow in this case? Or perhaps add a UserProfile?*
>
> *Regards,*
> *Frankline*
>
>  --
> 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/CAEAUGdXR2n0XR6gV1fMbvHxMLAJryvo7n6gJJOE615z%3DVWwpJQ%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUK11KXp542vqVZLTfPEG9qbcKjjAQVonPNjf4uDaO3VbA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to permissions to a group in Django 1.8?

2015-06-13 Thread Gergely Polonkai
Hello,

as the first step, you may want to look at [1]. Also, there is
django-guardian[2], which may be a bit more appropriate for your situation.

Best,
Gergely

[1]
https://docs.djangoproject.com/en/1.8/topics/auth/default/#topic-authorization
[2] https://django-guardian.readthedocs.org/en/v1.2/

2015-06-13 14:42 GMT+02:00 akshat :

> I have a 'Document' model which has many-to-many relationship with User
> model.There is a separate web page in my project which displays the
> Document instance in a text editor.
>
> Now suppose user who created one document wants to invite other users to
> this document.But he wants to give read-only permission to some and
> read-write permission to others.
>
> How do I implement this permission functionality in Django?How does groups
> and other permissions frameworks work 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 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/5bb18069-5121-4ccf-8093-f70d5acced4e%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUJ5MdCOT7EB-c7jW0hY4Ou_jJrf%3DKQav8_6iEzUpRMM9w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Running DJango with uWSGI with a user that has sudo access?

2015-06-14 Thread Gergely Polonkai
Hello,

the problem of the root access usually comes into play when your site gets
hacked (or if you don't trust the framework written by someone else, which
is not always a bad idea). Up until then, you can safely run your
application under root privileges.

When your site gets hacked, the main goal is to reduce the attacker's
playground. If the attacker gets in with the user's password, it can do
anything. If sudo is configured that it doesn't even ask for a password,
it's ever worse.

All in all, the best thing is to prepare for the worst case scenario.
Assume that the attacker is already on the computer. Make his place as
small as possible.

Best,
Gergely
On 14 Jun 2015 20:50, "Paul Koepke"  wrote:

> I'm running a Django app using uWSGI and nginx. I already saw in the uWSGI
> documentation that I should not run uWSGI as root. But does it matter if
> the user I run uWSGI has sudo access? Should I try to use a user that is
> not a sudoer or does it not really matter?
>
> --
> 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/7b28bd49-a1df-428a-b828-a085662100a1%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBU%2BVwgade0BfxT5SYKO5WyTqA5Dky3SkfsS1Bx7-ekDz%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


ValueError during migrations.RunPython to create OneToOne records in new model

2015-06-17 Thread Gergely Polonkai
Hello,

I have created a new model called Settings, which has a OneToOneField(User,
primary_key=True) field. After the automatically created
migrations.CreateModel() invocation I added a RunPython line that runs this
function:

def create_user_settings(apps, schema_editor):
User = get_user_model()
Settings = apps.get_model('accounts', 'Settings')

for user in User.objects.all():
Settings.objects.get_or_create(user=user) # This is line 13

When running this migration, I get the following error:

Traceback (most recent call last):

  File "manage.py", line 10, in 

execute_from_command_line(sys.argv)

  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/core/management/__init__.py",
line 338, in execute_from_command_line
utility.execute()
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/core/management/__init__.py",
line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/core/management/base.py",
line 390, in run_from_argv
self.execute(*args, **cmd_options)
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/core/management/base.py",
line 441, in execute
output = self.handle(*args, **options)
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
line 221, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/migrations/executor.py",
line 110, in migrate
self.apply_migration(states[migration], migration, fake=fake,
fake_initial=fake_initial)
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/migrations/executor.py",
line 147, in apply_migration
state = migration.apply(state, schema_editor)
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/migrations/migration.py",
line 115, in apply
operation.database_forwards(self.app_label, schema_editor, old_state,
project_state)
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/migrations/operations/special.py",
line 183, in database_forwards
self.code(from_state.apps, schema_editor)
  File "/home/polesz/Projects/dem/accounts/migrations/0003_settings.py",
line 13, in create_user_settings
Settings.objects.get_or_create(user=user)
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/models/manager.py",
line 127, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/models/query.py",
line 405, in get_or_create
return self.get(**lookup), False
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/models/query.py",
line 325, in get
clone = self.filter(*args, **kwargs)
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/models/query.py",
line 679, in filter
return self._filter_or_exclude(False, *args, **kwargs)
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/models/query.py",
line 697, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/models/sql/query.py",
line 1306, in add_q
clause, require_inner = self._add_q(where_part, self.used_aliases)
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/models/sql/query.py",
line 1333, in _add_q
current_negated=current_negated, connector=connector,
allow_joins=allow_joins)
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/models/sql/query.py",
line 1175, in build_filter
self.check_related_objects(field, value, opts)
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/models/sql/query.py",
line 1070, in check_related_objects
self.check_query_object_type(value, opts)
  File
"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/models/sql/query.py",
line 1054, in check_query_object_type
(value, opts.object_name))
ValueError: Cannot query "polesz": Must be "User" instance.

While debugging, it turns out that the value of the user variable is indeed
a User instance. Do I miss some key information here? Maybe apps are not
fully initialized when I run migrations?

Best,
Gergely

-- 
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/CACczBULo9LgrJ-d7AfmGUDN0aV9DRoz4gSRQJGLBQh9-PGmn6A%40

Re: ValueError during migrations.RunPython to create OneToOne records in new model

2015-06-17 Thread Gergely Polonkai
Hello Markus,

thanks for the pointer. Just for the record, if you want to use it in a
reusable app, you should do this:

User = apps.get_model(django.conf.settings.AUTH_USER_MODEL)

Best,
Gergely

2015-06-17 13:14 GMT+02:00 Markus Holtermann :

> Hi Gergely,
>
> You need to use apps.get_model() instead of get_user_model().  See
> https://docs.djangoproject.com/en/1.8/topics/migrations/#data-migrations
>
> /Markus
>
> On June 17, 2015 12:48:48 PM GMT+02:00, Gergely Polonkai <
> gerg...@polonkai.eu> wrote:
> >Hello,
> >
> >I have created a new model called Settings, which has a
> >OneToOneField(User,
> >primary_key=True) field. After the automatically created
> >migrations.CreateModel() invocation I added a RunPython line that runs
> >this
> >function:
> >
> >def create_user_settings(apps, schema_editor):
> >User = get_user_model()
> >Settings = apps.get_model('accounts', 'Settings')
> >
> >for user in User.objects.all():
> >Settings.objects.get_or_create(user=user) # This is line 13
> >
> >When running this migration, I get the following error:
> >
> >Traceback (most recent call last):
> >
> >  File "manage.py", line 10, in 
> >
> >execute_from_command_line(sys.argv)
> >
> >  File
>
> >"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/core/management/__init__.py",
> >line 338, in execute_from_command_line
> >utility.execute()
> >  File
>
> >"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/core/management/__init__.py",
> >line 330, in execute
> >self.fetch_command(subcommand).run_from_argv(self.argv)
> >  File
>
> >"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/core/management/base.py",
> >line 390, in run_from_argv
> >self.execute(*args, **cmd_options)
> >  File
>
> >"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/core/management/base.py",
> >line 441, in execute
> >output = self.handle(*args, **options)
> >  File
>
> >"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
> >line 221, in handle
> >  executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
> >  File
>
> >"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/migrations/executor.py",
> >line 110, in migrate
> >self.apply_migration(states[migration], migration, fake=fake,
> >fake_initial=fake_initial)
> >  File
>
> >"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/migrations/executor.py",
> >line 147, in apply_migration
> >state = migration.apply(state, schema_editor)
> >  File
>
> >"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/migrations/migration.py",
> >line 115, in apply
> >  operation.database_forwards(self.app_label, schema_editor, old_state,
> >project_state)
> >  File
>
> >"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/migrations/operations/special.py",
> >line 183, in database_forwards
> >self.code(from_state.apps, schema_editor)
> > File "/home/polesz/Projects/dem/accounts/migrations/0003_settings.py",
> >line 13, in create_user_settings
> >Settings.objects.get_or_create(user=user)
> >  File
>
> >"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/models/manager.py",
> >line 127, in manager_method
> >return getattr(self.get_queryset(), name)(*args, **kwargs)
> >  File
>
> >"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/models/query.py",
> >line 405, in get_or_create
> >return self.get(**lookup), False
> >  File
>
> >"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/models/query.py",
> >line 325, in get
> >clone = self.filter(*args, **kwargs)
> >  File
>
> >"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/models/query.py",
> >line 679, in filter
> >return self._filter_or_exclude(False, *args, **kwargs)
> >  File
>
> >"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/models/query.py",
> >line 697, in _filter_or_exclude
> >clone.query.add_q(Q(*args, **kwargs))
> >  File
>
> >"/home/polesz/Projects/dem/venv/lib/python2.7/site-packages/django/db/models/sql/query.py"

Re: Atomic block termination question

2015-06-24 Thread Gergely Polonkai
As for me I have a function registered for the post_save signal, so after
saving the 1:1 object gets created. If you don't mind that the 1:1 object
gets created outside of the atomic block, it should work for you, too.
On 24 Jun 2015 10:16, "Mike Dewhirst"  wrote:

> On 24/06/2015 4:43 PM, Mike Dewhirst wrote:
>
>> When saving a model I'm getting a TransactionManagementError - You can't
>> execute queries until the end of the 'atomic' block
>>
>> Ticket #21540 seems fairly explicit at least where Postgres is
>> concerned. TransactionManagementError prevents what I want to do and I'm
>> not a nuclear expert.
>>
>> How do I terminate the save() method code in that atomic block and then
>> immediately execute my queries?
>>
>
> I have implemented a workaround but not sure if it is the best way. Any
> comment appreciated ...
>
> In the model's clean() method I test for self.pk and if true, execute the
> queries which previously caused the problem. This seems to work but hasn't
> had any testing in production.
>
> Thanks again for any ideas
>
> Mike
>
>
>> I need the save() to complete so I can get_or_create some 1:1 records
>> belonging to the model being saved.
>>
>> Thanks
>>
>> Mike
>>
>>
>>
> --
> 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/558A676C.5080202%40dewhirst.com.au
> .
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUK6gLS2%3D0Rts%2Bbo9VXSSjFQHtmv4ZGNpiuLHfodgH7R_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to deploy django 1.8 + python 3.3 on Openshift

2015-06-25 Thread Gergely Polonkai
http://lmgtfy.com/?q=openshift+django+python+3.3

(I didn't put this in the subject to keep the thread intact. Please learn
to ask before you do so)
On 25 Jun 2015 06:23, "Arindam sarkar"  wrote:

>
>
> --
> Regards,
>
> Arindam
>
> Contact no. 08732822385
>
>
>  --
> 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/CAGnF%2BrDsXZyOKQR2MW2P%3DkdyCtdZ0YFoy8oE79oixSN4BELP5A%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBULk-CK-SNDLN7zW8-Q%3DTaiB200-gi0DZEs6L5M11bNrwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django unique email id model

2015-06-27 Thread Gergely Polonkai
Hello,

this depends on a load of things. Which version of Django do you use? Do
you have a custom user model, or you use the built in one?

Best,
Gergely
On 27 Jun 2015 13:47, "Arindam sarkar"  wrote:

> i am just starting with django. I need create a site with signup/sign in .
> i want user to sign up by email id . how do i proced ?
>
> --
> Regards,
>
> Arindam
>
> Contact no. 08732822385
>
>
>  --
> 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/CAGnF%2BrAtSBg8qF_xQA%3Duh%2BZmgp6VEtc_MEhn79%2BDpDK1tjt5LA%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUKHPPB2s-5ZjyHffr2AMnv-bhVXvvfOMP%3DmWvofd8r7vQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can't Start Project.

2015-07-01 Thread Gergely Polonkai
No, Django does that for you. You only have to worry about DB settings if
you want something else like MySQL or Postgres.
On 1 Jul 2015 23:40, "Bill Freeman"  wrote:

> Yes.  syncdb should work, assuming that sqlite is available (I think that
> it's built in in all the python 3.x versions), and assuming that you have a
> correctly configured settings.py (startproject makes one, but you will
> still have things to enter, such as data base configuration info (like the
> file to use to back sqlite), or to edit, such as your timezone.
>
> On Wed, Jul 1, 2015 at 5:35 PM, Steve Burrus 
> wrote:
>
>> no django was not installed so I did a quick "pip install django" and
>> installed django 1.8.2 into my ins tance of virualenv and was [finally]
>> able to connect to the django server. I assume trhat I can easily do the
>> "python manage.py syncdb" to connect to the sqllite3 server?
>>
>>
>> On Wed, Jul 1, 2015 at 3:58 PM, Bill Freeman  wrote:
>>
>>> It sounds like django isn't on your path.  If you are running in a
>>> virtualenv, was django pip installed while running in that same environment?
>>>
>>> On Wed, Jul 1, 2015 at 4:26 PM, Steve Burrus 
>>> wrote:
>>>
 cd to the directory containing manage.py (the project directory), then:
 "python manage.py runserver" Yeah I just now did exact;ly that but STILL
 got the error message : "(steve) C:\Users\SteveB\Desktop\steve\src>python
 manage.py runserver Traceback (most recent call last):  File
 "manage.py", line 8, in  from django.core.management import
 execute_from_command_line ImportError: No module named
 django.core.management" I r enamed my newly created project to "src".


 On Wed, Jul 1, 2015 at 3:14 PM, Bill Freeman  wrote:

> cd to the directory containing manage.py (the project directory), then:
>
>   python manage.py runserver
>
> On Wed, Jul 1, 2015 at 2:04 PM, Steve Burrus 
> wrote:
>
>> well I was able to create a new project earlier however I am now
>> having trouble with starting the django ser ver. when I ran this cpommand
>> "python .\Scripts\django-admin.py runserver" I always get this error
>> message : "python: can't open file '.\Scripts\django-admin.py': [Errno 2]
>> No such file or directory". What's going on for me to get this error?
>>
>> On Wednesday, July 1, 2015 at 10:27:14 AM UTC-5, Steve Burrus wrote:
>>>
>>> I need some help please with  tryiong to start a new Django project.
>>> Here is the error message I always get when I try to do this. can 
>>> someone
>>> help me with this?
>>>
>>> "C:\Users\SteveB\Desktop\steve>.\Scripts\activate
>>> (steve) C:\Users\SteveB\Desktop\steve>python
>>> .\Scripts\django-admin.py startproject proj
>>> python: can't open file '.\Scripts\django-admin.py': [Errno 2] No
>>> such file or directory"
>>>
>>>
>>>
>>>  --
>> 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/db741397-9c7c-4368-805c-07d60d6042bf%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/1wWP0wRstsU/unsubscribe
> .
> To unsubscribe from this group and all its topics, 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/CAB%2BAj0uiQO5Ksjd-xkQ_kVr2SDvNEGM654x0mmEs1gCRW2jmCg%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.
 Vis

Re: Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-16 Thread Gergely Polonkai
You don't need the temporary field.

1) create the "through" model, add it to the migration file
2) migrate all m2m instances (e.g. iterate over all Bereich objects then
iterate through its users, creating a UserBereichAssignment object for each
(all this done in a migrations.RunPython call)
3) change the m2m field by adding the through option, and add this change
to the migrations file.

However, you may want to go with django-guardian and thus, with
object-level permissions instead ;)
On 16 Jul 2015 16:05, "Carsten Fuchs"  wrote:

> Dear Django fellows,
>
> using Django 1.8.3, in a fully migrated app I have a model with a
> many-to-many relationship like this:
>
> from django.db import models
> from django.contrib.auth.models import User
>
> class Bereich(models.Model):
> benutzer = models.ManyToManyField(User)
>
> Now I would like to store some extra information with the relationship
> (e.g. some Booleans that describe what the user is permitted to do with the
> related Bereich object).
> That is, the intended result is planned to look like this:
>
> class Bereich(models.Model):
> benutzer = models.ManyToManyField(User,
> through='UserBereichAssignment')
>
> class UserBereichAssignment(models.Model):
> bereich  = models.ForeignKey(Bereich)
> user = models.ForeignKey(User)
> can_edit = models.BooleanField(verbose_name="can edit?",
> default=True)
>
> However:
>
> $ ./manage.py makemigration # ok, creates a new migrations file
> $ ./manage.py migrate
>
> # ...
> ValueError: Cannot alter field Lori.Bereich.benutzer into
> Lori.Bereich.benutzer - they are not compatible types (you cannot alter to
> or from M2M fields, or add or remove through= on M2M fields)
>
>
> Well, I understand that and also seem to see some of the involved
> problems: For example, how would it make sure that the same database table
> is used for the previous implicit intermediate model and the new
> UserBereichAssignment?
>
> I'm also aware of https://code.djangoproject.com/ticket/23034, but I'm
> not sure what to make of it, or if it is even applicable here.
>
>
> Thus, what would be a good way to proceed?
>
> To the best of my understanding, I could do this manually, that is: create
> an entirely new many-to-many field, e.g.
>
> class Bereich(models.Model):
> benutzer  = models.ManyToManyField(User)# old,
> unchanged
> benutzer_ = models.ManyToManyField(User,
> through='UserBereichAssignment')
>
> then manually migrate the data from "benutzer" to "benutzer_" (possibly
> using a data migration?), and finally remove the old field "benutzer". The
> only downside seems that all dependent code had to be updated from using
> the old name "benutzer" to the new name "benutzer_". (I'm not sure if
> making a migration for renaming the new field name to the old field name is
> possible?)
>
> Alas... are there any viable alternatives to this?
> I'd be very grateful for any hint!   :-)
>
> Best regards,
> Carsten
>
> --
> 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/55A7BA3E.5030105%40cafu.de.
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUKez8kCfMFJgT94P_3bueNrdYck7fCqWQWF6hO_1AtEFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Interfacing Django Project with Python Script

2015-07-17 Thread Gergely Polonkai
I think what you really need is a custom Django management command. You can
take a look at the implementation of createsuperuser, it takes some input
and creates a user based on this info.
On 17 Jul 2015 18:55, "Jake Rudolph"  wrote:

> So basically I have my Django app that takes in information from a user to
> make new objects, and I need to send some of that information to a separate
> script that performs logic and such with that information. When certain
> events occur I need to send information from the script to the database.
>
> On Friday, July 17, 2015 at 5:12:51 AM UTC-7, larry@gmail.com wrote:
>>
>> On Thu, Jul 16, 2015 at 7:44 PM, Jake Rudolph 
>> wrote:
>> > If I have a separate Python script that I want to interact with my
>> Django
>> > project, how do I set them up to communicate?
>>
>> Not 100% sure what you mean. Do you mean you want to have a standalone
>> python script that uses the ORM? I do this all the time. Just import
>> what you need.
>>
>  --
> 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/068b19ed-fdab-430b-8ae6-01cbb92321b7%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBU%2BACc7UeEbdk0FbB6tE80JGwKixv9kKivkKLkz70P%3DAvg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Good practise on Form logic

2015-07-18 Thread Gergely Polonkai
Hello,

whichever fits you. If you always and only do it before saving, you can
integrate it in the form's save() method, for example.

Another thing to consider is, what does some_logic do? If it works only
with the form data (e.g. transposing it somehow, which new data may be used
by others like a view), then it should clearly be part of the form, not the
view.

Best,
Gergely
On 18 Jul 2015 23:09, "Aldo Suarez"  wrote:

> Say for example you have a Form with its validator methods.
> Then, in the view you normally do:
>
> in forms.py,
>
> if form.is_valid():
>> # do some logic / add to database
>> # redirect
>
>
>
> Now: Is it good practise to do that "post-logic" inside Form methods or
> should I do it on the view? i.e.
>
> in views.py,
>
> def some_view(request):
>> if request.method == 'POST':
>> form = SomeForm(request.POST)
>> if form.is_valid():
>> form.some_logic(request.user)
>> # redirect
>> else:
>> form = SomeForm()
>> # render
>
>
> in forms.py,
>
> class SomeForm(forms.Form):
>> def clean(self):
>> # clean data
>> def some_logic(self, user):
>> # some logic w/ cleaned data
>
>  --
> 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/cdb0ae37-7f46-42c0-b99c-f3a641bbad0b%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBULzwe%3DAy8EUPpK4EHHZvZqdGYWgT3jB6ZzhpucyUFnFOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: SHOP APP

2015-07-21 Thread Gergely Polonkai
…anyways, I'm not really sure it can be done in mere 6 hours. Or if so, I
wouldn't dare to deploy it to production :)
On 22 Jul 2015 00:06, "Cesar Mojarro"  wrote:

> hahaha!
> Can you do my homework?
>
> On Tue, Jul 21, 2015 at 4:59 PM, Russell Keith-Magee <
> russ...@keith-magee.com> wrote:
>
>>
>> On Tue, Jul 21, 2015 at 7:11 PM, dravid rahul 
>> wrote:
>>
>>> Hi can anyone please help me with this.. I am newbie to django.
>>>
>>> PLEASE FIND BELOW ATTACHMENT
>>>
>>> Thanks in Advance
>>> Dravid
>>>
>>
>> Dravid - we're not going to do your homework for you. You've been given a
>> task for assessment purposes - the whole point is that you do the work
>> yourself.
>>
>> We're happy to answer questions, but they need to be specific questions
>> about usage, not "can you do this for me".
>>
>> Yours,
>> Russ Magee %-)
>>
>>
>>  --
>> 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/CAJxq84-tBeir0qSbARb0Djg%3D%2BsZoM%2BXK6rat85e22D%3DtZ00Liw%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHXGZtqGTZt33HBH-GAY84X4EStrb4Ts3-iujA96YGGXXit_sQ%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUJqX1_t-Va2JJ5ty15%2B-YLSqVycXWBzhPxuTNAibfV1OQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-23 Thread Gergely Polonkai
Hello,

I'm sorry, I was not around my mailbox lately.

Yes, you are right, my attempt is not the solution to your problem; it
seems that this m2m field really cannot be modified like this. With some
slight modifications, though, it may be.

1) create the through table
2) migrate data with RunPython — if you want to be portable, stay with
RunPython instead of RunSQL
3) delete the ManyToManyField
4) recreate the ManyToManyField with the through option

All this can (and I think, should) go into the same migration file.
Meanwhile it might worth a question to the devs (or a more thorough search
on the topic) to understand why you can't switch from a simple m2m field to
one with a through option.

Best,
Gergely
On 23 Jul 2015 19:08, "Carsten Fuchs"  wrote:

> Hi Carl,
>
> Am 23.07.2015 um 18:28 schrieb Carl Meyer:
>
>> Overall I think it might be simpler to go with your initial approach. I'd
>> first rename
>> the old field to some other temporary name (you don't have to update any
>> other code to
>> use this name, as you'll commit all of these migrations in one commit, so
>> nothing but
>> the following data migration ever needs to know anything about this
>> temporary name),
>>
>
> Thanks for clarifying the details regarding renaming! With this, this is
> the approach that I feel the most comfortable with and will try now.
>
> Overall, many thanks for your thoughts and your detailed reply, it's very
> much appreciated and helps a lot!
>
> Best regards,
> Carsten
>
> --
> 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/55B11F7B.1010805%40cafu.de.
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBU%2BYcmaxdqr7q-i%3DY1Xe3U%2BE0BqUF%2BqbBWFhthQoWFOg7w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django : DRF Token based Authentication VS JSON Web Token

2015-07-23 Thread Gergely Polonkai
Hello,

after a quick read I cannot find any essential differences between the two,
in regards of authentication. JWT, however, is much more fine grained and
has a bunch of token manipulation options.

Best,
Gergely
On 24 Jul 2015 03:01, "Ankit Agrawal"  wrote:

>
>Hi everyone,
>
>
> I am building a real world application where users will access the app
> primarily from Android, iOS devices as well as Desktops.
>
> From my elementary research, I have realized that token based
> authentication mechanism is more better and elegant for client-server
> models as compared to session based authentication.
>
>
> In Django, I have found two popular ways to do this -
>
>1.
>
> http://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication
>2. http://getblimp.github.io/django-rest-framework-jwt/
>
> From what I understood, option 2] is an extension of 1] except that the
> Token is in the form of JSON(serialized). I would like to understand what
> other differences there are between option 1] and 2] and the
> advantages/disadvantages of choosing either.
>
> --
> 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/11204a7d-a582-40bd-a9ba-e06abe23afff%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBU%2BOuayzoNLSX%2BQTbCdXBT0xsUzb%3DCRXh%3DyCzj%2BF4yvWZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Model opinnions

2015-07-25 Thread Gergely Polonkai
MEDIA_URL is a prefix that you will put in front of the URL media files.
E.g. you set your webserver to load such files under the /media/ URL, like
www.example.com/media/my-video.webm. Using different storage backends, like
an Amazon S3 bucket, you may want to set this to the bucket's URL.

However, you can even outsource avatar handling to some provider, like
Gravatar (which is a totally different topic, though).
I'm doing a little app that consists of a web page were users submits their
jokes (https://github.com/RompePC/django-muro_humoristas/tree/feature). I
had finished the models (a little overview would help), but I have one
question.

I want to use an avatar field for the users: however, I don't understand
well for what is *MEDIA_URL* (also, I would want to know where you would
put your *MEDIA_ROOT*, in a folder of the app, or in a directory as one
that gives the example
https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-MEDIA_ROOT).

Thanks (and sorry if anyone doesn't understand spanish hehe).

-- 
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/fddd7d84-04d3-4e88-ab8c-a75fb5b4e673%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBU%2BB6OVG%3DUQ03Fh1BBx7Z2C2tgQiwOL%3D036wV_OYvh%2BtQg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Model opinnions

2015-07-25 Thread Gergely Polonkai
Do you save your avatar images there? Do you prepend MEDIA_URL to the
avatar's src=""? How do you display the image by the way?

These are the quick questions that came into my mind without knowing your
setup…
On 25 Jul 2015 22:59,  wrote:

> Nah, I just want to have an avatar inside, to get easy.
>
> And I tried the media docs a few hours ago, but for some reason it doesn't
> work. I've to set specific URL in *urls.py* of the app? (Also notice that
> I use another folder inside media, but I don't think that's the problem).
>
> El viernes, 24 de julio de 2015, 13:47:26 (UTC+2), durir...@gmail.com
> escribió:
>>
>> I'm doing a little app that consists of a web page were users submits
>> their jokes (
>> https://github.com/RompePC/django-muro_humoristas/tree/feature). I had
>> finished the models (a little overview would help), but I have one question.
>>
>> I want to use an avatar field for the users: however, I don't understand
>> well for what is *MEDIA_URL* (also, I would want to know where you would
>> put your *MEDIA_ROOT*, in a folder of the app, or in a directory as one
>> that gives the example
>> https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-MEDIA_ROOT
>> ).
>>
>> Thanks (and sorry if anyone doesn't understand spanish hehe).
>>
>  --
> 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/d1078810-e3b2-46e6-b6ca-15992d1f6ada%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUJgv2mbHtFuSh7CJpcueqRs-2y8LvhhZHvkAGF4DvmpFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Model opinnions

2015-07-26 Thread Gergely Polonkai
It should, yes. But instead hardcoding /media in your templates, use {{
MEDIA_URL }}
On 26 Jul 2015 11:57,  wrote:

> Yeah, there is a test image to do the work. But I'm not using HTML
> elements to see it: I'm trying to directly see it with the URL, like when
> you open a Twitter image in a new tab.
>
> About the setup...
> MEDIA_ROOT = os.path.join(BASE_DIR, '/media/')
> MEDIA_URL = '/media/'
> So *localhost:8000/media/images/avatar.jpg* would work, isn't it?
>
>
> El sábado, 25 de julio de 2015, 23:14:58 (UTC+2), Gergely Polonkai
> escribió:
>>
>> Do you save your avatar images there? Do you prepend MEDIA_URL to the
>> avatar's src=""? How do you display the image by the way?
>>
>> These are the quick questions that came into my mind without knowing your
>> setup…
>> On 25 Jul 2015 22:59,  wrote:
>>
>>> Nah, I just want to have an avatar inside, to get easy.
>>>
>>> And I tried the media docs a few hours ago, but for some reason it
>>> doesn't work. I've to set specific URL in *urls.py* of the app? (Also
>>> notice that I use another folder inside media, but I don't think that's the
>>> problem).
>>>
>>> El viernes, 24 de julio de 2015, 13:47:26 (UTC+2), durir...@gmail.com
>>> escribió:
>>>>
>>>> I'm doing a little app that consists of a web page were users submits
>>>> their jokes (
>>>> https://github.com/RompePC/django-muro_humoristas/tree/feature). I had
>>>> finished the models (a little overview would help), but I have one 
>>>> question.
>>>>
>>>> I want to use an avatar field for the users: however, I don't
>>>> understand well for what is *MEDIA_URL* (also, I would want to know
>>>> where you would put your *MEDIA_ROOT*, in a folder of the app, or in a
>>>> directory as one that gives the example
>>>> https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-MEDIA_ROOT
>>>> ).
>>>>
>>>> Thanks (and sorry if anyone doesn't understand spanish hehe).
>>>>
>>>  --
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@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/d1078810-e3b2-46e6-b6ca-15992d1f6ada%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/d1078810-e3b2-46e6-b6ca-15992d1f6ada%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUL17Vudf_pFn4s7UKct7g9%2BvfCn3H4GfwhON5p9RrDeLg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using django login functionality in a non django app

2016-04-25 Thread Gergely Polonkai
Hello,

this all depends on how this Qt app communicates with the other end (server
side). Does it offer *any* kind of authentication/authorization? If so,
look for ways to integrate it with Django. If not, you are screwed anyway
(from security point of view), because even if your app pops up a login
screen, there can (and will) be ways to get around it.

Best,
Gergely
On Apr 25, 2016 22:37, "Larry Martell"  wrote:

> We have an existing django app with login, change password, and forgot
> password functionality.
>
> Then we have this other app built with the falcon framework. The
> client side of that is C++/Qt. That app has no login functionality -
> you bring it up and you're in. We would like to somehow use the login
> functionality of the django app in the falcon app. Is that even
> possible? I was thinking that in the Qt app I could bring up the
> django login page by invoking the URL for that app. But once they log
> in, how could I get control back to the Qt app and not have it proceed
> to the django app?
>
> Does this even make any sense? Has anyone ever done anything like this?
>
> --
> 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/CACwCsY4vgxwa6xCyem%3DG_OusAAfKcx5n-mixERNFDBdFknisoA%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/CACczBUJBXK-Y2Z8_VtidiTNpuNUZXi7hCruVTfx72cPDc87m9g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using django login functionality in a non django app

2016-04-25 Thread Gergely Polonkai
Now I somewhat understand what falcon is, I suggest that you simply
implement auth on you web app (it seems to me there is none or little right
now. Of course, you don't have to protect all iour views, or you may want
to display a different dataset, but that's another topic.

When that is done, you have to do two things in your Qt app. First, make
sure that when the server says that you are not authorized, pop up a login
window. After a successful login, store the user's credentials for later
use. What type of authentication to use and what to store is up to your
decision: HTTP Basic (store user/password), HTTP session (store the session
cookie) or token (store the token) based auths are the most common examples.

Best,
Gergely
On Apr 26, 2016 00:09, "Larry Martell"  wrote:

> The Qt app talks to the server with web requests routed to python code
> by falcon. It currently has no authentication/authorization of any
> kind. It's not a web app, you can't just navigate to any page, you can
> only get to parts of the app the code lets you get to.
>
> The way I envision it (if possible) is that I would have a decorator
> just like @login_required, and if that is called and the user is not
> logged in, it would invoke the django login page - just like it works
> in django. I think I can do most of this, the part I am unclear on is
> how I get control from the django login page back to the Qt app.
>
> On Mon, Apr 25, 2016 at 5:26 PM, Gergely Polonkai 
> wrote:
> > Hello,
> >
> > this all depends on how this Qt app communicates with the other end
> (server
> > side). Does it offer *any* kind of authentication/authorization? If so,
> look
> > for ways to integrate it with Django. If not, you are screwed anyway
> (from
> > security point of view), because even if your app pops up a login screen,
> > there can (and will) be ways to get around it.
> >
> > Best,
> > Gergely
> >
> > On Apr 25, 2016 22:37, "Larry Martell"  wrote:
> >>
> >> We have an existing django app with login, change password, and forgot
> >> password functionality.
> >>
> >> Then we have this other app built with the falcon framework. The
> >> client side of that is C++/Qt. That app has no login functionality -
> >> you bring it up and you're in. We would like to somehow use the login
> >> functionality of the django app in the falcon app. Is that even
> >> possible? I was thinking that in the Qt app I could bring up the
> >> django login page by invoking the URL for that app. But once they log
> >> in, how could I get control back to the Qt app and not have it proceed
> >> to the django app?
> >>
> >> Does this even make any sense? Has anyone ever done anything like this?
>
> --
> 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/CACwCsY5NrpmqBKjEcrvFEFLKiz%3D0DyL4oGueUKDvb37wZTO6Gg%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/CACczBU%2BbBHCzn-U_gEmoYFF%2BVz8vQNkhnMiGp-mv4Dn7_5BmJw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using django login functionality in a non django app

2016-04-26 Thread Gergely Polonkai
That’s not a big issue if you really communicate with Django via a
web-based API. If the user can’t log in, you can simply redirect them to a
web page. I don’t see the need for user admin functions, though.



Gergely Polonkai
[image: https://]about.me/gergely.polonkai
<https://about.me/gergely.polonkai?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>

2016-04-26 13:10 GMT+02:00 Larry Martell :

> Well, the issue with simply implementing auth, is that we'd need to
> not only implement login, which is easy, but also forgot password, and
> all the user admin functions. Since we have that already with django I
> want to leverage that and not reinvent the wheel.
>
> On Tue, Apr 26, 2016 at 2:29 AM, Gergely Polonkai 
> wrote:
> > Now I somewhat understand what falcon is, I suggest that you simply
> > implement auth on you web app (it seems to me there is none or little
> right
> > now. Of course, you don't have to protect all iour views, or you may
> want to
> > display a different dataset, but that's another topic.
> >
> > When that is done, you have to do two things in your Qt app. First, make
> > sure that when the server says that you are not authorized, pop up a
> login
> > window. After a successful login, store the user's credentials for later
> > use. What type of authentication to use and what to store is up to your
> > decision: HTTP Basic (store user/password), HTTP session (store the
> session
> > cookie) or token (store the token) based auths are the most common
> examples.
> >
> > Best,
> > Gergely
> >
> > On Apr 26, 2016 00:09, "Larry Martell"  wrote:
> >>
> >> The Qt app talks to the server with web requests routed to python code
> >> by falcon. It currently has no authentication/authorization of any
> >> kind. It's not a web app, you can't just navigate to any page, you can
> >> only get to parts of the app the code lets you get to.
> >>
> >> The way I envision it (if possible) is that I would have a decorator
> >> just like @login_required, and if that is called and the user is not
> >> logged in, it would invoke the django login page - just like it works
> >> in django. I think I can do most of this, the part I am unclear on is
> >> how I get control from the django login page back to the Qt app.
> >>
> >> On Mon, Apr 25, 2016 at 5:26 PM, Gergely Polonkai 
> >> wrote:
> >> > Hello,
> >> >
> >> > this all depends on how this Qt app communicates with the other end
> >> > (server
> >> > side). Does it offer *any* kind of authentication/authorization? If
> so,
> >> > look
> >> > for ways to integrate it with Django. If not, you are screwed anyway
> >> > (from
> >> > security point of view), because even if your app pops up a login
> >> > screen,
> >> > there can (and will) be ways to get around it.
> >> >
> >> > Best,
> >> > Gergely
> >> >
> >> > On Apr 25, 2016 22:37, "Larry Martell" 
> wrote:
> >> >>
> >> >> We have an existing django app with login, change password, and
> forgot
> >> >> password functionality.
> >> >>
> >> >> Then we have this other app built with the falcon framework. The
> >> >> client side of that is C++/Qt. That app has no login functionality -
> >> >> you bring it up and you're in. We would like to somehow use the login
> >> >> functionality of the django app in the falcon app. Is that even
> >> >> possible? I was thinking that in the Qt app I could bring up the
> >> >> django login page by invoking the URL for that app. But once they log
> >> >> in, how could I get control back to the Qt app and not have it
> proceed
> >> >> to the django app?
> >> >>
> >> >> Does this even make any sense? Has anyone ever done anything like
> this?
>
> --
> 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/CACwCsY6_P7B7PZK6PRCt%3D2m0JyQ%2BejcMLp-1Q%2B7C2N-5rfyxZg%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/CACczBUJF7654A-dgJ5-JwYsi_WXdPnusnknT83iRqgT59iw9XQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using django login functionality in a non django app

2016-04-26 Thread Gergely Polonkai
That means you have to be able to do it via the API. The other solution is
to pop up a web view for these tasks. However, we are moving out from
Django field here, as this is getting more and more a falcon/UX-related
question.



Gergely Polonkai
[image: https://]about.me/gergely.polonkai
<https://about.me/gergely.polonkai?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>

2016-04-26 14:19 GMT+02:00 Larry Martell :

> I need to support create user, change password, delete user and forgot
> password.
>
> On Tue, Apr 26, 2016 at 7:32 AM, Gergely Polonkai 
> wrote:
> >
> >
> > That’s not a big issue if you really communicate with Django via a
> web-based API. If the user can’t log in, you can simply redirect them to a
> web page. I don’t see the need for user admin functions, though.
> >
> >
> > Gergely Polonkai
> > about.me/gergely.polonkai
> >
> > 2016-04-26 13:10 GMT+02:00 Larry Martell :
> >>
> >> Well, the issue with simply implementing auth, is that we'd need to
> >> not only implement login, which is easy, but also forgot password, and
> >> all the user admin functions. Since we have that already with django I
> >> want to leverage that and not reinvent the wheel.
> >>
> >> On Tue, Apr 26, 2016 at 2:29 AM, Gergely Polonkai 
> wrote:
> >> > Now I somewhat understand what falcon is, I suggest that you simply
> >> > implement auth on you web app (it seems to me there is none or little
> right
> >> > now. Of course, you don't have to protect all iour views, or you may
> want to
> >> > display a different dataset, but that's another topic.
> >> >
> >> > When that is done, you have to do two things in your Qt app. First,
> make
> >> > sure that when the server says that you are not authorized, pop up a
> login
> >> > window. After a successful login, store the user's credentials for
> later
> >> > use. What type of authentication to use and what to store is up to
> your
> >> > decision: HTTP Basic (store user/password), HTTP session (store the
> session
> >> > cookie) or token (store the token) based auths are the most common
> examples.
> >> >
> >> > Best,
> >> > Gergely
> >> >
> >> > On Apr 26, 2016 00:09, "Larry Martell" 
> wrote:
> >> >>
> >> >> The Qt app talks to the server with web requests routed to python
> code
> >> >> by falcon. It currently has no authentication/authorization of any
> >> >> kind. It's not a web app, you can't just navigate to any page, you
> can
> >> >> only get to parts of the app the code lets you get to.
> >> >>
> >> >> The way I envision it (if possible) is that I would have a decorator
> >> >> just like @login_required, and if that is called and the user is not
> >> >> logged in, it would invoke the django login page - just like it works
> >> >> in django. I think I can do most of this, the part I am unclear on is
> >> >> how I get control from the django login page back to the Qt app.
> >> >>
> >> >> On Mon, Apr 25, 2016 at 5:26 PM, Gergely Polonkai <
> gerg...@polonkai.eu>
> >> >> wrote:
> >> >> > Hello,
> >> >> >
> >> >> > this all depends on how this Qt app communicates with the other end
> >> >> > (server
> >> >> > side). Does it offer *any* kind of authentication/authorization?
> If so,
> >> >> > look
> >> >> > for ways to integrate it with Django. If not, you are screwed
> anyway
> >> >> > (from
> >> >> > security point of view), because even if your app pops up a login
> >> >> > screen,
> >> >> > there can (and will) be ways to get around it.
> >> >> >
> >> >> > Best,
> >> >> > Gergely
> >> >> >
> >> >> > On Apr 25, 2016 22:37, "Larry Martell" 
> wrote:
> >> >> >>
> >> >> >> We have an existing django app with login, change password, and
> forgot
> >> >> >> password functionality.
> >> >> >>
> >> >> >> Then we have this other app built with the falcon framework. The
> >> >> >> client side of that is C++/Qt. That app has no login
> functionality -
> >> >&g

Re: Using django login functionality in a non django app

2016-04-27 Thread Gergely Polonkai
I would create a separate view for this, like /falcon_login/, which could
give you a plain text result. But that’s totally up to you.



Gergely Polonkai
[image: https://]about.me/gergely.polonkai
<https://about.me/gergely.polonkai?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>

2016-04-27 16:57 GMT+02:00 Larry Martell :

> Well, not really. I have managed to invoke my django login screen from
> my Qt app, but after I log in, of course my django app comes up.
>
> What I would like is to pass in some parameter to the login screen
> (which is easy), and then have my django app detect that and after
> successfully or unsuccessfully logging in, return a token or error
> code to the Qt app and not bring up the django app. But I'm not sure
> how to do that.
>
> On Tue, Apr 26, 2016 at 9:27 AM, Gergely Polonkai 
> wrote:
> >
> > That means you have to be able to do it via the API. The other solution
> is to pop up a web view for these tasks. However, we are moving out from
> Django field here, as this is getting more and more a falcon/UX-related
> question.
> >
> >
> > Gergely Polonkai
> > about.me/gergely.polonkai
> >
> > 2016-04-26 14:19 GMT+02:00 Larry Martell :
> >>
> >> I need to support create user, change password, delete user and forgot
> password.
> >>
> >> On Tue, Apr 26, 2016 at 7:32 AM, Gergely Polonkai 
> wrote:
> >> >
> >> >
> >> > That’s not a big issue if you really communicate with Django via a
> web-based API. If the user can’t log in, you can simply redirect them to a
> web page. I don’t see the need for user admin functions, though.
> >> >
> >> >
> >> > Gergely Polonkai
> >> > about.me/gergely.polonkai
> >> >
> >> > 2016-04-26 13:10 GMT+02:00 Larry Martell :
> >> >>
> >> >> Well, the issue with simply implementing auth, is that we'd need to
> >> >> not only implement login, which is easy, but also forgot password,
> and
> >> >> all the user admin functions. Since we have that already with django
> I
> >> >> want to leverage that and not reinvent the wheel.
> >> >>
> >> >> On Tue, Apr 26, 2016 at 2:29 AM, Gergely Polonkai <
> gerg...@polonkai.eu> wrote:
> >> >> > Now I somewhat understand what falcon is, I suggest that you simply
> >> >> > implement auth on you web app (it seems to me there is none or
> little right
> >> >> > now. Of course, you don't have to protect all iour views, or you
> may want to
> >> >> > display a different dataset, but that's another topic.
> >> >> >
> >> >> > When that is done, you have to do two things in your Qt app.
> First, make
> >> >> > sure that when the server says that you are not authorized, pop up
> a login
> >> >> > window. After a successful login, store the user's credentials for
> later
> >> >> > use. What type of authentication to use and what to store is up to
> your
> >> >> > decision: HTTP Basic (store user/password), HTTP session (store
> the session
> >> >> > cookie) or token (store the token) based auths are the most common
> examples.
> >> >> >
> >> >> > Best,
> >> >> > Gergely
> >> >> >
> >> >> > On Apr 26, 2016 00:09, "Larry Martell" 
> wrote:
> >> >> >>
> >> >> >> The Qt app talks to the server with web requests routed to python
> code
> >> >> >> by falcon. It currently has no authentication/authorization of any
> >> >> >> kind. It's not a web app, you can't just navigate to any page,
> you can
> >> >> >> only get to parts of the app the code lets you get to.
> >> >> >>
> >> >> >> The way I envision it (if possible) is that I would have a
> decorator
> >> >> >> just like @login_required, and if that is called and the user is
> not
> >> >> >> logged in, it would invoke the django login page - just like it
> works
> >> >> >> in django. I think I can do most of this, the part I am unclear
> on is
> >> >> >> how I get control from the django login page back to the Qt app.
> >> >> >>
> >> >> >> On Mon, Apr 25, 2016 at 5:26 PM, Gergely Polonkai <
> gerg...@polonkai.eu>
> >>

Re: Completed form for an authenticated user

2016-04-27 Thread Gergely Polonkai
It is indeed unclear, what you want to do. How I understood it:

show a bunch of fields to the user that they can fill with data
then, they press the Save button, and the data gets into the database (or
whatever)
then, you want to show the same fields, filled with the data that the user
just entered

Is this it?

Also, have you gone through the tutorial? If not, I strongly suggest to to
so. It will clear a lot of things both about Django and the web in general.

Best,
Gergely



Gergely Polonkai
[image: https://]about.me/gergely.polonkai
<https://about.me/gergely.polonkai?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>

2016-04-27 19:13 GMT+02:00 Said Akhmedbayev :

> Let's say, for example, I have a reusable form. An authenticated user
> fills out this form and saves it. How then, I can show to the user a page
> with the complete form?
>
> Sorry, for not being able to explain the question clearly, I am new to
> django and to the web development in general.
>
> --
> 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/4165af84-44ec-4494-8613-8396cc6d2e0b%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/4165af84-44ec-4494-8613-8396cc6d2e0b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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/CACczBUL_JRtrkzPq7Mjb_NQn9QpSnYFAYB907MbM1a2C_qiePw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Nagios plugins for Monitoring Django Apps

2016-04-27 Thread Gergely Polonkai
Hello,

I don’t know of any built-in metrics in Django that you can monitor. If you
write some for your apps, you could also write some monitoring scripts, too
(probably in the form of a management command).

Best,
Gergely



Gergely Polonkai
[image: https://]about.me/gergely.polonkai
<https://about.me/gergely.polonkai?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>

2016-04-27 22:42 GMT+02:00 Keir W :

> Does anyone have any tips on monitoring the health & status of a django
> app, possibly with the use of a Nagios plugin?
>
> I am using check_log to grep out any errors from the apache error log file
> (when using mod_wsgi) but wondered if I was missing a trick and someone had
> something better to try.
>
> Ta.
>
> --
> 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/12b0d8a7-ceb6-4a9f-a17d-3f05ee9aa2aa%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/12b0d8a7-ceb6-4a9f-a17d-3f05ee9aa2aa%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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/CACczBUJq8i6qJfA0zLLw-72RU%2BjPdDZm1RrmOGXXuiS%3Dzd_dYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: What is completed listing all formaters (fakers, providers) in FactoryBoy?

2016-04-30 Thread Gergely Polonkai
Looking at FactoryBoy’s documentation, it doesn’t seem you can use these;
for example, slug is never mentioned in the documentation. What exactly do
you want to achieve? Are you sure it’s FactoryBoy you are looking for?



Gergely Polonkai
[image: https://]about.me/gergely.polonkai
<https://about.me/gergely.polonkai?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>

2016-04-30 10:11 GMT+02:00 Seti Volkylany :

>
> I mean the factory.Faker('*name*', locale='en'), and
>
> I found slug, name, first_name, last_name, time, date, url, but I am don`t
> found all list in Web and factoryboy`s documentation.
>
> May anyone known?
>
> Thanks.
>
> --
> 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/787d683b-cb31-432e-ac34-a480d5d4fda2%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/787d683b-cb31-432e-ac34-a480d5d4fda2%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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/CACczBULd30C0o8ywkSFJeaPwL_XCVGPz_4aBab_-xFq1h2PtGQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help Replicating a Django App Repo

2016-05-08 Thread Gergely Polonkai
Hello,

1. Clone the repo (success)
2. Install pip requirements (mention using virtualenv, but don't make it a
requirement; pip install -r requirements.txt in a venv succeeded)
3. Set the SECRET_KEY environment variable (I think you shouldn't make
creating secret.sh a requirement, just suggest it; setting env variables in
a production environment may be very different, like editing the server's
configuration files)
4. Set up your database and set the password (where? In settings.py?
There's no env variable for that here, and if you don't run PgSQL locally,
it is very likely you *will* have a password)
4. Run python manage.py migrate (succeeded both with SQLite3 and PostgreSQL)

All in all: works for me ☺

One suggestion: unless you do some raw SQL magic, you should not make a
specific database a hard requirement. Your app seems to work well with
SQLite (long time performance is a different story, though).

Best wishes!

Gergely

PS: add some tests. python manage.py test feels lonely without them 😉
On May 8, 2016 00:28, "Erin A"  wrote:

> Hello,
>
> I am a junior software engineer and am quite new to Django. I built this
> app  and am working on a
> README to explain to others how to fork, clone and setup the app on their
> own machines. I've gotten stuck while trying to re-create the steps.
>
> This is the order in which I've drawn up the steps:
>
> 1. Fork and clone the repo
> 2. Source a virtual environment
> 3. Pip install requirements.txt
> 4. Obtain access_token and secret_key and store in secrets.sh
> 5. Setup a Postgres DB, create user & database
>
> This is where I get stuck.
>
> I tried migrating the app but there are no migrations to apply.
> I tried 'django-admin startproject ig_miner_app . but am getting this
> error code:
>
> "CommandError:
> /Users/Erin/Desktop/CodeByEAllard/project/instagram_miner/manage.py already
> exists, overlaying a project or app into an existing directory won't
> replace conflicting files"
>
> If I can get this sorted out, I should just be able to run the server like
> normal, right?
>
> I'm sure I'm missing something (or many things) but don't know what they
> are. Does any have suggestions for how to get the server to run?
>
> Thank you!
>
> Erin Allard
>
> --
> 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/83e916c1-cf32-4e95-83b5-1d5da686bca0%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/CACczBUKu1r9EpAarL%3D-T8Ty4K8VszfFnFdOh5UKOfcjuBUJ-SQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ubuntu+nginx+django urlpatterns 404 not found

2016-05-08 Thread Gergely Polonkai
What do you mean it doesn't work? What error message you get? Are you sure
it is provided by Django and not the webserver?

Also, GMail is marking your message as a possible malware; consider pasting
your urls.py inline instead of an attachment.
On May 8, 2016 15:39, "minom du"  wrote:

> Hello ,every body.
> attachment is my code
>
> i set the urls.py below
> urlpatterns += patterns('bullet.views.noticeview',
> (r'^$', 'notice'),
> (r'^board', 'board'),
> )
>
> the urlpatterns ^$ work fine
> but ^board not work ,it show 404 not found
>
> i have some code like this but work on windows+apache
> it work fine
>
> now i move it to ubuntu+nginx
> then it not work
>
> anyone can tell me how fix it ,please
> thank you very much
>
> --
> 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/48902712-26b6-4f3a-b465-ab4699f4dbfb%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/CACczBULjH3QfyWGUVU7JqNxdkT71rp4yKKYGqnZLM8h%3DNuWp5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ubuntu+nginx+django urlpatterns 404 not found

2016-05-09 Thread Gergely Polonkai
On May 9, 2016 10:06, "minom du"  wrote:
>
> sorry,my english is not good
> my urls.py is
> from django.conf.urls import include, url, patterns
> from django.contrib import admin
>
> urlpatterns = [
> url(r'^admin/', include(admin.site.urls)),
> ]
>
> urlpatterns += patterns('bullet.views.noticeview',
> (r'^$', 'notice'),
> (r'^board', 'board'),
> )

patterns is going away soon, so try this instead:

urlpatterns = [
url(r'^admin/', include(admin.sites.urls)),
url(r'^$', 'notice'),
url(r'^board', 'board'),
]

My guess is that it will solve your problem. If not, come back to us with
the results!

>
> and this is my views code
> def notice(request):
> logger = logging.getLogger('school')
> logger.info("ko ")
> board_list=board.objects.using("default").all()
> return render_to_response('index.html',locals())
>
> def board(request):
> t = loader.get_template("index.html")
> response_data = {}
> response_data["result"] = "Y"
> board_list=board.objects.using("default").all()
> response_data["content_html"] =
t.render(Context({'board_list':board_list}))
> return HttpResponse(json.dumps(response_data),
content_type="application/json")
>
> when i run localhost:82 it will run notice and goto index.html
> but when i run localhost:82/board
> it will return 404 not found
>
> and i try to change the code def board to this
> def board(request):
> logger = logging.getLogger('school')
> logger.info("ko ")
> board_list=board.objects.using("default").all()
> return render_to_response('index.html',locals())
>
> just same of notice
> it still return 404 not found
>
> the environment is ubuntu+nginx+django 1.8.13
>
>
> and i try build it on the environment windows2008+apache+django1.8.7
> both notice and board can work fine(windows use port:83)
>
>
>
> so i don't understand why ubuntu+nginx will return 404 not found
>
>
>
>
>
>
>
>
> Gergely Polonkai於 2016年5月9日星期一 UTC+8上午1時36分49秒寫道:
>>
>> What do you mean it doesn't work? What error message you get? Are you
sure it is provided by Django and not the webserver?
>>
>> Also, GMail is marking your message as a possible malware; consider
pasting your urls.py inline instead of an attachment.
>>>
>>>
> --
> 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/c23eb219-a5ba-4353-b938-79c478783921%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/CACczBULEoaSONiBXRmhYFXZ7wiN2BOL_qyJ52MT%2B-o76LQxXXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ubuntu+nginx+django urlpatterns 404 not found

2016-05-10 Thread Gergely Polonkai
If your 404 pages are white with DEBUG=True, then the problem lies within
the web server config. Could you show us the working apache config, too?
i tried
and still return 404 not found

Sai K於 2016年5月10日星期二 UTC+8下午7時36分57秒寫道:
>
> Can you change the url for board some thing like : *url(r'^board$',
> 'board') , lets try.*
>
> On Sunday, May 8, 2016 at 7:10:40 PM UTC+5:30, minom du wrote:
>>
>> Hello ,every body.
>> attachment is my code
>>
>> i set the urls.py below
>> urlpatterns += patterns('bullet.views.noticeview',
>> (r'^$', 'notice'),
>> (r'^board', 'board'),
>> )
>>
>> the urlpatterns ^$ work fine
>> but ^board not work ,it show 404 not found
>>
>> i have some code like this but work on windows+apache
>> it work fine
>>
>> now i move it to ubuntu+nginx
>> then it not work
>>
>> anyone can tell me how fix it ,please
>> thank you very much
>>
> --
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/3d41a71a-480e-49e4-ae49-5fe59d39929a%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/CACczBUJYAsL_BB80mk7F%3D41HTfLASw2m96UgOEkVaHS0fNC%3D5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Best way to switch from mysql to postgres?

2016-05-11 Thread Gergely Polonkai
Hello,

this depends on a lot of factors, like the anatomy of your models and
signals. I have a model which is is not administered, but every time I
create a user, a new row is added by a signal. This way, loading such a
dump is impossible without some modifications to these signals.

All in all, it would be really helpful if you show us you actual errors.
Without that it is impossible to decide if it is possible in your situation.

Best,
Gergely
On May 11, 2016 21:16, "anton"  wrote:

hi,

I have a django (1.8.13) project running
on windows 7 64 bit + python 2.7.10 (32bit).

Actually it runs with mysql (precise: mariadb)
and I tried the following:

1. commandline:> manage.py dumpdata -o dumpdata.json

2. then I switch the engine to postgres in my django settings file
  (the empty postgres is already prepared)

3. commandline:> manage.py loaddata dumpdata.json

Unfortunately it runs into an error.

Before I put here all the details, first one question:

Is this way supposed to work?

Or how would you do it?

Thanks

 Anton

--
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/nh00dn%24hj7%241%40ger.gmane.org
.
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/CACczBUL-ONCSSz%2BMXZ7hzJVP5c9ZLpAy9HK28s-GB3y-FnuUzg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Delete all migration files

2016-05-12 Thread Gergely Polonkai
Hello,

Michal is right, except…

If you have only one server running your code, there is no real need to
keep your unsquashed migrations; do a squash, and remove everything else.

If, however, your app's source is public, imagine the following scenario:

You publish your app with 3 migration files. I install it and migrate. Then
you create 2 more, but later decide to squash all 5 into one (resulting in
a 0001_0005 migration file) and remove the old ones. Now I hear about the
cool new feature you just built in and want to use it. I upgrade the app,
run migrate… and Django will miss the 0004 and 0005 files.

If I create an empty migration with the same name of your 0004 (I can check
it in the squashed migration file), then run makemigration, I'll get the
same result as you (I have to rename 0005 again, of course). However, if
you had a RunPython step in your 0004, I will know nothing about it, and
may destroy my data (of course not, I have backups).

=

I have some Django projects in production, and we always keep migration
files. We also have most of them squashed just in case (it speeds up
testing a lot).

I hope I helped :)

Best,
Gergely

On May 13, 2016 07:42, "Michal Petrucha" 
wrote:
>
> On Thu, May 12, 2016 at 08:11:42PM -0700, Noumia Ngangoum wrote:
> > Yeah Eugene, I know that, that's how I do now.
> > I was looking for a one-liner command or something.
>
> There is no one-liner, because you are not supposed to remove all
> migrations. The entire point of migrations is that once you crate
> them, you keep them together with your code.
>
> Occasionally you might want to squash your migrations, in case the
> migration history becomes too long and takes too much time to process
> one-by-one, but even when you do that, you do not simply remove all
> migrations and reset the migrations table.
>
> Cheers,
>
> Michal
>
> --
> 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/20160513054234.GC435%40konk.org
.
> 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/CACczBULN2j8evGURO2NPZJaF5%2BjFJbjKuO7tHUU%2B7-Ro3bkrnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get all columns as a list

2016-05-19 Thread Gergely Polonkai
Hello,

Django can’t do this out of the box, but see this post[1] for a possible
solution with dicts.

You might also want to look at serialization[2]; it might help you a bit,
but again, it’s primarily for dicts, not lists.

On the other hand, I started wondering why you need this, do you care to
share the use case?

Cheers,
Gergely

[1] http://stackoverflow.com/a/29088221/1305139
[2] https://docs.djangoproject.com/en/1.9/topics/serialization/
On May 20, 2016 00:13, "Larry Martell"  wrote:

> This is probably very simple, but I just can't figure out how to do it.
>
> I want to get all the columns in some rows as a list. I know I could
> use values_list and flat=True and list all the columns, but is that
> the only way?
>
> I want to do something like this:
>
> rows = FOO.objects.filter(bar='baz')
>
> and get a list of lists instead a list of FOO objects.
>
> --
> 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/CACwCsY7EZtbmLqLgggZnnBspKbvOucPDki1i28zD3jtjGp%3DWFQ%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/CACczBUJBs87C9ayBxEyfWo4AX%2BFrB0Do%2BrNeNTtX7OKQyoxr%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: is there any django app for opendata

2016-05-20 Thread Gergely Polonkai
Hello,

what exactly want to achieve? I mean, Open data is not a standard data
format you can implement, it’s just the way you make that data accessible.
The biggest challenge in this, I think, is keeping the integrity of the
data, so everyone sees the same thing at any point in time.

Best,
Gergely



Gergely Polonkai
[image: https://]about.me/gergely.polonkai
<https://about.me/gergely.polonkai?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>

2016-05-20 0:59 GMT+02:00 Luis Zárate :

> Hi,
>
> I interested in opendata and open government so I am looking for tools to
> build a platform for a local government.
>
> I really like django, I like to build system with it so I want to
> implement something useful that help to create and transparent and eficient
> for free
>
> Do you have some recommendation ?
>
> Thanks
>
>
> --
> "La utopía sirve para caminar" Fernando Birri
>
>
>
> --
> 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/CAG%2B5VyPWH5ap%2BhVRb3C%3Dhtvh406it7ngCROCdzpV87yh0fioMw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAG%2B5VyPWH5ap%2BhVRb3C%3Dhtvh406it7ngCROCdzpV87yh0fioMw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> 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/CACczBULgY0Ex95MqusxA1bGWceQ3cxshoNosR7%3Dkmbw_RvWYDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Complicated relationships

2016-05-23 Thread Gergely Polonkai
I would make Restaurant.dishes a @property that returns all dishes the
restaurant's chefs can make:

return Dish.objects.filter(chef__restaurant=self)
On May 23, 2016 14:46, "Jani Tiainen"  wrote:

> Something like
>
> Chef:
>   # Nothing special here, reverse relations will be done automatically
>
> Dish:
>chef = ForeignKey(Chef)
>
> Restaurant:
>chefs = ManyToMany(Chef)
>dishes = ManyToMany(Dish)
>
>
> Of course, you need to build something to make sure that restaurant
> doesn't serve dishes that it's chefs can't make.
>
>
> On 23.05.2016 15:19, Mlati Mudan wrote:
>
> I read the django documentation for a simple many-to-many relationship and
> I get it, but I'm stuck with this kind of complexity.
>
> Each restaurant employs many chefs and serves many dishes.
> Each chef can work for many restaurants and prepare many dishes.
> Each dish can only be prepared by a single chef but it can be on the menu
> of many restaurants.
>
> How do I connect these models: dish, chef, restaurant?
>
>
>
>
> --
> 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/01e504a5-bbc6-4cee-96e2-158a2803d5b7%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/5742FBA4.5010901%40gmail.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/CACczBULCJXyxtuzu%3D9Kns27qxkdwLYuFXGW1cDypktDafz8VcA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: UserProfile Pattern (extending User model); Migrations; New fields/columns on models.

2016-05-23 Thread Gergely Polonkai
Hello,

did you run manage.py migrate?

When you add a ForeignKey or OneToOne to a model, what actually gets stored
in the DB is the ID of the referenced object (in this case, a
auth.models.User). So the user_id column should be created for you during
the next makemigrations+migrate combo.

On a side note, giving a plural name to your models is bad practise,
especially if you use the builtin admin site.

Best,
Gergely
On May 23, 2016 18:42, "McKinley"  wrote:

> I have a Users table inside of a postgresql database in which auth_user
> also lives. I want the Users objects to have a OneToOne to the auth_user
> model. I added a line to my models.py under my Users class:
>
> user = models.OneToOneField(User, unique=True)
>
> There are probably other things wrong, because at this point my basic
> template returns this traceback:
>
> Exception Type: ProgrammingError at /scripts/users/
> Exception Value: column users.user_id does not exist
> LINE 1: SELECT "users"."id", "users"."user_id", "users"."email", "us..
>
>  I know my Users table doesn't have the user_id column. I do not know how
> to add it. Do Django users prefer to write a migration for this? Migrations
> themselves are not detecting any changes per app at all so I am completely
> flummoxed on how to add this column properly. I was going to manually do it
> in postgres, but I didn't know how to make it conform to the corresponding
> field in auth_user. Thank you for your help.
>
> --
> 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/3e89ccba-dcb9-42ef-b084-c6cc4b7d6891%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/CACczBULk4THu13xFBfP2je0XDBPgMCe-aBXjNxna%3DYkaf0Q_ZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: I am not able to run the following code

2016-05-26 Thread Gergely Polonkai
I don’t see any error here; what is the error message you see?



Gergely Polonkai
[image: https://]about.me/gergely.polonkai
<https://about.me/gergely.polonkai?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>

2016-05-26 10:16 GMT+02:00 Madhusudhana H V :

> I am trying to execute the following code. But I am getting error at step 2, 
> namely ">>> t = template.Template('My name is {{ name }}.')"
> Kindly help me out of this.
>
> >>> from django import template>>> t = template.Template('My name is {{ name 
> >>> }}.')>>> c = template.Context({'name': 'Adrian'})>>> print t.render(c)My 
> >>> name is Adrian.>>> c = template.Context({'name': 'Fred'})>>> print 
> >>> t.render(c)My name is Fred.
>
> Thanks and Regards,
> Madhusudhana H V
>
> --
> 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/1da7713e-5019-4a96-b026-30ff4ecc13bf%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/1da7713e-5019-4a96-b026-30ff4ecc13bf%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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/CACczBUJ0kXk8x0cp1g8vCbSUge4G8Dbt0v18BH9ivZF9Qm9OEA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Questions about Deploying django for production using apache and mod_wsgi.

2016-05-26 Thread Gergely Polonkai
On May 26, 2016 20:12, "Bruce Whealton" 
wrote:
>
> Hello all,
> I have a few questions of which I am not finding answers.
> 1) If I export my development db (Postgresql) and then import it into
production database,
> won't I be pulling in a very weak password that I used for development?
I guess I can
> just change that.

Yes you can, and yes, you will. I usually start prod with an empn]ty DB, I
consider that safer.

> 2) Should I export all the content and structure from my development
server to my
> production server?  Or should I just create the database connection and
then run migrations and
> then create the data content on the production server?  Obviously, my
development server has
> minimal content.

See my previous answer. If your dev data is production-ready, I don’t see
the downside though.

>
> 3) Should I just upload the other packages that I installed with pip on
my development server or
> should I instead run pip install on the production server to get all the
packages needed on the
> production server?

If you use virtualenv, you should use pip install. I suggest creating a
requirements.txt file (you can create one with pip freeze) and update it
regularly.

>
> 4) Is it a best practice ( continuing from #3) to create a requirement
file and use that to install
> with pip all the packages, as opposed to uploading the packages from
development to production?
> Note: I am developing on Ubuntu but deploying to Centos.

See previous answer.

>
> 5) I suppose, even if I had a Centos development environment, I would
still want to install the required
> packages on the production server instead of just uploading everything.
>
> Regarding #5, I am liking Python better than what I have used for some
time, PHP based application
> development.  However, for the longest time, things were much simpler
with php in that most php code is
> just text and so there isn't the notion of "installing" a package.  One
could expect things to work fine
> if one just uploaded the site from development to production (perhaps
certain new OO features are changing
> this situation for php sites, e.g. the use of autoloaders but that's
another topic).

PHP has its package system, too, it is called composer. It also has binary
modules (although they require much more effort on the server side)

>
> 6) Is there anything else, in addition to the top level assets (with
js/css) that I would want apache to serve directly
> versus going through mod_wsgi?  It seems like I read something to this
effect relating to parts of the admin,
> that need to be served directly by apache.  I could be wrong.

Take a look at the collectstatic management command. Also, if you use
django-compress, e.g. for less,sass, css/js minimizing), you need to run
that.

>
> Thanks in advance for any help,
> Bruce

Also, you may want to check this page[1] for other possible caveats and
best practises.

[1] https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/

>
> P.S. If anyone wants to develop a course on udemy.com on a python
framework, please don't develop with
> sqlite3 since we won't use that in production and please discuss
deployment on a server besides
> something like pythonanywhere.com.  The issues of setting things up on
one's own vps server are not
> trivial at all.  (smile).
>
> --
> 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/50b71c19-10a1-4610-8050-191bde7facda%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/CACczBULd2mqRCuY72euyZR0xiUCT2wWNKWBYF78qLsWP7KbFww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to use view function in another function of view in django

2016-06-15 Thread Gergely Polonkai
Just like this. Unless you have a specific use case you forgot to share in
your mail.

Views are mere functions that get called with a request az a parameter. You
shouldn’t treat them as special/holy/uncallable.

Best,
Gergely
On Jun 15, 2016 19:56, "hossein"  wrote:

> def base(request):
> j=Job.objects.all()
> a=Ab.objects.all()
> return render(request,'base.html',{'j':j, 'a':a})
>
> def index(request):
> base(request)
> x=X.objects.all()
> return render(request, 'index.html',{'x':x})
>
> def list(request):
> base(request)
> z=Z.objects.all()
> return render(request, 'list.html',{'z':z})
>
> --
> 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/3cc2651c-35df-4eaf-bab6-b1ae936f73d4%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/CACczBULw3kggNH5%3DerHjm5iY6yFkjwEknLL8V9Cpa1N9RX2Cww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using the Eclipse mysite>django>custom command(manage.py$(custom_command)) function

2016-06-26 Thread Gergely Polonkai
Hello,

that message tells you everything. As there is no tty (ie. a terminal that
can read user input and write some output), createsuperuser won’t run.

I don’t know eclipse, but if you can force it to run commands within a tty,
you won. Otherwise you will have to use the command line.

Well, except you can start an interactive Python shell from within Eclipse.
In this case, you can import your User model, and create users with that,
as if it was your app’s code.

Best,
Gergely
On Jun 26, 2016 00:51, "Gary Roach"  wrote:

> i did as you suggested and tried it with runserver. It worked. I tried the
> same thing with createsuperuser and got the errror: Superuser creation
> skipped due to not running in a TTY.
>
> Since I am setting up the sqlite dbms, does it make any difference if I
> run the thing inside Eclipse vs cd to mysite.manage.py and run things
> from the system monitor command line?
>
> Gary R.
>
> On 06/25/2016 01:55 PM, Ilya Boka wrote:
>
>> Click add. Enter your command( Ex: "runserver"). Click OK. Double
>> click to run this.
>>
>> On Sat, Jun 25, 2016 at 10:07 PM, Gary Roach 
>> wrote:
>>
>>> Hi all:
>>>
>>> OS Debian Stretch
>>> KDE Desktop
>>>
>>> I am using Eclipse Neon with the PyDev plugin for developing a django
>>> application. At present I am running through the djangoproject
>>> tutorial.The
>>> tutorial has me run:
>>>  python manage.py createsuperuser
>>> I want to run this within Eclipse and not the system command line. Right
>>> clicking on the project title and following the sub menus I get to the:
>>>  mysite>django>custom command(manage.py$(custom_command))
>>> function. I
>>> can't seem to figure  out how to use this. It is the only thing I could
>>> find
>>> that looks like it is meant to replace the system command line.
>>>
>>> In general, any time I have to use manage.py and there is not a specific
>>> menu item for the process, I'm awash.
>>>
>>> Any elucidation on this point will be sincerely appreciated.
>>>
>>> Gary R.
>>>
>>> --
>>> 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/d9eba089-965f-46cf-7c38-f97af2d17aa8%40verizon.net
>>> .
>>> 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/88d4a6cf-19d7-6d54-b1da-320a55641ebc%40verizon.net
> .
> 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/CACczBU%2B21Rxn9drubBJ2aZ3dMC3SMYLjYyP4pmtKnki%2BDdCpfQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: When need return the HttpResponseBadRequest and why?

2016-07-04 Thread Gergely Polonkai
400 Bad Request is responded if the client sends a… um… Bad Request?

Jokes aside, it may represent many things. Web servers may send 400 if the
HTTP request is malformed. Applications, such as a Django app, may send 400
if the request cannot be processed, e.g. when a required header is missing
or (with REST APIs) if a JSON field is not present or contains an invalid
value.

Best,
Gergely
On Jul 4, 2016 19:44, "Seti Volkylany"  wrote:

.

-- 
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/7f2bfae4-66d1-44c6-9255-4f862d42d43b%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/CACczBULSY21SaY-4ZO2SqKPqzGMq4gPzizW4BsqB_i1hMHKQug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError: $.get is not a function

2016-07-25 Thread Gergely Polonkai
This sounds to be a JavaScript problem, which is not part of Django in any
ways.

My idea, however, is that you don’t import another JS file that contains
the $ function (probably jQuery or Prototype?)



Gergely Polonkai
[image: https://]about.me/gergely.polonkai
<https://about.me/gergely.polonkai?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>

2016-07-25 12:31 GMT+02:00 ajay :

> //In scirpt
>
> $('#suggest').keyup(function ()
> {
>var query = $('#suggest').value;
>
>  $.get("/search/", {suggest:query},function( data ){
>  $("#list").html( {% for item in search_list %}
> ''+{{ item }}+ ''
> {% endfor %} )
>
>
> });
>
>
>
> In body
>
>
> 
> 
> 
>
>
> am i doing something wrong
>
> plz help
>
> --
> 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/f874db3a-1e19-4cef-9deb-9beed11159d2%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f874db3a-1e19-4cef-9deb-9beed11159d2%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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/CACczBU%2BHq2a7Xs7U5tqcfFF%2BZ2CzyQMTiMtetjkbxym5SJuczQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Migrations for forms fields

2016-08-16 Thread Gergely Polonkai
Hello,

rename migrations in your head to database migrations, or even model to
database migrations.

The migration process takes all your models and applies all the changes in
them to your database (usually an SQL instance in the wild).

Forms, on the other hand, are just that: forms, that can get some input
from somewhere. Although they can be used to interact with models (in fact,
there is ModelForm designed specifically for this case), they are not
models, thus, migrations don't apply to them.

Hope that makes the picture clear.

Best,
Gergely

On Tue, Aug 16, 2016, 00:56 Pranjal Tale  wrote:

> Hello!
> I was writing my models with forms.Forms and after writing when i run
> "python manage.py makemigrations app_label" it shows the error as "app not
> deceted".
>
> And at at same time when i build some models with models.Model and when i
> run the same command so all the migrations get implemented.
>
> It is so that for forms based models migrations are not applied
> If not i am unable to find the bug
> Please Help
> Thanks.
>
> --
> 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/f2b8c7cb-4e9c-4543-a80c-65d5bee3d935%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/CACczBUK-iZkH3u_KSYkT%2B%2BO2e2%3D8ckzBk6KegSC0uQeYTwv-5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unable to get tests to work

2016-08-17 Thread Gergely Polonkai
Hello,

this “refreshes.backups.tests” thing bothers me a lot. Could you show us
your directory structure, please?

Best,
Gergely

On Wed, Aug 17, 2016, 23:03 Matt  wrote:

> Ok a step forward. When I spell out the tests it works:
>
> https://dpaste.de/2MXf
>
> But when I run test without arguments, it fails out:
>
> https://dpaste.de/cgTH
>
> There is more than the backups app here, but I plan to replicate out the
> fix when I get it.
>
> On Wednesday, August 17, 2016 at 2:34:45 PM UTC-6, Fred Stluka wrote:
>
>> Matt,
>>
>> Oops!  Right.  I just noticed that in the dpaste.
>>
>> My next guess is you may need to change the name "good_index_text"
>> to something that starts with "test_" to get it to be recognized as a
>> test.
>>
>> Or maybe something to do with "refreshes"?  The test trace shows
>> it trying to run testcase "refreshes.backups.tests", but in the manual
>> import you did from the python shell, you only import "backups.tests"
>>
>> --Fred
>> --
>>
> Fred Stluka -- mailt...@bristle.com -- http://bristle.com/~fred/
>> Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
>> Open Source: Without walls and fences, we need no Windows or Gates.
>> --
>>
>> On 8/17/16 4:27 PM, Matt wrote:
>>
> Sorry for the typo, but I have already do that way. I have the output in
>> the the first link.
>>
>> On Wednesday, August 17, 2016 at 2:24:19 PM UTC-6, Fred Stluka wrote:
>>>
>>> Matt,
>>>
>>> Drop the "s" from "tests":
>>>
>>> ./manage.py test backups
>>>
>>> --Fred
>>> --
>>> Fred Stluka -- mailt...@bristle.com -- http://bristle.com/~fred/
>>> Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
>>> Open Source: Without walls and fences, we need no Windows or Gates.
>>> --
>>>
>>> On 8/17/16 4:17 PM, Matt wrote:
>>>
>>> When I'm trying to get tests to work it simply states that its unable to
>>> import .tests. I'm not sure what I'm missing here. Here is some output
>>> please let me know if you need more:
>>>
>>> ./manage.py tests backups
>>> https://dpaste.de/4U9C
>>>
>>> The test file:
>>> https://dpaste.de/bBZt
>>> --
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@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/89d6fac7-0848-4e35-8b4a-62d24178c3aa%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...@googlegroups.com.
>> To post to this group, send email to django...@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/04fcacea-15d0-42af-afe5-424c2d1df86f%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/404f7e22-6f34-4c0d-bfdd-f277f6fb7543%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/CACczBUKXpd-MKGXNDyNTSXiBcKQ-u7r1VF2wQCKKBq1PFCz4BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using version control with django

2016-08-23 Thread Gergely Polonkai
Hello,

the fact you develop alone doesn't make SVN a better choice than Git,
Mercurial, or any other distributed version control. But as you already
made your choice, here are my two cents.

You should put all the stuff under trunk/, so it becomes trunk/manage.py,
trunk/crm/, etc. If you are developing for multiple customers, the branches
and tags directory may come in handy later. Also, it's nothing but naming
convention: you can call these directories dog/, Pete/, and ananas/. But
that’s more for a Subversion user list, not Django.

On the other hand, you definitely should choose a distributed version
control if you are working alone. For example, Git, Mercurial and Fossil
repositories are self contained, which means the whole development history
is located right where you work. If you decide to publish (or just backup)
your work, all you need to do is to add a new remote. With SVN, it's hard
to publish somewhere else than before (read: it’s a real PITA to migrate
SVN history from one server to another).

Best,
Gergely

On Tue, Aug 23, 2016, 21:42 Rich Shepard  wrote:

>I want to track django projects with subversion. (Single developer,
> local,
> so svn is better suited than the distributed git and mercurial.) I'd like
> advice on how to lay this out vis-a-vis the django layout.
>
>Project overall root is ~/development/crm-project. This directory
> contains:
>
> Makefile  README  crm-project/  docs/  manage.py*  requirements.txt
>
>The top-level project directory is the same-named crm-project, and this
> contains:
>
> __init__.py   __pycache__/  settings.py   urls.py
> __init__.pyc  crm/  settings.pyc  wsgi.py
>
>The app directory is crm/.
>
>So, where should I place trunk/, tags/, and branches/ be created? If
> they're in the overall project root (~/development/crm-project/) should I
> then move that directory's contents into the newly made trunk/
> subdirectory?
>
>I find nothing in my web searches for using svn with django. Perhaps my
> web foo is insufficient.
>
> Rich
>

-- 
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/CACczBUJ3apCi5pgsm%3D768HA3dU0-%3DL%2B8Q16fgTaMjKXttRMuTg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Strange failing test

2016-08-24 Thread Gergely Polonkai
Hello,

I have a test that fetches some JSON data from my API and compares it with
the expected result, which is generated like this:

expected_json = {
'status': 'ok',
'invalid-fields': {},
'updated-fields': cloned_build.groupings.get(group=group1)
.field_values
.exclude(template=approvable_template)
.values_list('id', flat=True)[:],
}

At the end, I get this error:

AssertionError: {u'status': u'ok', u'invalid-fields': {},
u'updated-fields': [13, 14, 15]} != {u'status': u'ok', u'invalid-fields':
{}, u'updated-fields': [13, 14, 15]}
  {u'invalid-fields': {}, u'status': u'ok', u'updated-fields': [13, 14, 15]}


It seems the two dicts are equal, but assertEquals thinks they are not. Am
I missing something here?

Best,
Gergely

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


Re: Strange failing test

2016-08-24 Thread Gergely Polonkai
It just turned out that value_list(…, flat=True) returns a QuerySet, not a
list. So expected_json couldn’t be equal to the actual result. It took a
bit of debugging as repr() displays [1, 2, 3], not QuerySet(1, 2, 3) or
something.

Derek  ezt írta (időpont: 2016. aug. 24., Sze, 16:03):

> Assuming that the long function you have embedded inside your dictionary
> simply generates a list i.e.
>cloned_build.groupings.get(group=group1)
>.field_values
>.exclude(template=approvable_template)
>.values_list('id', flat=True)[:]
>
> results in:
>[1,2,3]
>
> Then some examples of possible tests:
>
>
> expected_json = {
> 'status': 'ok',
> 'invalid-fields': {},
> 'updated-fields': [1,2,3]
> }
> actual_json = {
> 'invalid-fields': {},
> 'status': 'ok',
> 'updated-fields': [1,2,3]
> }
> invalid_json = {
> 'invalid-fields': {},
> 'status': 'ok',
> 'updated-fields': [2,3]
> }
>
> assert cmp(expected_json, actual_json) == 0  # same
> assert cmp(expected_json, invalid_json) == -1  # different
>
> Hope this helps.  For more background & discussion, see:
>
>
> http://stackoverflow.com/questions/4527942/comparing-two-dictionaries-in-python
>
>
>
> On Wednesday, 24 August 2016 12:11:18 UTC+2, Gergely Polonkai wrote:
>>
>> Hello,
>>
>> I have a test that fetches some JSON data from my API and compares it
>> with the expected result, which is generated like this:
>>
>> expected_json = {
>> 'status': 'ok',
>> 'invalid-fields': {},
>> 'updated-fields': cloned_build.groupings.get(group=group1)
>> .field_values
>> .exclude(template=approvable_template)
>> .values_list('id', flat=True)[:],
>> }
>>
>> At the end, I get this error:
>>
>> AssertionError: {u'status': u'ok', u'invalid-fields': {},
>> u'updated-fields': [13, 14, 15]} != {u'status': u'ok', u'invalid-fields':
>> {}, u'updated-fields': [13, 14, 15]}
>>   {u'invalid-fields': {}, u'status': u'ok', u'updated-fields': [13, 14,
>> 15]}
>>
>>
>> It seems the two dicts are equal, but assertEquals thinks they are not.
>> Am I missing something here?
>>
>> Best,
>> Gergely
>>
> --
> 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/ac51f934-5320-45c1-8dc8-aca658fde881%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/ac51f934-5320-45c1-8dc8-aca658fde881%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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/CACczBUJ%2BuQRjSvEJebVtvKV1Srzzhq3WhSWHpAvhsNi39hm90w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Strange failing test

2016-08-24 Thread Gergely Polonkai
That’s indeed great news. Too bad I’m rooted with 1.9 for a while, as 1.10
doesn’t play nice with Python 2.7.8. I hope I can upgrade both Python and
Django to as recent as possible soon. Thank you for the info anyways!

Tim Graham  ezt írta (időpont: 2016. aug. 24., Sze,
16:59):

> You'll be glad to know that's fixed in Django 1.10:
> https://github.com/django/django/commit/e0837f2cb12de5e95e621d19b186b0da43bcdee2
>
>
> On Wednesday, August 24, 2016 at 10:27:37 AM UTC-4, Gergely Polonkai wrote:
>
>> It just turned out that value_list(…, flat=True) returns a QuerySet, not
>> a list. So expected_json couldn’t be equal to the actual result. It took a
>> bit of debugging as repr() displays [1, 2, 3], not QuerySet(1, 2, 3) or
>> something.
>>
>> Derek  ezt írta (időpont: 2016. aug. 24., Sze, 16:03):
>>
> Assuming that the long function you have embedded inside your dictionary
>>> simply generates a list i.e.
>>>cloned_build.groupings.get(group=group1)
>>>.field_values
>>>.exclude(template=approvable_template)
>>>.values_list('id', flat=True)[:]
>>>
>>> results in:
>>>[1,2,3]
>>>
>>> Then some examples of possible tests:
>>>
>>>
>>> expected_json = {
>>> 'status': 'ok',
>>> 'invalid-fields': {},
>>> 'updated-fields': [1,2,3]
>>> }
>>> actual_json = {
>>> 'invalid-fields': {},
>>> 'status': 'ok',
>>> 'updated-fields': [1,2,3]
>>> }
>>> invalid_json = {
>>> 'invalid-fields': {},
>>> 'status': 'ok',
>>> 'updated-fields': [2,3]
>>> }
>>>
>>> assert cmp(expected_json, actual_json) == 0  # same
>>> assert cmp(expected_json, invalid_json) == -1  # different
>>>
>>> Hope this helps.  For more background & discussion, see:
>>>
>>>
>>> http://stackoverflow.com/questions/4527942/comparing-two-dictionaries-in-python
>>>
>>>
>>>
>>> On Wednesday, 24 August 2016 12:11:18 UTC+2, Gergely Polonkai wrote:
>>>>
>>>> Hello,
>>>>
>>>> I have a test that fetches some JSON data from my API and compares it
>>>> with the expected result, which is generated like this:
>>>>
>>>> expected_json = {
>>>> 'status': 'ok',
>>>> 'invalid-fields': {},
>>>> 'updated-fields': cloned_build.groupings.get(group=group1)
>>>> .field_values
>>>> .exclude(template=approvable_template)
>>>> .values_list('id', flat=True)[:],
>>>> }
>>>>
>>>> At the end, I get this error:
>>>>
>>>> AssertionError: {u'status': u'ok', u'invalid-fields': {},
>>>> u'updated-fields': [13, 14, 15]} != {u'status': u'ok', u'invalid-fields':
>>>> {}, u'updated-fields': [13, 14, 15]}
>>>>   {u'invalid-fields': {}, u'status': u'ok', u'updated-fields': [13, 14,
>>>> 15]}
>>>>
>>>>
>>>> It seems the two dicts are equal, but assertEquals thinks they are not.
>>>> Am I missing something here?
>>>>
>>>> Best,
>>>> Gergely
>>>>
>>> --
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@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/ac51f934-5320-45c1-8dc8-aca658fde881%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/ac51f934-5320-45c1-8dc8-aca658fde881%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> 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/6e27b36b-9693-492e-baf6-b34d9596ee87%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/6e27b36b-9693-492e-baf6-b34d9596ee87%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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/CACczBUJsjL5dVOsjwJZLrD-w3qEgwAp_y9GeM30Lqa02TuDKmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ti possible CommaSeparatedIpField

2016-08-31 Thread Gergely Polonkai
Hello,

although it is possible, I'd go with an IP field and generate a list of
them, comma separated, at run time. This will make it easier to search and
manage the list.

Best,

Gergely

On Wed, Aug 31, 2016, 00:29 Jorge Cadena  wrote:

> Hi
>
> I have a idea CommaSeparatedIpField, it possible ?
>
> this for validacion IP ACL list in FreeSWITCH.
>
> --
> 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/9d5d8359-ce30-41c8-8d88-2733b32ad76d%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/CACczBUJvNiyC7QZ1NFjYkx97i1tB7%3D7QKGwu49PVsfaWr%2BZg7A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: I am searching: How to make drop down list in django

2016-09-01 Thread Gergely Polonkai
This very much depends on what exactly want to do, but in general, it
doesn’t really Django’s job. Can you produce the desired result in a plain
HTML file? If not, you should visit an HTML/CSS tutorial; if yes, you
should define your problem a bit better, otherwise we won’t be able to help
you.

 ezt írta (időpont: 2016. szept. 1., Cs, 13:17):

> I trying for last 7 days to search this topic but could not find :(
>
> --
> 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/a22b7506-9a82-4e1b-8835-b170774ec03a%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/CACczBU%2Bm_65mMwud1_xxZn1uKNj_oR-vfUyh%2Bc%3D9xP-C5XRrZw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django migrate generates SQLite3 file filled with junk

2016-09-25 Thread Gergely Polonkai
That file is an SQLite database, which is a binary format. It should look
like this.

I know it is confusing, because of that bunch of SMS statements, but it's
OK that way. If you want to interact with it, use the sqlite3 command, or
an SQLite GUI.

On Sun, Sep 25, 2016, 14:17 kbman99  wrote:

> Just getting started with django and having an issue with the migrate.py
> script. It generates a db.SQLite3 file which is filled with a lot of
> garbage characters. It's in UTF-8 encoding, but looks like this.
>
> 
> I've deleted the file and redone the migrate a few times but it's always
> like this.
>
> Any help appreciated!
> Thanks
>
> --
> 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/2980ce12-c366-454b-844a-c625e7520977%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/CACczBU%2BLjg8hzYKKEKEdec9kWdWS1bfXSCdX0qsO0oxcppVX5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


  1   2   >