Loader Template without context (request), Use Case and Proposal

2016-06-06 Thread aRkadeFR

Hello all,

I'd like to open a discussion on the Loader Template 
(django/template/loaders/app_directories.py)
which is linked to the Template Engine (django/template/engine.py) about
the context it has when determining the templates to load.

## Use Case

In order to do multi-tenancy on our project, we set the current_site on
the input request in a middleware (almost the same as
django/contrib/sites/middleware.py).

Then our part of the system base its computation on the current_site of
the request.

Some of our clients needs to have specific markup template (.html
template).

In order to do that, we chose a hierarchy of templates, that can be
overriden if we have another folder with the same name of the
client/website.

Let's take an example:

We have as templates:
- /default/base.html
- /custom/base.html

If the request.site is named "custom", then we want to load the
/custom/base.html . Otherwise we load the /default/base.html


## Problem encounter

The Loader for the template doesn't have any context, and so we have
setup a global state with the request in threads local. I personnaly
hate global state in Django
(https://code.djangoproject.com/wiki/GlobalState).


## Proposal

I'd like to know if we could add the possibility to have more context on
the Loader? At least the request?

This is a bit of refacto in the code of Django as the Engine is created
only once for every Django process.


Thanks for your reading,

Have a good day

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


Re: Django debug= false throwing 503 error

2015-12-28 Thread aRkadeFR

Hello,

How do you run your server in production?
Where do you see the server throwing the 503 error?

Thanks,

On 12/28/2015 09:46 AM, Web Architect wrote:

Hi,

I have set the following in settings.py for our production system:

DEBUG=False

ALLOWED_HOSTS = ['*'] (in fact any value is not working)

The server is throwing "HTTPError = 503".

There are no logs and I am clueless about the reason for the error. I 
tried searching the net and looking into DJango documents but couldn't 
find the possible reason.


Django version is 1.8.3.

Would really appreciate if anyone could help with the above.

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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/a3a76d7c-438c-442d-a68b-3d31859b4708%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/a3a76d7c-438c-442d-a68b-3d31859b4708%40googlegroups.com?utm_medium=email_source=footer>.

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


--
aRkadeFR

--
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/5681010B.9060600%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: [Django1.8.5] About migrate

2015-11-17 Thread aRkadeFR

Hey,

What is the code of your managers and what's the full stacktrace?
You can use dpaste.de as a pastebin :)

For the related field, iirc, it's recommended to reference them with a  
string.


try to change this

cards = models.ManyToManyField(Card, blank=True)

by:

cards = models.ManyToManyField('app.Card')


On 11/17/2015 04:45 AM, Dennis Liou wrote:

Hi :

I am new in Django, and I meet a bug.

I was upgrade django from 1.5 to 1.8.

My Django environment now is : Django 1.8.5 with python 2.7.10

   This is my auth models:

Class Card(models.Model):
 cardgroup = models.CharField(_('CardGroup'), max_length=60)
 cardname = models.CharField(_('CardName'), max_length=60)
 disabled = models.BooleanField(_('disabled'), default=False)
 objects = CardManager()

 class Meta:
 unique_together = (cardgroup', 'cardname')
 def __unicode__(self):
 return self.name
 @property
 def name(self):
 return '%s_%s' % (.self.cardgroup, self.cardname)

Class Factory(models.Model):
   sort = models.CharField(_('Short Name'), max_length=20, unique=True)
   address = models.CharField(_('Factory address'), max_length=20)
   cards = models.ManyToManyField(Card, blank=True)

   def __unicode__(self):
 return self.short


   After "#python manage.py migrate" twice , I got a error:

   ValueError: Lookup failed for model referenced by 
fieldcore.auth.Factory.card:core.auth.core.auth.Card

 Because of that, I cannot syncdb ,either.

 My auth apps was included in a core floder.

 Help me fix the bug, please. I wascoming unstuck for a mouth.
--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/a811320a-efb8-425f-aa0c-bd68df4191f9%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/a811320a-efb8-425f-aa0c-bd68df4191f9%40googlegroups.com?utm_medium=email_source=footer>.

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


--
aRkadeFR

--
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/564B4A78.3010405%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Custom user model password is not hashed

2015-11-12 Thread aRkadeFR

Hello,

I don't quite get the code in your method: 'MyUserManager.create_user':
user.set_password(self.cleaned_data["password"])

You're in your Manager method but call self.cleaned_data ?

You can set a breakpoint inside your method with pdb to see
what's going on with your fields?


On 11/12/2015 04:11 PM, Benjamin Smith wrote:

I have my own custom User model, and its own Manger too.

Models:

class MyUser(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(max_length=255, unique=True)
first_name = models.CharField(max_length=35)
last_name = models.CharField(max_length=35)
username = models.CharField(max_length=70, unique=True)
date_of_birth = models.DateField()
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)

@property
def is_staff(self):
return self.is_admin

def get_full_name(self):
return ('%s %s') % (self.first_name, self.last_name)

def get_short_name(self):
return self.username

objects = MyUserManager()
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['first_name', 'last_name', 'username',
'date_of_birth']


Manager:

class MyUserManager(BaseUserManager):
def create_user(self, email, first_name, last_name, username,
date_of_birth, password=None, **kwargs):
if not email:
raise ValueError('User must have an email address')

user = self.model(
email=self.normalize_email(email),
first_name=first_name,
last_name=last_name,
username=username,
date_of_birth=date_of_birth,
**kwargs
)
user.set_password(self.cleaned_data["password"])
user.save(using=self._db)
return user

def create_superuser(self, email, first_name, last_name,
username, date_of_birth, password, **kwargs):
user = self.create_user(
email,
first_name=first_name,
last_name=last_name,
username=username,
date_of_birth=date_of_birth,
password=password,
is_superuser=True,
**kwargs
)
user.is_admin = True
user.save(using=self._db)
return user


Everything works when creating a new user without any errors. But when 
I try to login I can't. So I checked the user's email and password to 
confirm. Then I noticed that the password is displayed as plain text 
(eg. *strongpassword)*, and when changed the admin form to get the 
hashed password using *ReadOnlyPasswordHashField()* I get an error 
inside the password field, even though I used *set_password()* for the 
Manger inside the *create_user()* function.


/Invalid password format or unknown hashing algorithm/


However, if I manually do *set_password('strongpassword')* for that 
user inside the console, then only the password is hashed. Could you 
please help me solve this problem. Thank you.

--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/CAM4YLWJNGdSj-rVAuhta_UA50Cjna8zg-c14FPxK%3DtdU49mngQ%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAM4YLWJNGdSj-rVAuhta_UA50Cjna8zg-c14FPxK%3DtdU49mngQ%40mail.gmail.com?utm_medium=email_source=footer>.

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


--
aRkadeFR

--
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/5644AE3A.5050609%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


New tool to build django deb package

2015-08-11 Thread aRkadeFR

Hey guys,

I wanted to share with you a little project I did for myself first:
https://github.com/aRkadeFR/dh-python-django

It's a build system paired with debhelper. It helps you build .deb
django package with systemd/nginx/uWSGI/virtualenv.

It's not finished yet, and obviously I take into account only little
use case.

If anyone interested, I'm available and you can PR :)

--
aRkadeFR

--
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/55CA0761.2020001%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: best way to use django

2015-06-29 Thread aRkadeFR

Just read the djangoproject tutorial and then start your project:
https://docs.djangoproject.com/en/1.8/

On 06/29/2015 01:20 PM, Jason Thomas wrote:

Which tutorial do you suggest? Which is the best as far as getting down to the 
nitty gritty (strieght to the point) for what I'm trying to do?



--
aRkadeFR

--
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/559152DF.6080105%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: best way to use django

2015-06-29 Thread aRkadeFR

Read the tutorial and begin to implement your website step by step.

You will see if you need djangular after.

On 06/29/2015 05:08 AM, Jason Thomas wrote:

I want to create twon sites, the first will be a tutorial/blog/projects site 
(how to's) that I can post different web apps to be used by public users logged 
into the site and the second a dating site. do I need to know djangular (as in 
is it to much for what I want to do?) or should I just use strieght django?



please help



--
aRkadeFR

--
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/559109DA.9020308%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Preferred way of adding social authorization to a Django / REST app?

2015-06-19 Thread aRkadeFR

I like JWT authentication coupled with AngularJS:
https://github.com/GetBlimp/django-rest-framework-jwt

On 06/18/2015 08:00 PM, Daniel Grace wrote:
What is the preferred way of adding social authorization to a Django / 
REST app?


I see that there are at least two packages: 
django-rest-framework-social-oauth2 (see 
https://pypi.python.org/pypi/django-rest-framework-social-oauth2/0.0.4) and django-rest-auth 
(see 
http://django-rest-auth.readthedocs.org/en/latest/installation.html). 
 django-rest-framework-social-oauth2 seems to have a lot of 
dependencies.  While the install page for django-rest-auth says that 
you should install rest_framework and rest_framework.authtoken apps, 
both of which give an error if you try to install them with pip:


Downloading/unpacking rest-framework.authtoken
  Could not find any downloads that satisfy the requirement 
rest-framework.authtoken

Cleaning up...
No distributions at all found for rest-framework.authtoken
Storing debug log for failure in C:\Users\Daniel\pip\pip.log

Or is there a better alternative to these two packages for Django / 
REST / social authorization apps?

--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/8637f6fa-7241-4866-9a52-311b36f5d8be%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/8637f6fa-7241-4866-9a52-311b36f5d8be%40googlegroups.com?utm_medium=email_source=footer>.

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


--
aRkadeFR

--
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/5583C520.7090406%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Shortcut for Date and Time is missing from the Django admin panel

2015-06-17 Thread aRkadeFR

Hello,

What's your problems with date and time?
Which shortcuts are you talking about?

On 06/17/2015 10:55 AM, vishwa raj wrote:

I am very new django user.
Here I am facing something troubles In the date and time shortcut.
Also I need to learn it ASAP.
This would be my first backend language.
Suggest me.
--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/034ec2b2-5d0a-4c6c-8f8e-11ea0477ae02%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/034ec2b2-5d0a-4c6c-8f8e-11ea0477ae02%40googlegroups.com?utm_medium=email_source=footer>.

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


--
aRkadeFR

--
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/558146EA.3080900%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Squashed migration

2015-06-15 Thread aRkadeFR

Great.

Thanks for the feedback :)

On 06/15/2015 02:18 PM, Cherie Pun wrote:

Hi,

So the original problem was that I was running in the repo which 
didn't have the squashed migration. Django does know when to switch to 
the squashed migrations when you have both squashed and unsquashed 
migration files coexist in the folder.
As for the syntax error it was because python cannot import from 
modules that starts with numbers. Also, the idea was that we shouldn't 
use the migration files as modules to import code from, that's why the 
file name stayed as it was. Users should manually move their RunPython 
methods manually and resolve those invalid references to migration files.


Hope this helps and sorry for confusing people that squash migration 
doesn't work! I am still new to Python and Django and I really 
appreciate everyone's replies.


Cheers,
Cherie

On Monday, June 15, 2015 at 9:54:09 AM UTC+1, aRkadeFR wrote:

Thanks for the good explanation as always :)

 From the documentation plus the explanation of the problem,
I wanted to know if by deleting the old migration it would still
run the old migrations.

Do we know the end of the story? Where it comes from?

Thanks

On 06/12/2015 05:42 PM, Carl Meyer wrote:
> On 06/12/2015 06:32 AM, aRkadeFR wrote:
>> You need to delete your old migrations so it uses only the
squashed
>> one after.
> No, the squashed migration should be used in place of the old
ones for
> any new database, even if the old ones are still present. This
is the
> point of the squashmigrations feature; that you can keep the old
ones
> around (which is necessary for any deployments that may not yet
have
> applied all of them) while still gaining the benefit of the new
squashed
> migration for new deployments (and tests).
>
> I know this works, because I just did it recently myself. It
sounds like
> Cherie was able to get it working too, though we didn't get any
> clarification on why it didn't seem to work originally.
>
>> In the documentation:
>> "This enables you to squash and not mess up systems currently in
>> production that aren’t fully up-to-date yet. The recommended
process is
>> to squash, keeping the old files, commit and release, wait
until all
>> systems are upgraded with the new release (or if you’re a
third-party
>> project, just ensure your users upgrade releases in order without
>> skipping any), and then remove the old files, commit and do a
second
>> release."
> That's right. The length of time you need to wait before
removing can
> vary widely. For a third-party app, it may be a full release
cycle or
> two (as long as you can tell your users to upgrade
version-by-version).
> For a project with only a few deployments, all under your
control, it
> may be the same day. But regardless, the squashed migration will
still
> be used in tests immediately, before you remove the old migrations.
>
> Carl
>

-- 
aRkadeFR


--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/a46519d9-3819-40d5-8a18-236a4bec846e%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/a46519d9-3819-40d5-8a18-236a4bec846e%40googlegroups.com?utm_medium=email_source=footer>.

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


--
aRkadeFR

--
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/557EC915.4020408%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Squashed migration

2015-06-15 Thread aRkadeFR

Thanks for the good explanation as always :)

From the documentation plus the explanation of the problem,
I wanted to know if by deleting the old migration it would still
run the old migrations.

Do we know the end of the story? Where it comes from?

Thanks

On 06/12/2015 05:42 PM, Carl Meyer wrote:

On 06/12/2015 06:32 AM, aRkadeFR wrote:

You need to delete your old migrations so it uses only the squashed
one after.

No, the squashed migration should be used in place of the old ones for
any new database, even if the old ones are still present. This is the
point of the squashmigrations feature; that you can keep the old ones
around (which is necessary for any deployments that may not yet have
applied all of them) while still gaining the benefit of the new squashed
migration for new deployments (and tests).

I know this works, because I just did it recently myself. It sounds like
Cherie was able to get it working too, though we didn't get any
clarification on why it didn't seem to work originally.


In the documentation:
"This enables you to squash and not mess up systems currently in
production that aren’t fully up-to-date yet. The recommended process is
to squash, keeping the old files, commit and release, wait until all
systems are upgraded with the new release (or if you’re a third-party
project, just ensure your users upgrade releases in order without
skipping any), and then remove the old files, commit and do a second
release."

That's right. The length of time you need to wait before removing can
vary widely. For a third-party app, it may be a full release cycle or
two (as long as you can tell your users to upgrade version-by-version).
For a project with only a few deployments, all under your control, it
may be the same day. But regardless, the squashed migration will still
be used in tests immediately, before you remove the old migrations.

Carl



--
aRkadeFR

--
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/557E9228.5080504%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Squashed migration

2015-06-12 Thread aRkadeFR

Hey,

You need to delete your old migrations so it uses only the squashed
one after.

In the documentation:
"This enables you to squash and not mess up systems currently in 
production that aren’t fully up-to-date yet. The recommended process is 
to squash, keeping the old files, commit and release, wait until all 
systems are upgraded with the new release (or if you’re a third-party 
project, just ensure your users upgrade releases in order without 
skipping any), and then remove the old files, commit and do a second 
release."


https://docs.djangoproject.com/en/1.8/topics/migrations/#squashing-migrations

On 06/12/2015 11:38 AM, Cherie Pun wrote:

Hi,

I have trying to experiment with squashmigration to see if it will 
make it faster to build the database when running tests. So I have 
squashed the migrations following the instructions on the Django 
website. However when I run the tests, it still uses the original 
migrations. I thought Django automatically uses the squashed one over 
the separated ones. Is there some settings that I have to configure? 
Also, it says that no optimisation was available even though there are 
a few AddField which should in theory be combined into AddModel.


Any help or suggestions will be much appreciated, thanks!

Cherie
--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/9288958d-0214-4cd2-9b51-dd173a8e83ae%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/9288958d-0214-4cd2-9b51-dd173a8e83ae%40googlegroups.com?utm_medium=email_source=footer>.

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


--
aRkadeFR

--
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/557AD178.9090707%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Why the extra minute in PostgreSQL when using time zone info?

2015-05-29 Thread aRkadeFR

awesome explanation.

I was only aware of time zone information, and got to
understand the daylight saving time not that long ago.

Glad to know, after reading from you, the historical
differences on the time offset of the same geographical
area.

Have a good weekend :)

On 05/29/2015 06:00 PM, Carl Meyer wrote:

Hi aRkadeFR,

On 05/29/2015 02:09 AM, aRkadeFR wrote:

Indeed, the problem comes from the representation on PG,
cause I have only good results (0/30 for the minutes) from
the python function.

[snip]

The OP already found and posted the solution (see below) and it is not
related to Postgres. Here's a fuller explanation:

A pytz timezone class does not represent a single offset from UTC, it
represents a geographical area which, over the course of history, has
probably gone through several different UTC offsets. The oldest offset
for a given zone, representing the offset from before time zones were
standardized (in the late 1800s, most places) is usually called "LMT"
(Local Mean Time), and it is often offset from UTC by an odd number of
minutes.

When you create a timezone using `pytz.timezone('Europe/London')`, pytz
doesn't yet know what datetime you plan to attach the timezone object
to, so it doesn't know which historical period's offset it should use,
and it defaults to the first one in the zoneinfo database, which is
usually LMT:


import pytz
uktz = pytz.timezone('Europe/London')
uktz



You can see that this timezone object is Europe/London _LMT_, and you
can also see that it is one minute offset from UTC (that's the "23:59:00
STD" bit).

The _wrong_ way to attach a pytz timezone to a naive Python datetime is
by passing it to the `tzinfo` argument of the datetime constructor (or
by using `.replace(tzinfo=...)`). When you do this, pytz literally
attaches the exact timezone offset (London LMT, dating from the
mid-1800s) to your datetime:


from datetime import datetime
lmt_dt = datetime(2015, 6, 11, 13, 30, tzinfo=uktz)

datetime.datetime(2015, 6, 11, 13, 30, tzinfo=)

If you convert this to UTC, you'll see the effect of that mysterious one
minute offset:


lmt_dt.astimezone(pytz.utc)

datetime.datetime(2015, 6, 11, 13, 31, tzinfo=)

The _right_ way to attach a pytz timezone to a naive Python datetime is
to call `tzobj.localize(dt)`. This gives pytz a chance to say "oh, your
datetime is in 2015, so I'll use the offset for Europe/London that's in
use in 2015, rather than the one that was in use in the mid-1800s":


good_dt = uktz.localize(datetime(2015, 6, 11, 13, 30))
good_dt

datetime.datetime(2015, 6, 11, 13, 30, tzinfo=)

You can see that this datetime object is in BST (one hour offset from
UTC, at least in June) instead of LMT - a much better choice for this
century. And we can convert it to UTC and get a more sensible result:


good_dt.astimezone(pytz.utc)

datetime.datetime(2015, 6, 11, 12, 30, tzinfo=)

Since we're on the Django list here, I should also point out that
`django.utils.timezone` has a `make_aware` method which handles this
correctly for you automatically.

Interesting historical sidenote: the 1-minute offset for London LMT is
based on historical observations such as this [1]:

# From Peter Ilieve (1994-07-06):
#
# On 17 Jan 1994 the Independent, a UK quality newspaper, had a piece about
# historical vistas along the Thames in west London. There was a photo
# and a sketch map showing some of the sightlines involved. One paragraph
# of the text said:
#
# 'An old stone obelisk marking a forgotten terrestrial meridian stands
# beside the river at Kew. In the 18th century, before time and longitude
# was standardised by the Royal Observatory in Greenwich, scholars observed
# this stone and the movement of stars from Kew Observatory nearby. They
# made their calculations and set the time for the Horse Guards and
Parliament,
# but now the stone is obscured by scrubwood and can only be seen by walking
# along the towpath within a few yards of it.'
#
# I have a one inch to one mile map of London and my estimate of the stone's
# position is 51 degrees 28' 30" N, 0 degrees 18' 45" W. The longitude
should
# be within about +-2". The Ordnance Survey grid reference is TQ172761.
#
# [This yields GMTOFF = -0:01:15 for London LMT in the 18th century.]


Carl

[1] https://github.com/eggert/tz/blob/master/europe#L107



On Thu, May 28, 2015 at 11:42 PM, Daniel Grace <danwgr...@gmail.com
<mailto:danwgr...@gmail.com>> wrote:

 I used this function, seemed to tidy up the problem:

 from datetime import datetime
 from pytz import timezone

 def utcDtTm(self, dt_tm):
 tz = timezone('Europe/London')
 return
 tz.normalize(tz.localize(dt_tm)).astimezone(timezone('UTC'))


--
aRkadeFR

--
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+unsubs

Re: Why the extra minute in PostgreSQL when using time zone info?

2015-05-29 Thread aRkadeFR

Hey,

Indeed, the problem comes from the representation on PG,
cause I have only good results (0/30 for the minutes) from
the python function.

I don't get though why it is showing the wrong datetime.
@Avraham: It's not the representation of the timezone offset.
It's a false representation. He is not talking about the *+01*
at the end, but why it is 31 or 1 minute on the datetime.

Correct me if I'm wrong.

On 05/29/2015 08:42 AM, Avraham Serour wrote:

this is not an extra minute, it is a representation of the timezone offset

On Thu, May 28, 2015 at 11:42 PM, Daniel Grace <danwgr...@gmail.com 
<mailto:danwgr...@gmail.com>> wrote:


I used this function, seemed to tidy up the problem:

from datetime import datetime
from pytz import timezone

def utcDtTm(self, dt_tm):
tz = timezone('Europe/London')
return
tz.normalize(tz.localize(dt_tm)).astimezone(timezone('UTC'))

-- 
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
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto: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/12a0ab90-8108-46b4-8e90-5aadedbb3d2c%40googlegroups.com

<https://groups.google.com/d/msgid/django-users/12a0ab90-8108-46b4-8e90-5aadedbb3d2c%40googlegroups.com?utm_medium=email_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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/CAFWa6tJp2CLSSqzkiOMyGysGzxk%3DyhP2OD23toS1FOb43%3D%3D3Dg%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAFWa6tJp2CLSSqzkiOMyGysGzxk%3DyhP2OD23toS1FOb43%3D%3D3Dg%40mail.gmail.com?utm_medium=email_source=footer>.

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


--
aRkadeFR

--
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/55681EAB.9020602%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: datepicker

2015-05-27 Thread aRkadeFR

Hey,

Look at the widgets in the fields forms:
https://docs.djangoproject.com/en/1.8/ref/forms/widgets/

Implement your own widget, so it includes the javascript
and the css your datepicker needs.

Then render it in your template (the medias included).

Have a good one

On 05/26/2015 07:30 PM, sum abiut wrote:

Hi,
Is there a way to implement jquery datepicker with Django models. I am 
looking at http://jqueryui.com/datepicker/ but i am finding very 
difficult to apply it to django models. any help will be very much 
appreciated.


Cheers


--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/CAPCf-y735T-8%3DNVdePFU7UEmN_9SQmsLj9uWUeCQ%2B-dRUMNYjQ%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAPCf-y735T-8%3DNVdePFU7UEmN_9SQmsLj9uWUeCQ%2B-dRUMNYjQ%40mail.gmail.com?utm_medium=email_source=footer>.

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


--
aRkadeFR

--
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/5565749D.2060101%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: how to do a django data migration on a massive Postgres data table (solved)

2015-05-26 Thread aRkadeFR

Thanks for the email on the django-user ML.

I don't see the gist though, is the problem from me?

On 05/22/2015 09:09 PM, Vernon D. Cole wrote:
Django migrations are run in a single transaction (if your database is 
capable of doing a rollback of DDL, as PostgreSQL is) so data 
migrations of large tables become impossible.


I was able to solve this problem by having the migration run a no-wait 
subprocess which performs the data migration using raw SQL without the 
django ORM.  In order to keep things together, the subprocess is 
contained in the same source file as the migration... when run as a 
module it runs itself as a main program.  In my case, it ran for about 
two days, converting my 10 million row table 1000 rows at a time. 
[Actually, I had to restart it three times by pretending to remove it 
and then re-applying it.]


In case I need to do it some other time, I am putting the code into a 
GIST.  I am posting here so that others may find it when searching for 
the right keywords...

https://gist.github.com/9adedbab1899224a4eaf.git

--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/86fda457-03a2-4ef7-9d3f-e540fa0e8c1d%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/86fda457-03a2-4ef7-9d3f-e540fa0e8c1d%40googlegroups.com?utm_medium=email_source=footer>.

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


--
aRkadeFR

--
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/55644FCD.5090002%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: How to get selects option value !!

2015-05-19 Thread aRkadeFR

Are you sure you're doing Django?

It looks like flask to me.

On 05/19/2015 06:01 PM, Reznov Ammar wrote:

Hey guys,

I've had created a search form, and i need to send a post request to 
my python file to get information .


Here is my html code :

  

  

  Область/Город республиканского значения
  
нет
value1
value2
value3
value4
value5
value6
7
8
value9
  



and here is my python file :

@app.route('/serviceidlookup', methods=["GET", "POST"])
def serviceidlookup():
reload(sys)
sys.setdefaultencoding("utf-8")
sys.stdout.encoding
serviceid = request.form.get('serviceid')
areaid = request.form.get('areaid')
con = psycopg2.connect(**config)
cur = con.cursor()
cur.execute("select ate,ate_type,name_kg,name_ru,name_en,parent 
from ate_history where ate in (select ate from street_ate where street 
in (select street from street_history where name_ru = '(*value of 
serviceid*)') and ate = '(*value of areaid*)')" %(serviceid,areaid))
entries = [dict(ate=row[0], ate_type=row[1], name_kg=row[2], 
name_ru=row[3], name_en=row[4], parent=row[5]) for row in cur.fetchall()]



return render_template('lookup.html', serviceid=serviceid, 
entries=entries)


What i need is the options texts to get inside serviceid and the 
values to get inside areaid !!


please any help, because here i got confused really !!!
--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/c341c1e2-6aab-4479-8f51-8f021775133b%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/c341c1e2-6aab-4479-8f51-8f021775133b%40googlegroups.com?utm_medium=email_source=footer>.

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


--
aRkadeFR

--
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/555B5F36.5010204%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: possible bug - CharField accepts string as max_length

2015-05-18 Thread aRkadeFR

Hey,

And is the CharField is really 16 char max_length in DB if
you specifiy a string '16'?

On 05/15/2015 10:53 AM, Santiago L wrote:

Hi,

I think that I have found a bug on the system check: it accepts a 
string as value for CharField.max_length argument.


It happens only if the string can be converted to int (e.g. 
max_length='16'). Otherwise shows fields.E121 error (e.g. 
max_length='foo').


|
fromdjango.db importmodels

classFoo(models.Model):
bar =models.CharField(max_length='16')


# following code raises an Exception
obj =Foo(bar='lorem ipsum')
obj.clean_fields()
|


Traceback:
|
>>> obj = Foo(bar='lorem ipsum')
>>> obj.clean_fields()
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/usr/local/lib/python3.4/dist-packages/django/db/models/base.py", 
line 1167, in clean_fields

setattr(self, f.attname, f.clean(raw_value, self))
  File 
"/usr/local/lib/python3.4/dist-packages/django/db/models/fields/__init__.py", 
line 589, in clean

self.run_validators(value)
  File 
"/usr/local/lib/python3.4/dist-packages/django/db/models/fields/__init__.py", 
line 541, in run_validators

v(value)
  File 
"/usr/local/lib/python3.4/dist-packages/django/core/validators.py", 
line 280, in __call__

if self.compare(cleaned, self.limit_value):
  File 
"/usr/local/lib/python3.4/dist-packages/django/core/validators.py", 
line 319, in 

compare = lambda self, a, b: a > b
TypeError: unorderable types: int() > str()
|

Best regards,

Santiago
--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/7f920d86-1657-4922-a6a6-603ab0f846a3%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/7f920d86-1657-4922-a6a6-603ab0f846a3%40googlegroups.com?utm_medium=email_source=footer>.

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


--
aRkadeFR

--
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/5559966E.5080608%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Possible bug in QuerySet API when chaining filter() and update() methods?

2015-05-18 Thread aRkadeFR

Hey!

Maybe you should open a ticket :)

Have a good one

On 05/14/2015 08:13 PM, Alejandro Treviño wrote:

Hello everyone, first-time poster here!

I ran into an interesting scenario earlier today that I thought was 
worth sharing:


Given this update statement using the django ORM:

>>> pks = MyModel.objects.all().values_list('pk', flat=True)
>>> pks
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, '...(remaining elements 
truncated)...']

>>> MyModel.objects.filter(pk__in=pks).update(foo_field=True)

When pks is a "reasonably small" size, the django ORM generates this 
(valid) SQL statement:


UPDATE `djangoapp_mymodel` SET `foo_field` = 1 WHERE 
`djangoapp_mymodel`.`id` IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)


However, when pks is very large (300k records on my data set), it 
generates this instead:


UPDATE `djangoapp_mymodel` SET `foo_field` = 1 WHERE 
`djangoapp_mymodel`.`id` IN (SELECT U0.`id` FROM `djangoapp_mymodel` U0)


Which is not allowed in MySQL:

django.db.utils.OperationalError: (1093, "You can't specify target 
table 'djangoapp_mymodel' for update in FROM clause")



I'm wondering if this classifies as a bug, or if this is just a known 
limitation?  My workaround is to just do the updates in smaller 
batches.  An update on 100k records still generated valid SQL for me, 
but I haven't done enough testing to figure out what cut-off point is.


*Environment:*
Python 3.4.2
Django 1.8.1

mysql  Ver 14.14 Distrib 5.5.43, for osx10.8 (i386) using readline 5.1


Thanks!

Alex

--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/10d0d83b-733a-47d2-b5d1-6f9c904269a6%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/10d0d83b-733a-47d2-b5d1-6f9c904269a6%40googlegroups.com?utm_medium=email_source=footer>.

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


--
aRkadeFR

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


Re: Django Limitation

2015-05-11 Thread aRkadeFR

Please refer to all existing project in django:
http://stackoverflow.com/questions/886221/does-django-scale

:)

On 05/11/2015 06:15 PM, Arindam sarkar wrote:

can django be used for large projects ?

--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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%2BrAZ7eeueOSbh7x33ARQEgTpCR156t4xpFyrco2SGgzMjQ%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAGnF%2BrAZ7eeueOSbh7x33ARQEgTpCR156t4xpFyrco2SGgzMjQ%40mail.gmail.com?utm_medium=email_source=footer>.

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


--
aRkadeFR

--
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/5550D767.5080406%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Admin site in Django 1.8 tutorial giving CSRF errors

2015-05-11 Thread aRkadeFR

Can you provide us more information?
Your url / views + admin.py and the settings
at least?

Thanks

On 05/07/2015 05:36 PM, David Riddle wrote:

No I have not made any changes to the admin templates. I simply
followed the instructions in the tutorial. I am using Django's
runserver per the tutorial instructions. I am totally stumped.

David

On Thu, May 7, 2015 at 3:04 AM, aRkadeFR <cont...@arkade.info> wrote:

Hey,

You shouldn't see these errors since the templates with the form
and so the CSRF token are generated from the contrib app admin.

Could you provide us more details of the error? Did you override
the admin templates?

Thanks,

aRkadeFR


On 05/06/2015 10:03 PM, David Riddle wrote:

Hi,

I am working through the Django 1.8 tutorial. I finished part one and
am starting on part 2. I created an admin user but when I login to the
/admin page I receive a 403 Error because CSRF verification failed.

https://docs.djangoproject.com/en/1.8/intro/tutorial02/

Any idea what the problem is?

Thanks,

David R.


--
aRkadeFR

--
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/554B1CA7.2090800%40arkade.info.
For more options, visit https://groups.google.com/d/optout.





--
aRkadeFR

--
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/555061BD.1090700%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Admin site in Django 1.8 tutorial giving CSRF errors

2015-05-07 Thread aRkadeFR

Hey,

You shouldn't see these errors since the templates with the form
and so the CSRF token are generated from the contrib app admin.

Could you provide us more details of the error? Did you override
the admin templates?

Thanks,

aRkadeFR

On 05/06/2015 10:03 PM, David Riddle wrote:

Hi,

I am working through the Django 1.8 tutorial. I finished part one and
am starting on part 2. I created an admin user but when I login to the
/admin page I receive a 403 Error because CSRF verification failed.

https://docs.djangoproject.com/en/1.8/intro/tutorial02/

Any idea what the problem is?

Thanks,

David R.



--
aRkadeFR

--
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/554B1CA7.2090800%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: How to find a view in a complex web application

2015-04-28 Thread aRkadeFR

I dont quite get your request.

Where is your starting point to search the user view?
When you say "a user wants to use", where does it
come from? A template view? A view_name maybe?
A URL?

On 04/28/2015 11:27 AM, guettli wrote:

We have a complex intranet application.

It has many view.

The problem: How to find the view a user wants to use?

A huge sitemap HTML does not help.

Is there a way to search the matching view?

Maybe even with auto complete?


--
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/b933d0e6-dcb4-4be2-90c3-aeb943924cdd%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/553F56F5.1020208%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Slowness of the resulting squashed migration

2015-04-27 Thread aRkadeFR

Thanks for the answer.

Right now, I just know that after squashing some migrations,
it created a squashed migrations with CreateModel + AlterField
and AddField after that runs on 5seconds, and now that I put
all the field in the CreateModel without any AlterField or AddField,
it runs on <2secondes.

I had some custom RunPython function in the migrations but
removed it for the squashing.

I will dig a bit more and open a ticket if I can reproduce it :)

Have a good day

On 04/24/2015 09:09 PM, Markus Holtermann wrote:

Hi,

In principle it is possible to write your own or modify existing 
migrations unless they are already applied.


Regarding the additional AddField() operations: in case you have e.g. 
circular references between two models Django cannot add both models 
with their full columns at the same time. Django first adds one model 
without the ForeignKey, then the second model including the FK to the 
first model and finally adds the field to the first model pointing to 
the second model [1]. Bottom line: if you find a way to optimize 
something in your squashed migration, feel free to go ahead. It would 
be helpful if you report this as an enhance to our issue tracker [2] 
so we can include a possible improvement in future Django versions.


/Markus

[1] Have a look at slide 14f 
of https://speakerdeck.com/andrewgodwin/migrations-under-the-hood

[2] https://code.djangoproject.com/

On Friday, April 24, 2015 at 8:14:34 PM UTC+2, aRkadeFR wrote:

Hello,

After working on a project and having around 10 migrations per app,
I wanted to refactor some migrations (of the same app) into only one
and have a faster migrations while testing.

I did squashmigrations on many of the migrations, but the resulting
squased migration is still pretty slow (around 6 seconds to create 4
tables on MySQL 5.5 without any data inserted).

After looking at the migrations, there is some
CreateModel(name='')
and after the table creation some AddField on the same
table/models...

I would like to know if it's safe to change the migrations by
hand? Is
there a reason the squashmigrations didn't refactor into only
CreateModel
without AddField then?

Thanks

    aRkadeFR



--
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/553E0EFE.60902%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Slowness of the resulting squashed migration

2015-04-24 Thread aRkadeFR

Hello,

After working on a project and having around 10 migrations per app,
I wanted to refactor some migrations (of the same app) into only one
and have a faster migrations while testing.

I did squashmigrations on many of the migrations, but the resulting
squased migration is still pretty slow (around 6 seconds to create 4
tables on MySQL 5.5 without any data inserted).

After looking at the migrations, there is some CreateModel(name='')
and after the table creation some AddField on the same table/models...

I would like to know if it's safe to change the migrations by hand? Is
there a reason the squashmigrations didn't refactor into only CreateModel
without AddField then?

Thanks

aRkadeFR

--
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/553A87EB.9080506%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: upgrading from Django 1.6 and south to Django 1.8

2015-04-22 Thread aRkadeFR

Hey there,

maybe you found some answers in my other post:
"django contrib auth last_login cannot be "null""

Did you run makemigrations ?

For the upgrade, I suggest to you to do it minor
version to minor version.


On 04/20/2015 09:04 PM, Scott Hostovich wrote:

I'm upgrading from Django 1.6 and south to Django 1.8.

Following the instructions 
at: https://docs.djangoproject.com/en/1.8/topics/migrations/#upgrading-from-south 
seems to work initially but then realize that the user model wasn't 
updated: https://github.com/django/django/tree/1.8/django/contrib/auth/migrations. 



I am using a custom user model but it only tacks on a field and some 
properties. Anyone else come across 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/75e22f40-5beb-405c-8360-cb6a98e8f87f%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/5537BABA.2040607%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: django contrib auth last_login cannot be "null"

2015-04-22 Thread aRkadeFR

Indeed this was the problem.

Thanks for your answer and I got it through IRC too.

Have a good day

On 04/21/2015 07:13 PM, Tim Graham wrote:
This seems to be a common point of confusion. I'll add a sentence to 
release notes under the "``AbstractUser.last_login`` allows null 
values" section -- if this makes sense:


If you are using a custom user model, you'll need to run 
:djadmin:`makemigrations` and generate a migration for your app.


On Tuesday, April 21, 2015 at 12:27:57 PM UTC-4, aRkadeFR wrote:

Hello,

I'm upgrading my systems to Django 1.8 and I'm facing this error:
(1048, "Column 'last_login' cannot be null")

so I describe my table in DB:

+-+--+--+-+-++

| Field   | Type | Null | Key | Default |
Extra  |

+-+--+--+-+-++

| last_login  | datetime | NO   | | NULL
||


and yep, it is not nullable, but the 0005_alter_user_last_login_null
migrations
is run, so why this field is not nullable?
How can I debug this?

PS: I run ./manage.py migrate (without --fake option)
and I use the AbstractUser as my base class.

Thanks and have a good one



--
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/55376E27.6000208%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


django contrib auth last_login cannot be "null"

2015-04-21 Thread aRkadeFR

Hello,

I'm upgrading my systems to Django 1.8 and I'm facing this error:
(1048, "Column 'last_login' cannot be null")

so I describe my table in DB:
+-+--+--+-+-++
| Field   | Type | Null | Key | Default | 
Extra  |

+-+--+--+-+-++
| last_login  | datetime | NO   | | NULL 
||



and yep, it is not nullable, but the 0005_alter_user_last_login_null 
migrations

is run, so why this field is not nullable?
How can I debug this?

PS: I run ./manage.py migrate (without --fake option)
and I use the AbstractUser as my base class.

Thanks and have a good one

--
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/55367A76.7050509%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Django admin page display unnormal

2015-04-13 Thread aRkadeFR

Your static files are not served properly.

Please, run the collectstatic command and see if the admin
static files are copied.

Check in your browser that the files media are served then.

aRkadeFR

On 04/13/2015 05:04 AM, zli wrote:


It is my admin add user page

<https://lh3.googleusercontent.com/-ofDeQzCP3P4/VSswff7MRfI/ABc/01fZsQDeV8w/s1600/useradd.png>

It is static_root setting

<https://lh3.googleusercontent.com/-QnN2lnPdtVw/VSsx_8ZtudI/ABo/kFY78r__M10/s1600/setting.png>



--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/226a43b2-4918-43f1-9e12-3cb716c05d8b%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/226a43b2-4918-43f1-9e12-3cb716c05d8b%40googlegroups.com?utm_medium=email_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/552BBB58.8040405%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Saving Contionus Data through Django

2015-04-02 Thread aRkadeFR

Not sure Django is the best solution to your problem.

As Ilya said, you should buffer it. Then you can work
with your buffered data. You said one entry every minute,
so the "buffer" can just send this entry every minute to
a Django project?

On 04/02/2015 04:34 PM, Ilya Kazakevich wrote:

You can't just store stream in database.
You need to buffer it first, and then save to field like 
blob: http://www.postgresql.org/docs/9.1/static/datatype-binary.html


I am not sure that relational database is the best place to store 
binary data coming from devices.



On Thursday, April 2, 2015 at 5:10:23 PM UTC+3, nitinag...@gmail.com 
wrote:


Hello All

I am new to Django. And, I need help in models file.
I made a table - device_list. It contain one filed as device_id.
Now, I need to store 3 continuous data stream which is coming like
1 entry per minute each for this device_id.
All 3 data streams will have different timestamps and that also
needs to be stored.

So, what is the best way to store the stream ?




--
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/69d2b2a4-5928-488f-a923-f03750d1eea6%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/551D5698.6000608%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: subprocess behave diferent in the server than in the client.

2015-03-31 Thread aRkadeFR

What is your production stack (nginx/uwsgi/permissions folder etc. etc.)?
Do you have any logger / stack trace to debug it?

Thanks

On 03/31/2015 05:12 PM, dk wrote:
playing a littlie bit more, I found out that does work if I am using 
the manage.py runserver.

but doesn't work using the production django =(.



On Monday, March 30, 2015 at 5:53:59 PM UTC-5, dk wrote:

hi, I have a button in my webpage that lunch a subprocess and
check the ping of the computer and save the information in a text
file. that's it,  very basic stuff.

If I am doing my click in the server computer everything works,
the subprocess will ping the computer, make the file and save the
information.
and go back the corresponding view.


but if I do it from a client computer,  does all the script, 
return the view that needs to return, but it never lunched the

subprocess =(.   is like that line was commented or something
doesn't even complain or spits errors =(

have any one got an issue 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bb43b536-352e-4eb0-b32a-485860d19e13%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/551ACF38.2040601%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Hidden fields in formsets

2015-03-31 Thread aRkadeFR

Hello,

I read very quickly, but you sure you want to *render* and get the value
of "user_create" from the client?
It can be modified by any client...

aRkadeFR

On 03/31/2015 10:45 AM, François GUÉRIN wrote:

Hi,

I'm using multiple formsets in Create / Update views, and I want to 
set some *hidden* fields in it : user_create, date_create on creation, 
user_update, date_update on update.


I've created a MultiFormsetMixin, which provide machinery to 
initialize those formsets in my CreateView / UpdateView.
Basicaly, the mixin fill a formset_list containing dicts with 
{'formset': , 'name': , 'verbose_name': 
}... The rendering of the formsets uses the same 
rendering than 'normal' formsets, via a {%for formset in formset_list 
%}{# formset rendering #}[% endfor %}. The formsets display normaly.


Data initialization is performed through the 'initial' dict. Every 
forms in the formsets have the same values for those fields, at 
initialization, so I update each form of the formsets with those values.


My problem is that those hidden fields are not rendered in the 
template, even in a 'hidden_field'. I've tryed to set 'exclude' and 
'hidden_fields' Meta option in my ModelForm object, but it doesn't work.


When I go through the 'form.hidden_fields' I have my formset 
administrative normal data (id, parent) but not my fields.


Is it possible to render those fields in the template ?

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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/13de9082-3dd5-4b3c-bb72-7393e3f0884c%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/13de9082-3dd5-4b3c-bb72-7393e3f0884c%40googlegroups.com?utm_medium=email_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/551ACE9D.3050008%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: authenticate() not working

2015-03-30 Thread aRkadeFR

Hello,


Just by changing the type of your input, you're enable to
authenticate inside your view then?

Do a dump of your post data to see if anything has changed.
```
print("data: {!s}".format(request.POST))
```

Then you can see in a shell (manage.py shell) if the authenticate
function works as expected with your data.

On 03/28/2015 10:36 AM, Kishan Mehta wrote:

Hi all,

>>My html has following input type :

Password: 


>>  user = authenticate(username=username, password=password)
is not able to authenticate in views.py...

Not able to login.

P.S :
when i do :

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/9b40bc4f-09ad-4697-b2a7-5d4881acd496%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/55191B65.4040804%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Textarea taking htnml tags

2015-03-27 Thread aRkadeFR

Hey,

He doubled post. A thread already exists about this called:
"textarea showing image instead of code"


On 03/27/2015 03:54 PM, Filipe Ximenes wrote:

Can you send us the code of the view and the template of this form?

On Fri, Mar 27, 2015 at 3:27 AM, > wrote:


Hie to all,
In one of my template i am using text area. The issue is that when
i write html tags with some image link using img tag, when i am
saving this i am getting image on the desription field.

Actual-Image is comming

Expected-I want HTML code to be displayed in the discription.

Please suggest
-- 
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/32bb3e0a-1eb1-46d1-94fe-4135c7c916df%40googlegroups.com

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




--

*Filipe Ximenes
*+55 (81) 8245-9204*
**Vinta Software Studio
*http://www.vinta.com.br

--
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/CAA-QWB3OPdmK11XzPFf--2MBT6evTDu-RuRrPArem1PbZT2FmA%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/55159AA1.9070605%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: textarea showing image instead of code

2015-03-27 Thread aRkadeFR

What is db.TextProperty!? Is it Django?
Where the "result" variable comes from?

please read:
https://docs.djangoproject.com/en/1.7/ref/models/


On 03/27/2015 10:20 AM, Akash Patni wrote:

Hi This is my html

{% block content %}



  
src="/site_media/images/digital-assets-note-icon.png" alt="Notes" />

View Notes
See your notes details.
  
  

{% for i in result %}

 Note Title
 {{i.note_title}}



 Note
*{{i.note}*




 Beneficiaries
 
   {% if all_nominees %}
   {% for nominee in all_nominees %}
   {% if nominee.1 %}
 {{nominee.0.first_name}} {% if nominee.last_name 
%}{{nominee.last_name}}{% endif %} {% if nominee.0.is_charity 
%}(charity){% else %}(individual){% endif %}

 
   {% endif %}
   {% endfor %}
{% else %}
No beneficiaries at the moment.
{% endif %}
 




 Action
 
 href="/user/notes/edit?id={{i.key}}">Edit
 href="/user/notes/delete?id={{i.key}}" onclick="return 
deleteConfirmation();">Delete

 


  {% endfor %}

{% endblock %}

This is my model

class AssetNotes(db.Model):
user_id = db.ReferenceProperty(User)
written_on = db.DateProperty(verbose_name="Note Date")
note_title = db.StringProperty(verbose_name = "Note Title *")
note = db.TextProperty(verbose_name = "Note")
add_date = db.DateTimeProperty(verbose_name=None, auto_now_add=True)
update_date = db.DateTimeProperty(verbose_name=None, auto_now=True)
client_id = db.StringProperty(verbose_name = "Client ID", default="")
def __unicode__(self):
return self.note_title
I want to show only code but instead of that it is showing image in 
descrption field.


and the code contains image url.

On Fri, Mar 27, 2015 at 2:41 PM, aRkadeFR <cont...@arkade.info 
<mailto:cont...@arkade.info>> wrote:


Hello,

You could provide us more information when asking for
help please. Your template and view code at least.

I guess your problem is in your HTML but to be sure, please
dump your information at the POST request to see what
is send. Then review your template. Maybe there's a "name"
attribute on the img tag?

Have a good one

On 03/27/2015 08:36 AM, akash.pa...@ranosys.com
<mailto:akash.pa...@ranosys.com> wrote:

Hie to all,
In one of my template i am using text area. The issue is that
when i write html tags with some image link using img tag, when i
am saving this i am getting image on the desription field.

Actual-Image is comming

Expected-I want HTML code to be displayed in the discription.

Please suggest

-- 
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
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to
django-users@googlegroups.com <mailto: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/597ca45f-a1d9-43a4-a77b-a4ffc29d1b69%40googlegroups.com

<https://groups.google.com/d/msgid/django-users/597ca45f-a1d9-43a4-a77b-a4ffc29d1b69%40googlegroups.com?utm_medium=email_source=footer>.
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/6bheSzmXFGc/unsubscribe.
To unsubscribe from this group and all its topics, send an email
to django-users+unsubscr...@googlegroups.com
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto: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/55151EC7.3090403%40arkade.info

<https://groups.google.com/d/msgid/django-users/55151EC7.3090403%40arkade.info?utm_medium=email_source=footer>.


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




--
*Best Regards,*
Akash Patni
Software Engineer
*
*
*
**
ranosys <http://ranosys.com/>
facebook <https://www.facebook.com/ranosys> 	twitter 
<https://twitter.com/ranosys> 	linkedin 
<https://www.linkedin.com/company/741079?trk=prof-exp-company-name> 
googleplus <https://plus.google.com/+Ranosys> 	


*Head Office: *
Oxley Bizhub, #06-48 | 73 Ubi Road 1 | Singapore - 408733
*Tel:* +65 66331556 | *HP: *+65 98573420

**

*
**

*Global Offices:*
San 

Re: When I mark to delete the formset, django requires complete all fields, he does not ignore the marked form to delete.

2015-03-27 Thread aRkadeFR

Thanks for the code paste.

You mean in your views, the formset.is_valid() returns False
and so does not delete your form tagged to delete?

I don't quite understand where exactly is the problem?


On 03/27/2015 12:17 AM, Neto wrote:
When I mark to delete the formset, django requires complete all 
fields, he does not ignore the marked form to delete. How do I solve 
this? I wanna that django delete the form marked or ignore him.


from  django.forms.formsets  import  formset_factory
>>>from  myapp.forms  import  ArticleForm
>>>ArticleFormSet  =  formset_factory(ArticleForm,  can_delete=True, min_num=1, 
extra=0)


 {{  formset.management_form  }}
 {%  for  form  in  formset  %}
 
 {{  form.title  }}
 {{  form.pub_date  }}
 {%  if  formset.can_delete  %}
 {{  form.DELETE  }}
 {%  endif  %}
 
 {%  endfor  %}

--
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/7ecb3486-818c-4051-84e2-168b506b5c10%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/55151F97.8020400%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: textarea showing image instead of code

2015-03-27 Thread aRkadeFR

Hello,

You could provide us more information when asking for
help please. Your template and view code at least.

I guess your problem is in your HTML but to be sure, please
dump your information at the POST request to see what
is send. Then review your template. Maybe there's a "name"
attribute on the img tag?

Have a good one

On 03/27/2015 08:36 AM, akash.pa...@ranosys.com wrote:

Hie to all,
In one of my template i am using text area. The issue is that when i 
write html tags with some image link using img tag, when i am saving 
this i am getting image on the desription field.


Actual-Image is comming

Expected-I want HTML code to be displayed in the discription.

Please suggest

--
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/597ca45f-a1d9-43a4-a77b-a4ffc29d1b69%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/55151EC7.3090403%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Global access to request.user

2015-03-27 Thread aRkadeFR

I agree with Anderson, this is one solution, even
though I don't know if it's a good way.

For example a middleware is used to add the user to
the request. You could do the same with the request
to a singleton instance and get it back then from your
form, view etc.? But be aware that some function should
work within the request cycle or without.

A filter or tag is only a way to process/render data inside
the templates. I don't see it as a solution.

On 03/26/2015 05:19 PM, Esau Rodriguez wrote:

I don't see how middleware could be used to avoid passing the user or
request parameter to the inner methods.

As this is part of the view, I'd probably write a custom filter or tag, I dunno.

Regards,
Esau.

On Thu, Mar 26, 2015 at 2:52 PM, Anderson Resende
 wrote:

You can use middlewares!!! It is a way...


--
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/2c55f576-7012-49a2-bd53-a8e5fdc4754a%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/55151A6B.2030100%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing django app from another app with ajax

2015-03-26 Thread aRkadeFR

No problem we agree that having a stacktrace would be
a better way to debug it.

Even on a 400 :)

On 03/26/2015 03:48 PM, Filipe Ximenes wrote:

My mistake.


On Thu, Mar 26, 2015 at 11:42 AM, aRkadeFR <cont...@arkade.info 
<mailto:cont...@arkade.info>> wrote:


But from the first email, the debug settings is already at True
and he is not getting a stacktrace...


On 03/26/2015 03:40 PM, Filipe Ximenes wrote:

In case there's no one using your project and there's no
sensitive data in it, you can briefly set DEBUB to True in the
server to see stack traces.

On Thu, Mar 26, 2015 at 11:26 AM, Larry Martell
<larry.mart...@gmail.com <mailto:larry.mart...@gmail.com>> wrote:

On Thu, Mar 26, 2015 at 10:20 AM, aRkadeFR
<cont...@arkade.info <mailto:cont...@arkade.info>> wrote:
> You should setup your project so you're able to retrieve the
> stacktrace on a 500 server error.

When there is a stack trace I get it (e.g. when I was getting
the 403
error). There was no stack trace when I was getting the 500.
But the
500 is resolved. I am now fighting the 400 error, which also
gives no
stack trace.


>
>
> On 03/26/2015 12:25 PM, Larry Martell wrote:
>>
>> On Thu, Mar 26, 2015 at 7:22 AM, aRkadeFR
<cont...@arkade.info <mailto:cont...@arkade.info>> wrote:
>>>
>>> Do you have the stacktrace? Without it it's gonna be hard
>>> to help you.
>>>
>>> My only guess is CORS (Cross-Origin Resource Sharing)? But
>>> you should have the same error on local dev if you have
similar
>>> setup from your production.
>>
>> There was no stacktrace. But I figured that this issue - I
did not
>> have a slash on the end of the URL. I added that, then
instead of a
>> 500 I got a 403 Forbidden, because it didn't like the CSRF
token, but
>> I am sending that. So I disabled CSRF and then I get a 400 bad
>> request, again no stacktrace. ALLOWED_HOSTS is ['*'] so
that's not the
>> cause.
>>
>>
>>>
>>> On 03/26/2015 02:04 AM, Larry Martell wrote:
>>>>
>>>> I have a webservice written in django and I want to call
it from a non
>>>> django app with ajax. Both apps run on the same host.
When I call the
>>>> webservice with curl it works fine, but when I call it
with ajax from
>>>> the other app I get a 500 internal server error. There
are no errors
>>>> in the web server log. DEBUG is True, and ALLOWED_HOSTS
= ['*']. When
>>>> I run the dev server and connect to that I get no
errors, just the 500
>>>> error. I tried setting a breakpoint in the view, but it
never makes it
>>>> there.
>>>>
>>>> Anyone have any ideas as to why this is happening or how
I could debug
>>>> it further?

--
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
<mailto:django-users%2bunsubscr...@googlegroups.com>.
To post to this group, send email to
django-users@googlegroups.com
<mailto: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/CACwCsY5Ea%3DiJbXMfC14Ep-fQ%2BCjE7RYzu4XZ5xiDCUUECGXB7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.




-- 


*Filipe Ximenes
*+55 (81) 8245-9204 <tel:%2B55%20%2881%29%208245-9204>*
**Vinta Software Studio
*http://www.vinta.com.br

-- 
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
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to
django-users@googlegroups.com <mailto: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.c

Re: Accessing django app from another app with ajax

2015-03-26 Thread aRkadeFR

But from the first email, the debug settings is already at True
and he is not getting a stacktrace...

On 03/26/2015 03:40 PM, Filipe Ximenes wrote:
In case there's no one using your project and there's no sensitive 
data in it, you can briefly set DEBUB to True in the server to see 
stack traces.


On Thu, Mar 26, 2015 at 11:26 AM, Larry Martell 
<larry.mart...@gmail.com <mailto:larry.mart...@gmail.com>> wrote:


On Thu, Mar 26, 2015 at 10:20 AM, aRkadeFR <cont...@arkade.info
<mailto:cont...@arkade.info>> wrote:
> You should setup your project so you're able to retrieve the
> stacktrace on a 500 server error.

When there is a stack trace I get it (e.g. when I was getting the 403
error). There was no stack trace when I was getting the 500. But the
500 is resolved. I am now fighting the 400 error, which also gives no
stack trace.


>
>
> On 03/26/2015 12:25 PM, Larry Martell wrote:
>>
    >> On Thu, Mar 26, 2015 at 7:22 AM, aRkadeFR <cont...@arkade.info
<mailto:cont...@arkade.info>> wrote:
>>>
>>> Do you have the stacktrace? Without it it's gonna be hard
>>> to help you.
>>>
>>> My only guess is CORS (Cross-Origin Resource Sharing)? But
>>> you should have the same error on local dev if you have similar
>>> setup from your production.
>>
>> There was no stacktrace. But I figured that this issue - I did not
>> have a slash on the end of the URL. I added that, then instead of a
>> 500 I got a 403 Forbidden, because it didn't like the CSRF
token, but
>> I am sending that. So I disabled CSRF and then I get a 400 bad
>> request, again no stacktrace. ALLOWED_HOSTS is ['*'] so that's
not the
>> cause.
>>
>>
>>>
>>> On 03/26/2015 02:04 AM, Larry Martell wrote:
>>>>
>>>> I have a webservice written in django and I want to call it
from a non
>>>> django app with ajax. Both apps run on the same host. When I
call the
>>>> webservice with curl it works fine, but when I call it with
ajax from
>>>> the other app I get a 500 internal server error. There are no
errors
>>>> in the web server log. DEBUG is True, and ALLOWED_HOSTS =
['*']. When
>>>> I run the dev server and connect to that I get no errors,
just the 500
>>>> error. I tried setting a breakpoint in the view, but it never
makes it
>>>> there.
>>>>
>>>> Anyone have any ideas as to why this is happening or how I
could debug
>>>> it further?

--
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
<mailto:django-users%2bunsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto: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/CACwCsY5Ea%3DiJbXMfC14Ep-fQ%2BCjE7RYzu4XZ5xiDCUUECGXB7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.




--

*Filipe Ximenes
*+55 (81) 8245-9204 <tel:%2B55%20%2881%29%208245-9204>*
**Vinta Software Studio
*http://www.vinta.com.br

--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/CAA-QWB3zLJUjsA_nXpMOAQNJw13CFUtZ2Xio8op4bzOZnLxuzA%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAA-QWB3zLJUjsA_nXpMOAQNJw13CFUtZ2Xio8op4bzOZnLxuzA%40mail.gmail.com?utm_medium=email_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/55141AEC.4010300%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing django app from another app with ajax

2015-03-26 Thread aRkadeFR

You should setup your project so you're able to retrieve the
stacktrace on a 500 server error.

On 03/26/2015 12:25 PM, Larry Martell wrote:

On Thu, Mar 26, 2015 at 7:22 AM, aRkadeFR <cont...@arkade.info> wrote:

Do you have the stacktrace? Without it it's gonna be hard
to help you.

My only guess is CORS (Cross-Origin Resource Sharing)? But
you should have the same error on local dev if you have similar
setup from your production.

There was no stacktrace. But I figured that this issue - I did not
have a slash on the end of the URL. I added that, then instead of a
500 I got a 403 Forbidden, because it didn't like the CSRF token, but
I am sending that. So I disabled CSRF and then I get a 400 bad
request, again no stacktrace. ALLOWED_HOSTS is ['*'] so that's not the
cause.




On 03/26/2015 02:04 AM, Larry Martell wrote:

I have a webservice written in django and I want to call it from a non
django app with ajax. Both apps run on the same host. When I call the
webservice with curl it works fine, but when I call it with ajax from
the other app I get a 500 internal server error. There are no errors
in the web server log. DEBUG is True, and ALLOWED_HOSTS = ['*']. When
I run the dev server and connect to that I get no errors, just the 500
error. I tried setting a breakpoint in the view, but it never makes it
there.

Anyone have any ideas as to why this is happening or how I could debug
it further?


--
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/5513EBD8.2060809%40arkade.info.
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/55141598.9040208%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing django app from another app with ajax

2015-03-26 Thread aRkadeFR

Do you have the stacktrace? Without it it's gonna be hard
to help you.

My only guess is CORS (Cross-Origin Resource Sharing)? But
you should have the same error on local dev if you have similar
setup from your production.

On 03/26/2015 02:04 AM, Larry Martell wrote:

I have a webservice written in django and I want to call it from a non
django app with ajax. Both apps run on the same host. When I call the
webservice with curl it works fine, but when I call it with ajax from
the other app I get a 500 internal server error. There are no errors
in the web server log. DEBUG is True, and ALLOWED_HOSTS = ['*']. When
I run the dev server and connect to that I get no errors, just the 500
error. I tried setting a breakpoint in the view, but it never makes it
there.

Anyone have any ideas as to why this is happening or how I could debug
it further?



--
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/5513EBD8.2060809%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Django Integrate custom apps with each other

2015-03-26 Thread aRkadeFR

Hello,

Everything is an application in Django, and you can see them
in settings.INSTALLED_APPS.

Then you can include your app models/forms/etc. from
anywhere else in the project containing the previous app.

To check if the app is registrered or not, you can use the
Django Application (new in Django 1.7). Please read
https://docs.djangoproject.com/en/1.7/ref/applications/

From your example, you can have an app called "comment"
that inside has some models and can be related to anything
else, or the reverse any of your model in your project related
to some model from the comment app.

For more information, please check out the "comments" app
in django.contrib :)

Thanks

aRkadeFR

On 03/26/2015 11:37 AM, Eduardo Pascoal wrote:

Hi everyone,
I am a Django newbie and I'm facing the problem related with binding 
applications.


My intention is to make a new functionality to manage comments (i 
don't want to use disqus) and for that reason i want to create an 
application and integrate with another one that i've created in first 
place.


What is the best way to do that? How can i bind them?

It is simply like when i use django contrib auth model?

|
fromdjango.db importmodels
fromdjango.contrib.auth.models importUser

classGroup(models.Model):
groupName = models.CharField(max_length=200)
users =models.ManyToManyField(User,through='GroupWatcher')
def__unicode__(self):
returnself.groupName


|


something like this...

|
|
fromdjango.db importmodels
fromapp2.models import||MyApp2Model||

classGroup(models.Model):
groupName = models.CharField(max_length=200)
users 
=models.ManyToManyField(MyApp2Model,through='GroupWatcher')

def__unicode__(self):
returnself.groupName
|

|
--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/ca41151f-bc0f-412e-bf85-780916f90cf7%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/ca41151f-bc0f-412e-bf85-780916f90cf7%40googlegroups.com?utm_medium=email_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/5513EB2B.3010705%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Re-run only tests that failed last time

2015-03-25 Thread aRkadeFR

Great tool, thanks :)

On 03/24/2015 11:22 PM, 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

.
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 
.

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


Re: image handling

2015-03-24 Thread aRkadeFR

When do you want to delete the old image?

On 03/24/2015 10:59 AM, akash.pa...@ranosys.com wrote:

Hi ,
I want to delete the old image.

On Tuesday, March 24, 2015 at 2:40:35 PM UTC+5:30, 
akash...@ranosys.com wrote:


hi..
Can anyone please tell me how to handle old image after uploading
new image.

--
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/4aa4ac92-e622-4130-8ea0-dfbe46862c08%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/55113CF7.6060604%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Why I don't access the {{ user }} variable in template?

2015-03-23 Thread aRkadeFR

Do you have 'django.contrib.auth.context_processors.auth' in
your context template processor?

{{ user_first_name }} won't work anyway cause the variable
set by the context_processor auth is user. To access a key
or an attribute of a variable, the syntax is:
{{ user.first_name }}

documentation on the django template language:
https://docs.djangoproject.com/en/1.7/ref/templates/api/

On 03/23/2015 03:15 PM, Fellipe Henrique wrote:

Hello,

I have this settings.py [1], and my CustomUser [2]

When I try to use in my template:

{{ user_first_name }}

don't show anything... What I miss in these code?

Regards,


[1] - https://gist.github.com/fellipeh/adbfaf06361d68650f95

[2] - https://gist.github.com/fellipeh/a0cc18f26aa9868a061f

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/CAF1jwZG2Qwk8n7TGT3ZcZv7FHtnm0MH7r34PkU92N0cBo1%3DgCw%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/5510214C.4020505%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: what do you think about django FORM system?

2015-03-06 Thread aRkadeFR

So you're problem is not about forms but widgets.

The widget are the object that render a field form. You can subclass
it to render it in anyway you want.

What do you don't like in subclassing a widget/model ?

On 03/06/2015 03:38 PM, john wrote:
I can tell you what I found to be hard to understand (and I don't 
think I do understand at the moment) that is how to set the HTML, the 
types, ID, and any of the special attributes of the object.  I 
understand that I can sub-class but it's also my understanding that I 
shouldn't have too.  For example I want to use the new HTML 5 
type=month.  I'd also like to use size but so far I haven't determined 
how.  I did get the validation working.


Johnf

On 03/06/2015 02:43 AM, aRkadeFR wrote:

Hello

It's pretty easy to use django forms after reading the docs.
And django form are well integrated with the whole django framework.
You have multiple layers of cleaning the form, from the widget to the 
model, and

I love that.

Could you provide us more in-deapth of your feeling using the django 
form?

What are the problem? Or what do you expect from it?

Thanks

On 03/06/2015 11:37 AM, younger.shen wrote:

Hello everyone:

i use django since last year, and now i can not stand the django 
form any more, hard to use , especially custom error message , i use 
laravel for php development , and validator of laravel is very easy 
to use and very clean code , so i hack a small plugin .


https://github.com/youngershen/django-laravel-validator

i want your opinion my friends.  talk to me please , what is your 
opinion about django form.



every key to every locked *DREAM* 
--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/CAFp8GAKe7r7PWzBbFMsLk6PuR863-QU5%3D%2Bv%2BGQ4uA_yihFh3dw%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAFp8GAKe7r7PWzBbFMsLk6PuR863-QU5%3D%2Bv%2BGQ4uA_yihFh3dw%40mail.gmail.com?utm_medium=email_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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/54F984E9.2070701%40arkade.info 
<https://groups.google.com/d/msgid/django-users/54F984E9.2070701%40arkade.info?utm_medium=email_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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/54F9BBCD.3070408%40jfcomputer.com 
<https://groups.google.com/d/msgid/django-users/54F9BBCD.3070408%40jfcomputer.com?utm_medium=email_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/54F9C1D7.6020007%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Gunicorn sock file is missing?

2015-03-06 Thread aRkadeFR


On 03/06/2015 01:30 PM, Kaloian wrote:

Hi Erik, and thanks for the help.

Well it appears to be a permission issue after all, but I really 
cannot understand why. I tried to change the directory for the sock 
file from /webapps/my-app/run/gunicorn.sock to /sockets/gunicorn.sock 
and gunicorn started normally. I tried to give full permissions to 
/webapps/my-app/run/ but still no success. I never tried to create the 
sock file myself and the /webapps/my-app/run/ dir is empty all the 
time. I cannot understand what is stopping gunicorn from creating the 
sock file in this directory.


Did you try to sudo to the user running gunicorn and creating the socket?
Some hints:
- The user can't access the directory cause he is not allowed to index 
one of his parent

- The user isn't in one of the new group cause he is logged in
- ... ?

Most of the time sudo to the user is useful for me



Regards,
Kaloian

On Thursday, February 26, 2015 at 10:47:41 AM UTC+2, Erik Cederstrand 
wrote:



> Den 26/02/2015 kl. 07.56 skrev Kaloian :
>
> Hi Erik,
>
> No it doesn't start at all, running the gunicorn_start script
gives:
>
> [ERROR] Retrying in 1 second.
> [ERROR] Retrying in 1 second.
> [ERROR] Retrying in 1 second.
> [ERROR] Retrying in 1 second.
> [ERROR] Retrying in 1 second.
> [ERROR] Can't connect to /path/to/my/gunicorn.sock
>
> This is why I thought that the missing sock file is failing it
to start. Do you think it could be something else?
> I have already tried to add the absolute path in gunicorn_start
but nothing changed.

A UNIX socket is like a TCP connection, except it's represented as
a file. gunicorn is supposed to create it on startup and destroy
it on shutdown, and it shouldn't be present when gunicorn is not
running.

Maybe you tried to create /path/to/my/gunicorn.sock yourself, and
the file is now garbage? Try deleting it. Otherwise, another
instance of gunicorn may be running already. Try "ps aux | grep
gunicorn" or "lsof -U | grep gunicorn" if you're on Linux. Also,
the user running gunicorn_start must have access to create files
in /path/to/my/

Erik

--
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/59fe3b92-d9d7-4e03-b8f3-b0be1c355d78%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/54F9C13C.7000101%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: what do you think about django FORM system?

2015-03-06 Thread aRkadeFR

Hello

It's pretty easy to use django forms after reading the docs.
And django form are well integrated with the whole django framework.
You have multiple layers of cleaning the form, from the widget to the 
model, and

I love that.

Could you provide us more in-deapth of your feeling using the django form?
What are the problem? Or what do you expect from it?

Thanks

On 03/06/2015 11:37 AM, younger.shen wrote:

Hello everyone:

i use django since last year, and now i can not stand the django form 
any more, hard to use , especially custom error message , i use 
laravel for php development , and validator of laravel is very easy to 
use and very clean code , so i hack a small plugin .


https://github.com/youngershen/django-laravel-validator

i want your opinion my friends.  talk to me please , what is your 
opinion about django form.



every key to every locked *DREAM* 
--
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/CAFp8GAKe7r7PWzBbFMsLk6PuR863-QU5%3D%2Bv%2BGQ4uA_yihFh3dw%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/54F984E9.2070701%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Data migration using RunPython

2015-03-05 Thread aRkadeFR


On 03/05/2015 10:01 AM, Murthy Sandeep wrote:

Thanks,

Two further questions if you don’t mind:

1. I am in the Python interpreter and am working with
one of my db models called SmallGroup.

When I do SmallGroup.objects.all() I get the following message:

File "", line 1, in 
   File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 
119, in __repr__
 return repr(data)
   File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 458, 
in __repr__
 u = six.text_type(self)
TypeError: coercing to Unicode: need string or buffer, SmallGroup found

Does this have something to do with the method `__str__` which I added
to this model in my `models.py`?  I don’t think I did a ‘python manage.py 
migrate’ after
the change though.


There's two problems yeah, you didn't run your migrations, and maybe
you have unicode encoding problem.
Please, check the documentation on migration[1] and unicode[2].



2. If I want to modify or delete entries in the db table SmallGroup are there
methods corresponding to `bulk_create` for doing this?  Something like

Country.objects.using(db_alias).bulk_update(  )

Country.objects.using(db_alias).bulk_delete(  )

?


You have all you need in the documentation [3].
You have the .update and .delete methods on a queryset.


Thanks again in advance.

Sandeep


[1] migrations: https://docs.djangoproject.com/en/1.7/topics/migrations/
[2] unicode with python 2: https://docs.python.org/2/howto/unicode.html
[3] https://docs.djangoproject.com/en/1.7/topics/db/queries/


On 5 Mar 2015, at 19:34, aRkadeFR <cont...@arkade.info> wrote:

Hello,

In Django, you can instanciate objects from your model without
persist it to the database. The way you do it is Country(name=..., ...).

In order to create multiple objects at once, you can
call the bulk_create method on the manager with a list
of object to persist.

The using(db_alias) is instanciating the manager.
I won't explain further cause my knowledge of this area
is reduced.

Have a good one

On 03/05/2015 01:20 AM, Murthy Sandeep wrote:

I am working on a data migration for my Django app to populate
the main table in the db with data that will form the mainstay of
the app - this is persistent/permanent data that may added to but
never deleted.

My reference is the Django 1.7 documentation and in particular an
example on page

https://docs.djangoproject.com/en/1.7/ref/migration-operations/#django.db.migrations.operations.RunPython

with a custom method called forward_funcs:

def forwards_func(apps, schema_editor):

# We get the model from the versioned app registry;
# if we directly import it, it'll be the wrong version


Country = apps.get_model("myapp", "Country")
db_alias = schema_editor.connection.alias
Country.objects.using(db_alias).bulk_create([
Country(name="USA", code="us"),
Country(name="France", code="fr"),])

I was wondering if someone could please explain what is happening
here and how this method works - is the argument  to bulk_create a
list of namedtuple objects called Country or are these Country model
objects?

Also could someone please explain what db_alias is?

Sandeep



--
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/54F814FC.9090407%40arkade.info.
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/54F824F6.7040109%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Data migration using RunPython

2015-03-05 Thread aRkadeFR

Hello,

In Django, you can instanciate objects from your model without
persist it to the database. The way you do it is Country(name=..., ...).

In order to create multiple objects at once, you can
call the bulk_create method on the manager with a list
of object to persist.

The using(db_alias) is instanciating the manager.
I won't explain further cause my knowledge of this area
is reduced.

Have a good one

On 03/05/2015 01:20 AM, Murthy Sandeep wrote:

I am working on a data migration for my Django app to populate
the main table in the db with data that will form the mainstay of
the app - this is persistent/permanent data that may added to but
never deleted.

My reference is the Django 1.7 documentation and in particular an
example on page

https://docs.djangoproject.com/en/1.7/ref/migration-operations/#django.db.migrations.operations.RunPython

with a custom method called forward_funcs:

def forwards_func(apps, schema_editor):

# We get the model from the versioned app registry;
# if we directly import it, it'll be the wrong version


Country = apps.get_model("myapp", "Country")
db_alias = schema_editor.connection.alias
Country.objects.using(db_alias).bulk_create([
Country(name="USA", code="us"),
Country(name="France", code="fr"),])

I was wondering if someone could please explain what is happening
here and how this method works - is the argument  to bulk_create a
list of namedtuple objects called Country or are these Country model
objects?

Also could someone please explain what db_alias is?

Sandeep




--
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/54F814FC.9090407%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: icons let the template or resolve in the view?

2015-03-04 Thread aRkadeFR

If I get your request right, you want to display icons on each row
of your table.

In my projects, I'm using a font face. It's easy to use, scalable,
and you don't need any {% static %} templatetags in your templates.

Personnaly using icomoon to manage my icons.
https://icomoon.io/app/

Then you generate your font and include it in your html :)

Hope I helped you


On 03/03/2015 07:17 PM, dk wrote:
I will be populating a table with information of computers and I would 
like to display an icon in front of each line of the table. might 
change depending of the machine,  should I let the view handle that 
with and if then and later on use static to resolve the file path?

or should I make that if then and resolve the path by myself in the view?


--
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/0a3fb3f1-1c24-4fa0-a7ed-4b21a2c99430%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/54F6CF2E.2060605%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Can the new `Prefetch` solve my problem?

2015-03-03 Thread aRkadeFR

Thanks a lot for your answer :)

I will definitely use it from now on.

On 03/03/2015 06:59 AM, Simon Charette wrote:

Hi cool-RR,

The following should do:

filtered_chairs = Chair.objects.filter(some_other_lookup=whatever)
desks = Desk.objects.prefetch_related(
PrefetchRelated('chairs', filtered_chairs, to_attr='filered_chairs'),
PrefetchRelated('nearby_chairs', filtered_chairs, 
to_attr='filtered_nearby_chairs'),

)

from itertools import chain
for desk in desks:
for chair in chain(desk.filtered_chairs, desk.filtered_nearby_chairs):
# 

It will issue only three queries independently of the number of Chair 
or Desks you have.


Simon

Le mercredi 25 février 2015 15:05:50 UTC-5, cool-RR a écrit :

Hi guys,

I'm trying to solve a problem using the new `Prefetch` but I can't
figure out how to use it.

I have these models:

class Desk(django.db.models.Model):
pass
class Chair(django.db.models.Model):
desk = django.db.models.Foreignkey('Desk',
related_name='chair',)
nearby_desks = django.db.models.ManyToManyField(
'Desk',
blank=True,
)

I want to get a queryset for `Desk`, but it should also include a
prefetched attribute `favorite_or_nearby_chairs`, whose value
should be equal to:

Chair.objects.filter(
(django.db.models.Q(nearby_desks=desk) |
django.db.models.Q(desk=desk)),
some_other_lookup=whatever,
)

Is this possible with `Prefetch`? I couldn't figure out how to use
the arguments.


Thanks,
Ram.

--
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/726492e7-5f82-4690-a97c-20743592c3f8%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/54F56F11.6000700%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Populating Django app db with JSON data

2015-03-02 Thread aRkadeFR

“custom Python code in a historical context”
FMPOV, it means that your code will be run exactly at a certain
schema of your DB. If your migration is the 3rd one, it will
always be run after your first two migrations, thus you will
know exactly your schema.

The schema is passed to your function (as apps and schema_editor)
in order to get your Model class.

Sorry if my explanation wasn't clear, hope it will help at least.

On 03/02/2015 10:27 AM, Murthy Sandeep wrote:

Hi

thanks for the info.

The docs also say that RunPython runs “custom Python code
in a historical context”.  What does that mean exactly?  It seems
related to the apps and schema_editor arguments passed to
the custom method that will be called by RunPython - is this something
like a snapshot of the app model that is stored when I do `python manage.py 
migrate`?

Sandeep



On 2 Mar 2015, at 19:37, aRkadeFR <cont...@arkade.info> wrote:

Hello,

Indeed, the data migration is the best way. Check out
the documentation here:
https://docs.djangoproject.com/en/1.7/ref/migration-operations/#django.db.migrations.operations.RunPython

You write your function that will be called by the RunPython
and will load your JSON.
Migration are ordered, your first migration will create the
tables and the second (your data migration) will load your
JSON.

To create an empty migration:
./manage.py makemigrations  --empty

You can rename to a useful descriptive name the migration
file.

Have a good one


On 03/02/2015 08:16 AM, Sandeep Murthy wrote:

Hi

I've tried to get the answer to this question (which is a bit open-ended) on 
stackoverflow without much success, which
is basically this: what is the recommended approach to populating a 
pre-existing Django app database table (generated
from a model and which is currently empty) with JSON data?

There seem to be several alternatives given in the Django documentation (Django 
1.7 manual) which include (1) fixtures,
(2) SQL scripts, (3) data migrations.  Of these I am a bit confused by the 
advice in the manual which suggests that (1)
and (2) are only useful for loading initial data.  That's not what I want to 
do.  The data that the app needs is going to be
persistent and permanent because the app is intended to be a web query tool for 
a large dataset that is currently in the
form of several JSON files, each containing on average thousands of JSON 
objects, each object representing an entry
corresponding to a table entry in a relational db.  The data is not going to be 
re-loaded or change after entry, and there
is no user facility for changing the data.

The table has been created using the makemigrations and migrate tools, but is 
empty.  I just need to populate the
table with the JSON data.  It seems that I need to write a custom data 
migration script that will insert the data into the
table via the interpreter, and then I need to run python manage.py migrate.  Is 
this the case, and if so, are there
are examples that I could use?

Thanks in advance for any suggestions.

SM
--
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/db5919c5-ace4-4556-b90e-aa47baa26552%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/54F42164.6040505%40arkade.info.
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/54F43A59.60803%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Populating Django app db with JSON data

2015-03-02 Thread aRkadeFR

Hello,

Indeed, the data migration is the best way. Check out
the documentation here:
https://docs.djangoproject.com/en/1.7/ref/migration-operations/#django.db.migrations.operations.RunPython

You write your function that will be called by the RunPython
and will load your JSON.
Migration are ordered, your first migration will create the
tables and the second (your data migration) will load your
JSON.

To create an empty migration:
./manage.py makemigrations  --empty

You can rename to a useful descriptive name the migration
file.

Have a good one


On 03/02/2015 08:16 AM, Sandeep Murthy wrote:

Hi

I've tried to get the answer to this question (which is a bit 
open-ended) on stackoverflow without much success, which
is basically this: what is the recommended approach to populating a 
pre-existing Django app database table (generated

from a model and which is currently empty) with JSON data?

There seem to be several alternatives given in the Django 
documentation (Django 1.7 manual) which include (1) fixtures,
(2) SQL scripts, (3) data migrations.  Of these I am a bit confused by 
the advice in the manual which suggests that (1)
and (2) are only useful for loading initial data.  That's not what I 
want to do.  The data that the app needs is going to be
persistent and permanent because the app is intended to be a web query 
tool for a large dataset that is currently in the
form of several JSON files, each containing on average thousands of 
JSON objects, each object representing an entry
corresponding to a table entry in a relational db.  The data is not 
going to be re-loaded or change after entry, and there

is no user facility for changing the data.

The table has been created using the makemigrations and migratetools, 
but is empty.  I just need to populate the
table with the JSON data.  It seems that I need to write a custom data 
migration script that will insert the data into the
table via the interpreter, and then I need to run python manage.py 
migrate.  Is this the case, and if so, are there

are examples that I could use?

Thanks in advance for any suggestions.

SM
--
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/db5919c5-ace4-4556-b90e-aa47baa26552%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/54F42164.6040505%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Can the new `Prefetch` solve my problem?

2015-02-27 Thread aRkadeFR

Yeah, but from my experience, your example through a new
query. You have to (and please correct me if I'm wrong or
there are other ways) use the self.chair_set.all() in order
to not through a new query when you have prefetched the
chairs.

To be simple and answer the problem: my only solution I
have in mind is to prefetched all the objects (chairs), and
then filter it in python with properties like I said. But as you
said it will load too much objects...

Still watching the thread cause I have couple of problems
like this one :)

aRkadeFR

On 02/26/2015 08:27 PM, James Schneider wrote:
Heh, I just realized that aRkadeFR had replied with a similar idea to 
use a property. At least I know I'm not too far off on my thinking. :-D


-James

On Thu, Feb 26, 2015 at 11:02 AM, James Schneider 
<jrschneide...@gmail.com <mailto:jrschneide...@gmail.com>> wrote:


Whoops, accidentally sent that last one too early, here's the
continuation:

However, that probably doesn't buy you much since you are still
doing an extra query for every Desk you pull from your original query.

Funny enough, I was googling around for an answer here, and
stumbled across this:


https://docs.djangoproject.com/en/1.7/ref/models/queries/#django.db.models.Prefetch

which I think is what you were referring to initially in your OP.
I wasn't even aware of its existence. Prefetch() is a helper class
for prefetch_related(). Taking a quick glance through the source
code, I would imagine that it probably won't help you much, since
the functionality of that class only controls the action of
prefetch_related().


Zooming out a bit, the crux of your problem is this: An attribute
you wish to populate is not an FK or M2M field, it is an entirely
separate Queryset with some moderately complex filters. The
built-in ORM functionality for pre-loading via
prefetch/select_related() is expecting a FK or M2M relationship
and can't  use another queryset AFAIK. The high-level
functionality of prefetch_related() is probably close to what you
want, which is to run a single second query to collect all of
the favorite_or_nearby_chairs for all of the Desks in your
original query, and then glue everything together behind the
scenes in Python to make the desk_obj.favorite_or_nearby_chairs
available seamlessly.

I would then wonder if there is another way to organize this data
to make it easier to work with? How about adding a
'favorite_chairs' field to the Desk model that has an M2M to
Chair? I would also update your 'nearby_desks' model field to use
'nearby_chairs' as the related_field.

Then you could do something like the following:

desks = Desk.objects.filter().select_related('nearby_chairs', 'favorite_chairs')

Then, you can modify your model with a property that will return
the concatenation of nearby_chairs and favorite_chairs:

class Desk(models.Model):
@property
def favorite_or_nearby_chairs(self):
return self.nearby_chairs.all() + self.favorite_chairs

I don't believe this will spawn another query, since
select_related() will have already run and have the results
cached. You may also want to consider moving 'nearby_desks' out of
Chair and renaming it to 'nearby_chairs' in Desk, and using a
related_name of 'nearby_desks' instead. Then you can remove the
.all() from the property definition from above and it definitely
won't spawn a query. Obviously you'll need to create other
processes that will populate desk.favorite_chairs, which may or
may not be feasible.

TL;DR; I don't believe you can pre-fetch anything because of the
extra SQL logic needed to calculate the favorite_or_nearby_chairs
attribute. It might be possible via raw SQL though. Reformatting
your data models may lead to an easier time since you can then
take advantage of the some of the optimizations Django offers.

I'm slightly out in right field on this one, so YMMV, but taking a
hard look at the current model design would be where I would start
to try and eliminate the need for that custom queryset.

Again, the django-debug-toolbar is your friend in these cases, but
obviously a high number of even relatively fast queries can have a
detrimental effect on your load times. Also ensure that the fields
you are using to filter contain indexes, if appropriate/available.

-James




On Thu, Feb 26, 2015 at 10:17 AM, James Schneider
<jrschneide...@gmail.com <mailto:jrschneide...@gmail.com>> wrote:

Yep, looks like I misunderstood.

So, you want to have something like this pseudo code:

desks = Desk.objects.filter()
for desk in desks:
print desk.favorite_or_nearby_chairs

And have favorite_or_nearby_chairs be pre-populated with your
Chair queryset mention

Re: Can the new `Prefetch` solve my problem?

2015-02-26 Thread aRkadeFR

got it, so you want to prefetch but not all chairs.

I will def follow this thread to see the possibilities of Prefetch :)

On 02/26/2015 12:52 PM, Ram Rachum wrote:
There may be a big number of chairs, and I don't want all the chairs 
prefetched. I want to have the database filter them according to the 
queryset I specified in a single call, I don't want to filter them in 
Python or make a new call to filter them.


Thanks,
Ram.

On Thu, Feb 26, 2015 at 1:48 PM, aRkadeFR <cont...@arkade.info 
<mailto:cont...@arkade.info>> wrote:


I may not have completely understand your problem, but
why not prefetching all the chairs? and then with the (new)
attribute favorite_or_nearby_chairs loading only the favorite
or nearby one?

like:
@property
def favorite_or_nearby_chairs(self):
for chair in self.chair_set.all():
  #filter...
  ans += ...
return ans

It will only hit the DB once thanks to the first join of desk
<-> chair.


On 02/26/2015 11:28 AM, cool-RR wrote:

James, you misunderstood me.

There isn't supposed to be a `favorite_or_nearby_chairs`
attribute. That's the new attribute I want the prefetching to add
to the `Desk` queryset that I need. Also, I don't understand why
you'd tell me to add a `.select_related('nearby_desks')` to my
query. Are you talking about the query that starts with
`Chair.objects`? I'm not looking to get a `Chair` queryset. I'm
looking to get a `Desk` queryset, which has a prefetched
attribute `favorite_or_nearby_chairs` which contains the `Chair`
queryset I wrote down.


Thanks,
Ram.

On Thursday, February 26, 2015 at 6:02:15 AM UTC+2, James
Schneider wrote:

Well, the Desk model you provided is blank, but I'll believe
you that there's a favorite_or_nearby_chairs attribute. ;-)

Should be relatively simple. Just add a
.select_related('nearby_desks') to your existing query and
that should pull in the associated Desk object in a single
query. You can also substitute in prefetch_related(),
although you'll still have two queries at that point.

If you are trying to profile your site, I would recommend the
Django-debug-toolbar. That should tell you whether or not
that query set is the culprit.

-James

On Feb 25, 2015 1:28 PM, "Ram Rachum" <r...@rachum.com> wrote:

Hi James,

I've read the docs but I still couldn't figure it out. My
queryset works great in production, I'm trying to
optimize it because our pageloads are too slow. I know
how to use querysets in Django pretty well, I just don't
know how to use `Prefetch`.

Can you give me the solution for the simplified example I
gave? This might help me figure out what I'm not
understanding. One thing that might be unclear with the
example I gave, is that I meant I want to get a queryset
for `Desk` where every desk has an attribute names
`favorite_or_nearby_chairs` which contains the queryset
of chairs that I desrcibed, prefetched.


Thanks,
Ram.

On Wed, Feb 25, 2015 at 11:18 PM, James Schneider
<jrschn...@gmail.com> wrote:

I assume that you are talking about the
select_related() and prefetch_related() queryset methods?


https://docs.djangoproject.com/en/1.7/ref/models/querysets/#select-related

https://docs.djangoproject.com/en/1.7/ref/models/querysets/#prefetch-related

Both of those sections have excellent examples, and
detail what the differences are (primarily joins vs.
separate queries, respectively).

For better help, you'll need to go into more detail
about the queries you are trying to make, what you've
tried (with code examples if possible), and the
results/errors you are seeing.

In general, I would try to get an initial queryset
working and gathering the correct results first
before looking at optimizations such as
select_related(). Any sort of pre-fetching will only
confuse the situation if the base queryset is incorrect.

-James

On Wed, Feb 25, 2015 at 12:05 PM, cool-RR
<ram.r...@gmail.com> wrote:

Hi guys,

I'm trying to solve a problem using the new
`Prefetch` but I can't figure out how to use it.

I have these models:

class Desk(django.db.models.Model):
pass
class Chair(django.db.m

Re: Can the new `Prefetch` solve my problem?

2015-02-26 Thread aRkadeFR

I may not have completely understand your problem, but
why not prefetching all the chairs? and then with the (new)
attribute favorite_or_nearby_chairs loading only the favorite
or nearby one?

like:
@property
def favorite_or_nearby_chairs(self):
for chair in self.chair_set.all():
  #filter...
  ans += ...
return ans

It will only hit the DB once thanks to the first join of desk
<-> chair.

On 02/26/2015 11:28 AM, cool-RR wrote:

James, you misunderstood me.

There isn't supposed to be a `favorite_or_nearby_chairs` attribute. 
That's the new attribute I want the prefetching to add to the `Desk` 
queryset that I need. Also, I don't understand why you'd tell me to 
add a `.select_related('nearby_desks')` to my query. Are you talking 
about the query that starts with `Chair.objects`? I'm not looking to 
get a `Chair` queryset. I'm looking to get a `Desk` queryset, which 
has a prefetched attribute `favorite_or_nearby_chairs` which contains 
the `Chair` queryset I wrote down.



Thanks,
Ram.

On Thursday, February 26, 2015 at 6:02:15 AM UTC+2, James Schneider 
wrote:


Well, the Desk model you provided is blank, but I'll believe you
that there's a favorite_or_nearby_chairs attribute. ;-)

Should be relatively simple. Just add a
.select_related('nearby_desks') to your existing query and that
should pull in the associated Desk object in a single query. You
can also substitute in prefetch_related(), although you'll still
have two queries at that point.

If you are trying to profile your site, I would recommend the
Django-debug-toolbar. That should tell you whether or not that
query set is the culprit.

-James

On Feb 25, 2015 1:28 PM, "Ram Rachum"  wrote:

Hi James,

I've read the docs but I still couldn't figure it out. My
queryset works great in production, I'm trying to optimize it
because our pageloads are too slow. I know how to use
querysets in Django pretty well, I just don't know how to use
`Prefetch`.

Can you give me the solution for the simplified example I
gave? This might help me figure out what I'm not
understanding. One thing that might be unclear with the
example I gave, is that I meant I want to get a queryset for
`Desk` where every desk has an attribute names
`favorite_or_nearby_chairs` which contains the queryset of
chairs that I desrcibed, prefetched.


Thanks,
Ram.

On Wed, Feb 25, 2015 at 11:18 PM, James Schneider
 wrote:

I assume that you are talking about the select_related()
and prefetch_related() queryset methods?


https://docs.djangoproject.com/en/1.7/ref/models/querysets/#select-related



https://docs.djangoproject.com/en/1.7/ref/models/querysets/#prefetch-related



Both of those sections have excellent examples, and detail
what the differences are (primarily joins vs. separate
queries, respectively).

For better help, you'll need to go into more detail about
the queries you are trying to make, what you've tried
(with code examples if possible), and the results/errors
you are seeing.

In general, I would try to get an initial queryset working
and gathering the correct results first before looking at
optimizations such as select_related(). Any sort of
pre-fetching will only confuse the situation if the base
queryset is incorrect.

-James

On Wed, Feb 25, 2015 at 12:05 PM, cool-RR
 wrote:

Hi guys,

I'm trying to solve a problem using the new `Prefetch`
but I can't figure out how to use it.

I have these models:

class Desk(django.db.models.Model):
pass
class Chair(django.db.models.Model):
desk = django.db.models.Foreignkey('Desk',
related_name='chair',)
nearby_desks = django.db.models.ManyToManyField(
'Desk',
blank=True,
)

I want to get a queryset for `Desk`, but it should
also include a prefetched attribute
`favorite_or_nearby_chairs`, whose value should be
equal to:

Chair.objects.filter(
(django.db.models.Q(nearby_desks=desk) |
django.db.models.Q(desk=desk)),
some_other_lookup=whatever,
)

   

Re: django deployment in a virtual machine.

2015-02-25 Thread aRkadeFR

Hello there,

It's always good to take a look at how prodding a django website.

As George Silva said, you need nginx/apache or other. They will serve
your media and static files. Then for the django server, you need
to run it in uWSGI or another wsgi, and link it to your nginx/apache.

http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

Have fun :)

On 02/24/2015 10:49 PM, dk wrote:

its just a website with one link =)
basicly shows one graph. and that's it.

On Tuesday, February 24, 2015 at 3:41:14 PM UTC-6, george wrote:

not production i hope.

in prod use nginx. if not on prod use runserver 0.0.0.0:8000


Em 24/02/2015 18:37, "dk"  escreveu:

I got a virtual machine with Linux centos that we are going to
use for our django webpage.
that machine will have the html service on. so when people go
to the computer typing the IP, will show them the webpage. is
there any special trick to do? like make a service that lunch
manage.py with the runserver command?
if any one can point me to a webpage I will appreciate.

thanks guys.
-- 
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/e3255fbf-27c2-4ac5-bec6-939b9a8744cd%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/bf9c8f15-7206-4932-95c9-d5c8bc82af9b%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/54ED85B1.2020507%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: modelFormSet and csrf

2015-02-24 Thread aRkadeFR

Please, print your variable request.POST on your
view and see if the csrf_token is missing or not?
Same for your formset variable :)

On 02/24/2015 09:55 AM, joulumaa wrote:
Thanks, but I did exactly that and still 403 csrf error, attached my 
template and related code

thanks for help


{% csrf_token %}

{{ formset }}

 


def school(request):
SchoolFormSet = modelformset_factory(SchoolHistory)
if request.method == 'post':
formset = SchoolFormSetSet(request.POST, request.FILES)
if formset.is_valid():
formset.save()
# do something.
else:
formset = SchoolFormSet()
return render_to_response("testformset.html", {
"formset": formset,
})


tiistai 24. helmikuuta 2015 10.31.13 UTC+2 aRkadeFR kirjoitti:

Hello :)

The template indeed doesn't show the submit button in the
documentation here:

https://docs.djangoproject.com/en/1.7/topics/forms/formsets/#using-a-formset-in-views-and-templates

<https://docs.djangoproject.com/en/1.7/topics/forms/formsets/#using-a-formset-in-views-and-templates>

In order to add the csrf token, you can use the template tag
{% csrf %} inside the form tag.
And add the submit button before closing the form tag too :)

On 02/24/2015 01:09 AM, joulumaa wrote:

Hi,
I just studied and created first modelFormSet, and tried to use
it in view.
I have same code in template as is in django documentation.
modelFormset shows data ok, but submit button is missing,why it
is not in example template in documentation?
ok, I added submit button like I have used with basic forms, it
shows up but cause csrf error,
then I added csrf tag as in form cases before, but still csrf 
error


I am missing some information i guess???, any help for beginner...?

-Vesa
btw, i would like to have that saving button on each row in
formset is it possible?
-- 
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
<http://groups.google.com/group/django-users>.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/ee930575-0a61-4c74-ad34-847df414f59c%40googlegroups.com

<https://groups.google.com/d/msgid/django-users/ee930575-0a61-4c74-ad34-847df414f59c%40googlegroups.com?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout
<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/54EC5805.7000907%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: modelFormSet and csrf

2015-02-24 Thread aRkadeFR

Hello :)

The template indeed doesn't show the submit button in the
documentation here:
https://docs.djangoproject.com/en/1.7/topics/forms/formsets/#using-a-formset-in-views-and-templates

In order to add the csrf token, you can use the template tag
{% csrf %} inside the form tag.
And add the submit button before closing the form tag too :)

On 02/24/2015 01:09 AM, joulumaa wrote:

Hi,
I just studied and created first modelFormSet, and tried to use it in 
view.

I have same code in template as is in django documentation.
modelFormset shows data ok, but submit button is missing,why it is not 
in example template in documentation?
ok, I added submit button like I have used with basic forms, it shows 
up but cause csrf error,

then I added csrf tag as in form cases before, but still csrf error

I am missing some information i guess???, any help for beginner...?

-Vesa
btw, i would like to have that saving button on each row in 
formset is it possible?

--
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/ee930575-0a61-4c74-ad34-847df414f59c%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/54EC367F.6090602%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Handling FormSet client side with javascript

2015-02-20 Thread aRkadeFR

Hello,

Yes {{ formset.media }} works. But the problem is
wider. How to include/manage the javascript around
the formset?

I want to add a media file (js) only on formset and not
inside a form contained in a formset.

Let me know if I'm not clear in my first message (it's
a bit long to read, I know =D).

Thanks

On 02/19/2015 07:28 PM, Collin Anderson wrote:

Hi,

Sorry for the late reply. Does simply using {{ formset.media }} work?

Collin

On Friday, February 13, 2015 at 11:02:31 AM UTC-5, aRkadeFR wrote:

Hello everyone,

I'm using FormSet in order to add multiple object at once on
a view. To have a more user friendly approach, I created a
'my.formset.js' file and I need to include a 'jquery.formset.js' lib
to add/remove row of the formset (client side) and edit the
formset management information.

My idea to resolve this problem was to include these two
javascript media file everytime I'm using a formset.

A bit like every media js file for widgets :)

So my first attempt was something like that:
```
class BaseFormSet(BaseInlineFormSet):
 class Media:
 js = ("my.formset.js", "jquery.formset.js", )
```

but this doesnt render these js files with formset.media.render_js().

My second attempt was:
```
formset.media.add_js( ["my.formset.js", "jquery.formset.js", ])
```

My last attempt:
```
form = formset.forms[0]

formset.forms[0].fields[form.fields.keys()[0]].media.add_js(["my.formset.js",

"jquery.formset.js", ])
```

Still not working cause the .media._js is regenerating the media js
files.

The only solution so far I have, provided by @tbaxter, is to
include all my js files in all my application, and initialize/use
the formset/widgets javascript only on certain condition.

I don't like the idea of including my js application wide. It's
gonna overload all my pages for nothing (my js files are
completely standalone) when there is no FormSet.

Can I have your tought on this probleme, and what solution
you have in mind?

Thank you,



--
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/54E6F981.4020505%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Struggling with formsets

2015-02-19 Thread aRkadeFR

Hello,

Can we have the template?

Did you rendered the hidden fields id of your forms ?

Dump (by printing) the request.POST informations to see
if you received any "id" :)



On 02/19/2015 04:25 PM, Werner Brand wrote:
I cannot seem to figure this, although I suspects it is really 
elementary:


I have two models:

class Employee(models.Model):

id_number = models.CharField(max_length=13)

surname = models.CharField(max_length=100)

name =  models.CharField(max_length=100)


class Payslip(models.Model):

surname = models.CharField(max_length=100)
name =  models.CharField(max_length=100)

salary = models.DecimalField(max_digits=20, decimal_places=2)


In my forms:

class PayslipForm(ModelForm):

class Meta:

model = Payslip

fields = ['surname', 'name', 'salary']


PayslipFormSet = modelformset_factory(Payslip, extra=0)


In views.py:

def Payslip(request):

employee = Employee.objects.all()

formset = PayslipFormSet(queryset=employee)

context = {'formset': formset}

return render(request, 'file.html', context)


def PayslipSubmit(request):

f = PayslipFormSet(request.POST)

if f.is_valid():

f.save()

return HttpResponse('Submitted')

else:

return HttpResponse(f.errors)


The problem is that when I submit I get the following each form in 
formset:


  * id
  o Select a valid choice. That choice is not one of the available
choices.

I hope someone can 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/8c766350-f426-475c-aac5-15f42952ce00%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/54E61AC4.8040504%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: how to handle race conditions?

2015-02-19 Thread aRkadeFR


On 02/19/2015 01:04 AM, Mario Gudelj wrote:

Great reply. You're a champion, Carl!



Couldn't say more. Very thorough answer and interesting :)

On 19 February 2015 at 05:31, Carl Meyer > wrote:


Hi Abraham,

On 02/17/2015 10:01 PM, Abraham Varricatt wrote:
> I'm trying to make an app where folks can order X quantity of an
item.
> The condition is that the order should only be made if inventory
exists.
> Assume that we have stock of Y items. This means that only if Y >= X
> should we allow the sale to go through. And once we accept an
order, the
> inventory should be updated so that Y = Y - X.

In general, the construct you need is called a "transaction", which
ensures that a series of database operations will either all be
committed together, or rolled back if they can't be successfully
completed. The Django API for that is "django.db.transaction.atomic".

> The way I've currently implemented this is with a pair of
getter/setter
> methods. I have a model 'ShopItem' which has two fields called
> 'quantity' and 'name' (this is unique). I've made a utility class
> (outside model source file) where I've made the following 2
functions;
>
> def get_quantity(name):
>   stuff_left = 0
>   try:
> item = ShopItem.objects.get(name=name)
> stuff_left = item.quantity
>   except ShopItem.DoesNotExist:
> pass # return zero
>   return stuff_left
>
> def set_quantity(name, stuff_left):
>   item = ShopItem.objects.get(name=name)
>   item.quantity = stuff_left
>   item.save()
>
>
> Elsewhere in my project, if I need to display the remaining
quantity of
> an item in a view, I'll pass the result from get_quantity(). At sale
> time here is how I update things;
>
> def customer_buy(name, number):
>   temp = get_quantity(name)
>   if (temp >= number):
> temp = temp - number
> set_quantity(name, temp)
> // do other things
>   else:
> // sale failed, do something else
>
> I tested this on my system and things appear to work. But I'm
concerned
> about race conditions. What if two different customers came in
to buy
> the same item? As in; if I only have 7 items in stock, but one
customer
> came to buy 6nos and another 5nos. There is a chance (as per my
> understanding) that both orders will be accepted - even worse, my
> inventory will not accurately reflect the updated situation.
>
> Any ideas on how this issue can be resolved? I've come across this
> -

https://docs.djangoproject.com/en/1.6/ref/models/instances/#updating-attributes-based-on-existing-fields
> , but not sure how to apply it to the current scenario.

If we're only considering the changes to your ShopItem model, you
don't
even need an explicit transaction to avoid race conditions,
because (as
the docs you linked show) the operation can be completed in a single
database query, which is inherently atomic. This is how it would
look to
do it in a single query:

from django.db.models import F

def customer_buy(name, number):
ShopItem.objects.filter(
name=name).update(quantity=F('quantity')-number)

You want this to fail if someone tries to purchase a larger quantity
than are available. The best way to do this is via a database-level
"check constraint" on the column, such that the database itself will
never permit a negative quantity. If you make 'quantity' a
PositiveIntegerField (the name is wrong, it actually allows zero
too) on
your model, and your database is PostgreSQL (or Oracle), Django
will add
this constraint for you automatically. Then if someone tries to
purchase
more than are available, you'll get an IntegrityError, which you'd
want
to catch and handle in some way:

from django.db import IntegrityError
from django.db.models import F

class InsufficientInventory(Exception):
pass

def customer_buy(name, number):
try:
ShopItem.objects.filter(
name=name).update(quantity=F('quantity')-number)
except IntegrityError:
# signal to the calling code that the purchase failed
- the
# calling code should catch this exception and notify the
# user that the purchase failed due to lack of inventory,
# and tell them the updated available quantity
raise InsufficientInventory()

You also want this function to handle the case where the given product
name doesn't exist. To help with this case, the `update` method
returns
the number of rows updated:

from django.db import IntegrityError
from django.db.models import F

class 

Re: ImportError

2015-02-18 Thread aRkadeFR


On 02/18/2015 07:17 AM, Petar Pilipovic wrote:
aRkadeFR I have one other question regarding urls.py. I got this error 
when I am trying to go from contact or about to home page.



Using the URLconf defined in |tryDjango.urls|, Django tried these URL 
patterns, in this order:


 1. ^$ [name='home']
 2. ^about/$ [name='about']
 3. ^contact/$ [name='contact']
 4. ^admin/
 5. ^static\/(?P.*)$
 6. ^media\/(?P.*)$

The current URL, |contact/{% url 'home' %}|, didn't match any of these.



the first part of your list are regexes. The "$" means the end of the line.
So there's nothing after "contact/" ; you can't do "contact/".

A link in a template is as simple as:
Link
For your home page:
Link

Now mine root/urls.py <http://ur1.ca/jr147>, and this is mine 
navbar.html <http://ur1.ca/jr14h>, every other thing is connected 
properly, and I can go from home page to contact, about, but I can not 
go reverse.

Can you explain to me where is the error?
Tank you.

On Wednesday, 18 February 2015 06:02:54 UTC+1, Petar Pilipovic wrote:

Hello aRkadeFR.
I have solved mine problem, I was working whit Python 2.X here,
and like you recommended I have done some  absolute import.
from forms import contactForm ,  and that solved it.
There was one other error, mine base.html did not render mine
block content, because I did not defined it, I did that and now
mine form is working.
Tank you.
Best.
Petar...;-)



On Tuesday, 17 February 2015 14:57:46 UTC+1, aRkadeFR wrote:

Two different problems here.

For your import of contactForm, please try the relative import
like:
from contact.forms import contactForm
> contact is your app name

try the (absolute_import)[1] too if you're python2.

[1] https://docs.python.org/2/library/__future__.html
<https://docs.python.org/2/library/__future__.html>

Let us know if this works

On 02/17/2015 01:30 PM, Petar Pilipovic wrote:

Maybea this can help you, a bref info :
I made a contact app, I have defined app url in mine url root
project, then i made a forms.py file, i have defined form in
it, then i have made contact.html where I have defined
contact.html form which mine app will render, I have then go
to views.py an imported contactForm class.
Afther that I have defined connection between  contact.html
page and navbar.html, collected static, run server and bam
error occur.
I just can not explain to mine self how come he can not
import contactForm, and how com he can not render
havbar.html, error pop's out line 15.
On Tuesday, February 17, 2015, Petar Pilipovic
<iam...@gmail.com> wrote:
> Hello, I can not do it wright now I am not at home.
> As for mine forms.py, it is in mine contact app. I have two
apps in mine root project, one off them is contact.
> I will send you more info as soon as posible.
> Tank you.
>
>
> On Tuesday, February 17, 2015, aRkadeFR
<con...@arkade.info> wrote:
>> Hello :)
>>
>> Can you dump us the layout of your files?
>> Where is your forms.py?
>>
>> Thanks
>>
>> On 02/17/2015 06:36 AM, Petar Pilipovic wrote:
>>
>> Hello all, I am trying to build and e_commerc django app,
but I have encounter an confusing error.
>> Mine Error is:
>> Environment:
>>
>> Request Method: GET
>> Request URL: http://127.0.0.1:8000/
>> Django Version: 1.7.4
>> Python Version: 2.7.6
>> Installed Applications:
>> ('django.contrib.admin',
>>  'django.contrib.auth',
>>  'django.contrib.contenttypes',
>>  'django.contrib.sessions',
>>  'django.contrib.messages',
>>  'django.contrib.staticfiles',
>>  'profiles')
>> Installed Middleware:
>> ('django.contrib.sessions.middleware.SessionMiddleware',
>>  'django.middleware.common.CommonMiddleware',
>>  'django.middleware.csrf.CsrfViewMiddleware',
>>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>>
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
>>  'django.contrib.messages.middleware.MessageMiddleware',
>>  'django.middleware.clickjacking.XFrameOptionsMiddleware')
>>
>> Template error:
>> In template
/home/petarp/Documents/Udemy/Learn_Django/static/templates/navbar.html,
error at li

Re: how to handle race conditions?

2015-02-18 Thread aRkadeFR

Hello,

My opinion on the problem:
A database is ACID, so there will be no problem if every information
are stored in the database.
There should be a "available_quantity" property on a item.
This will allow you to have more control of the stock too.

If a customer put an item in his basket this checks the
available quantity of the item and update it. So you
succeed to sell only available item.

Then the release item problem:
If the user didnt buy the item before X minutes, you need
to forbid his basket and you put again his items inside
the available_quantity.

Don't know if it helped you?

Thanks,

PS:
May I suppose to you that the get_quantity function and set_quantity
should be in the manager of the model?
something like:
```
class ShopItemManager(Manager):
def get_quantity(self, name):
return self.get_queryset().get(name=name).quantity

class ShopItem(Model):
...
objects = ShopItemManager()
```
This allow you to tied up your function to the model.


On 02/18/2015 06:01 AM, Abraham Varricatt wrote:

Hello,

I'm trying to make an app where folks can order X quantity of an item. 
The condition is that the order should only be made if inventory 
exists. Assume that we have stock of Y items. This means that only if 
Y >= X should we allow the sale to go through. And once we accept an 
order, the inventory should be updated so that Y = Y - X.


The way I've currently implemented this is with a pair of 
getter/setter methods. I have a model 'ShopItem' which has two fields 
called 'quantity' and 'name' (this is unique). I've made a utility 
class (outside model source file) where I've made the following 2 
functions;


def get_quantity(name):
  stuff_left = 0
  try:
item = ShopItem.objects.get(name=name)
stuff_left = item.quantity
  except ShopItem.DoesNotExist:
pass # return zero
  return stuff_left

def set_quantity(name, stuff_left):
  item = ShopItem.objects.get(name=name)
  item.quantity = stuff_left
  item.save()


Elsewhere in my project, if I need to display the remaining quantity 
of an item in a view, I'll pass the result from get_quantity(). At 
sale time here is how I update things;


def customer_buy(name, number):
  temp = get_quantity(name)
  if (temp >= number):
temp = temp - number
set_quantity(name, temp)
// do other things
  else:
// sale failed, do something else

I tested this on my system and things appear to work. But I'm 
concerned about race conditions. What if two different customers came 
in to buy the same item? As in; if I only have 7 items in stock, but 
one customer came to buy 6nos and another 5nos. There is a chance (as 
per my understanding) that both orders will be accepted - even worse, 
my inventory will not accurately reflect the updated situation.


Any ideas on how this issue can be resolved? I've come across this 
- https://docs.djangoproject.com/en/1.6/ref/models/instances/#updating-attributes-based-on-existing-fields 
, but not sure how to apply it to the current scenario.


Learning django,
Abraham 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7552759e-81d6-4cfb-a0ce-4fed95eef5bc%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/54E453B0.4030509%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Installare versioni successive

2015-02-17 Thread aRkadeFR

Hello there,

I think this is an English mailing list. From google translate, I
understood you want to upgrade Django 1.6 to 1.7.

Please read the following releases notes:
https://docs.djangoproject.com/en/1.7/releases/1.7/
more specifically:
https://docs.djangoproject.com/en/1.7/releases/1.7/#backwards-incompatible-changes-in-1-7

Check that nothing breaks, and then you can just upgrade
your version :)


On 02/17/2015 04:32 PM, Paola Di Tomasso wrote:

Ciao a tutti sono nuova  del gruppo,
io ho django 1.6.x e ho l'esigenza  di passare alle 1.7, devo fare 
qualcosa  di preciso o semplicemente istallando la 1.7 effettua 
 l'aggiornamento alla versione successiva.


Grazie  mille
Paola.
--
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/e7283738-af94-4971-82b9-5b6c965bdb2f%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/54E361D7.708%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: ImportError

2015-02-17 Thread aRkadeFR

Two different problems here.

For your import of contactForm, please try the relative import like:
from contact.forms import contactForm
> contact is your app name

try the (absolute_import)[1] too if you're python2.

[1] https://docs.python.org/2/library/__future__.html

Let us know if this works

On 02/17/2015 01:30 PM, Petar Pilipovic wrote:

Maybea this can help you, a bref info :
I made a contact app, I have defined app url in mine url root project, 
then i made a forms.py file, i have defined form in it, then i have 
made contact.html where I have defined contact.html form which mine 
app will render, I have then go to views.py an imported contactForm class.
Afther that I have defined connection between  contact.html page and 
navbar.html, collected static, run server and bam error occur.
I just can not explain to mine self how come he can not import 
contactForm, and how com he can not render havbar.html, error pop's 
out line 15.
On Tuesday, February 17, 2015, Petar Pilipovic <iamr...@gmail.com 
<mailto:iamr...@gmail.com>> wrote:

> Hello, I can not do it wright now I am not at home.
> As for mine forms.py, it is in mine contact app. I have two apps in 
mine root project, one off them is contact.

> I will send you more info as soon as posible.
> Tank you.
>
>
> On Tuesday, February 17, 2015, aRkadeFR <cont...@arkade.info 
<mailto:cont...@arkade.info>> wrote:

>> Hello :)
>>
>> Can you dump us the layout of your files?
>> Where is your forms.py?
>>
>> Thanks
>>
>> On 02/17/2015 06:36 AM, Petar Pilipovic wrote:
>>
>> Hello all, I am trying to build and e_commerc django app, but I 
have encounter an confusing error.

>> Mine Error is:
>> Environment:
>>
>> Request Method: GET
>> Request URL: http://127.0.0.1:8000/
>> Django Version: 1.7.4
>> Python Version: 2.7.6
>> Installed Applications:
>> ('django.contrib.admin',
>>  'django.contrib.auth',
>>  'django.contrib.contenttypes',
>>  'django.contrib.sessions',
>>  'django.contrib.messages',
>>  'django.contrib.staticfiles',
>>  'profiles')
>> Installed Middleware:
>> ('django.contrib.sessions.middleware.SessionMiddleware',
>>  'django.middleware.common.CommonMiddleware',
>>  'django.middleware.csrf.CsrfViewMiddleware',
>>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>>  'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
>>  'django.contrib.messages.middleware.MessageMiddleware',
>>  'django.middleware.clickjacking.XFrameOptionsMiddleware')
>>
>> Template error:
>> In template 
/home/petarp/Documents/Udemy/Learn_Django/static/templates/navbar.html, error 
at line 15

>>cannot import name contactForm
>>5 :   aria-expanded="false" aria-controls="navbar">

>>
>>6 : Toggle navigation
>>
>>7 : 
>>
>>8 : 
>>
>>9 : 
>>
>>10 :   
>>
>>11 :   Bootstrap theme
>>
>>12 : 
>>
>>13 : 
>>
>>14 :   
>>
>>15 : {% url 'home' as home %}
>>
>>16 :{% url 'about' as about %}
>>
>>17 :{% url 'contact' as contact %}
>>
>>18 : class="active" {%endif%}>Home

>>
>>19 : class="active" {%endif%}>About

>>
>>20 : class="active" {%endif%}>Contact

>>
>>21 : 
>>
>>22 :   data-toggle="dropdown" role="button" aria-expanded="false">Dropdown 


>>
>>23 :   
>>
>>24 : Action
>>
>>25 : Another action
>>
>> Traceback:
>> File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/core/handlers/base.py" 
in get_response
>>   111. response = wrapped_callback(request, 
*callback_args, **callback_kwargs)
>> File 
"/home/petarp/Documents/Udemy/Learn_Django/source/profiles/views.py" 
in home

>>   7. return render(request, tempalte, context)
>> File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/shortcuts.py" 
in render

>>   50. return HttpResponse(loader.render_to_string(*args, **kwargs),
>> File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/loader.py" 
in render_to_string

>>   178. return t.render(context_instanc

Re: ImportError

2015-02-17 Thread aRkadeFR

Hello :)

Can you dump us the layout of your files?
Where is your forms.py?

Thanks

On 02/17/2015 06:36 AM, Petar Pilipovic wrote:
Hello all, I am trying to build and e_commerc django app, but I have 
encounter an confusing error.

Mine Error is:
|
Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/

Django Version: 1.7.4
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'profiles')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Template error:
In template 
/home/petarp/Documents/Udemy/Learn_Django/static/templates/navbar.html, error 
at line 15

 cannot import name contactForm
   5 :   data-toggle="collapse" data-target="#navbar" aria-expanded="false" 
aria-controls="navbar">



   6 : Toggle navigation


   7 : 


   8 : 


   9 : 


   10 :   


   11 :   Bootstrap theme


   12 : 


   13 : 


   14 :   


   15 : {% url 'home' as home %}


   16 :{% url 'about' as about %}


   17 :{% url 'contact' as contact %}


   18 : {%endif%}>Home



   19 : {%endif%}>About



   20 : class="active" {%endif%}>Contact



   21 : 


   22 :   data-toggle="dropdown" role="button" aria-expanded="false">Dropdown 




   23 :   


   24 : Action


   25 : Another action


Traceback:
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/core/handlers/base.py" 
in get_response
  111. response = wrapped_callback(request, 
*callback_args, **callback_kwargs)
File 
"/home/petarp/Documents/Udemy/Learn_Django/source/profiles/views.py" 
in home

  7.   return render(request, tempalte, context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/shortcuts.py" 
in render

  50. return HttpResponse(loader.render_to_string(*args, **kwargs),
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/loader.py" 
in render_to_string

  178. return t.render(context_instance)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" 
in render

  148. return self._render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" 
in _render

  142. return self.nodelist.render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" 
in render

  844. bit = self.render_node(node, context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/debug.py" 
in render_node

  80. return node.render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/loader_tags.py" 
in render

  126. return compiled_parent._render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" 
in _render

  142. return self.nodelist.render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" 
in render

  844. bit = self.render_node(node, context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/debug.py" 
in render_node

  80. return node.render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/loader_tags.py" 
in render

  150. return template.render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" 
in render

  148. return self._render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" 
in _render

  142. return self.nodelist.render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" 
in render

  844. bit = self.render_node(node, context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/debug.py" 
in render_node

  80. return node.render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/defaulttags.py" 
in render
  444.   

Re: Django Inline formset with jquery

2015-02-17 Thread aRkadeFR

Hello,

I got the same kind of probleme while working on the formset
couple days ago.

If this is related, the problem is the auto complete javascript that
doesn't go well with the jquery.formset.js.

You can add a function "added" in parameter of the formset function
for reloading the autocomplete widget.

something like:
```
|
$(function() {
$(".inline.{{ orderformset.prefix }}").formset({
prefix: "{{ orderformset.prefix }}",
added: function () { reload_auto_complete(); },
})
})
|
```

About the deletion, is it on the front end or the backend you're
talking about?

If this is front -> check your javascript
If this is backend -> check all the values dumping request.POST

Hope I was useful


On 02/17/2015 06:01 AM, Ajay Kumar wrote:
Here by choosing serial_no and the rest of the fields name and author 
should be auto populate. Auto populate works for first inline formset 
and able to save it but when I add another inline formset auto 
populate is not working plus I'm unable to delete it or save it.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, 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/54E2FF5F.2070509%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Handling FormSet client side with javascript

2015-02-13 Thread aRkadeFR

Hello everyone,

I'm using FormSet in order to add multiple object at once on
a view. To have a more user friendly approach, I created a
'my.formset.js' file and I need to include a 'jquery.formset.js' lib
to add/remove row of the formset (client side) and edit the
formset management information.

My idea to resolve this problem was to include these two
javascript media file everytime I'm using a formset.

A bit like every media js file for widgets :)

So my first attempt was something like that:
```
class BaseFormSet(BaseInlineFormSet):
class Media:
js = ("my.formset.js", "jquery.formset.js", )
```

but this doesnt render these js files with formset.media.render_js().

My second attempt was:
```
formset.media.add_js( ["my.formset.js", "jquery.formset.js", ])
```

My last attempt:
```
form = formset.forms[0]
formset.forms[0].fields[form.fields.keys()[0]].media.add_js(["my.formset.js", 
"jquery.formset.js", ])

```

Still not working cause the .media._js is regenerating the media js
files.

The only solution so far I have, provided by @tbaxter, is to
include all my js files in all my application, and initialize/use
the formset/widgets javascript only on certain condition.

I don't like the idea of including my js application wide. It's
gonna overload all my pages for nothing (my js files are
completely standalone) when there is no FormSet.

Can I have your tought on this probleme, and what solution
you have in mind?

Thank you,

--
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/54DE2006.9030001%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Template Spaces and tabs

2015-02-13 Thread aRkadeFR

to be concise:
try using a  tag in your HTML ;)


{% for line in lines %}
{{ line }}
{% endfor %}


On 02/12/2015 09:32 PM, Tom Evans wrote:

On Thu, Feb 12, 2015 at 8:25 PM, Ulisses Cruz  wrote:

Hello
This may seem trivial but can you help?

I'm reading a file line by line and transforming it in a list of lines
(example: list_of_lines = [file_line1, file_line2, ...])
then I pass the list to a template to be displayed. (example: return
render(request, 'template/location.html', {'lines':list_fo_lines}))

In the template I have a for loop to white each line:

{% for line in lines %}
 {{ line }}
{% endfor %}

Now, the problem is that, in the file I wrote from, some words in a line
have more than one space and sometimes tabs between them.
I would like to keep them in the html page as well, but in the html page the
additional spaces and tabs do not appearing.

This does not have anything to do with django, but in an HTML
document, all whitespace is collapsed.

You can use a HTML tags to denote pre-formatted content.


I know the answer may be in HTML but I'm not getting there.

So you knew this wasn't the right place to send it, but thought "What the hell?"

There are many HTML tutorials out there that describe the common HTML
tags, I'd suggest investing some of *your* time in reading them, as
writing web applications is much easier when you have a grasp of HTML.

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/54DE044F.3000202%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Optimizing has_perm query time on PERMISSION AND GROUP PERMISSION

2014-12-19 Thread aRkadeFR

Hey mohd,

How do you know the CPU burnt come from the method has_perm?
Did you dump the query and play it again?

It's most likely to be something else FMPOV. The has_perm is just a simple
query in DB...

aRkadeFR

On 12/18/2014 05:27 PM, mohd irshad wrote:

Hello ,
I am constantly facing face max cpu usage problem because of few 
database (postgres) heavy query has_perm is one of them.


how can I optimized such query.
--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/525f6423-f10b-40f7-8514-d3b5af225d96%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/525f6423-f10b-40f7-8514-d3b5af225d96%40googlegroups.com?utm_medium=email_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/54942F0E.2010003%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Database queries location

2014-12-19 Thread aRkadeFR

Depend exactly on what to compute for your post data.

I would almost write no logic code in the views.

I split every application as follow:
- managers.py: All the logic as a table level (raw SQL, complex queries)
- models.py: All logic as a row level / object level (python computing data)
- forms.py: All logic as forms data / processing / validation for 
request data


Have a good one,

aRkadeFR

On 12/18/2014 10:12 PM, pythonista wrote:

I understand that functions can be placed in the models fille

However if I have complex queries that receive post input does the


Query live in the model  the views or an external module



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


Re: Select a single field from database (postgresql)

2014-12-19 Thread aRkadeFR

Hello Cássio,

You first need to map your cars table with a Model in Django
(https://docs.djangoproject.com/en/1.7/topics/db/models/),
then you can construct your query something like this:

Car.objects.order_by('-registered').last()

Check out the documentation on queries here:
https://docs.djangoproject.com/en/1.7/topics/db/queries/

Have a good one,

aRkadeFR


On 12/19/2014 12:51 PM, Cássio Van Helden Gameiro wrote:
Hi, i have a database with many cars, and i want to select the last 
car based the hour that it was registered, can someone help me?


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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/fecb3393-d336-4aa8-8058-f6bbf9cfbfc4%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/fecb3393-d336-4aa8-8058-f6bbf9cfbfc4%40googlegroups.com?utm_medium=email_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/54941319.9040806%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Does Django offers a way to generate data grid from database table like web2py

2014-11-28 Thread aRkadeFR

Hello,

From my point of view, you're asking for a similar MySQL admin
with bootstrap style? Why not directly get a DB admin like pgadmin
or so?

The most similar thing will be the django admin as Timothy stated.

Thank you,

aRkadeFR

On 11/28/2014 05:55 AM, Sarbjit singh wrote:
What web2py GRID does is, that it takes the SQL table/query as 
argument, and return the records satisfying the query.


Records which are returned are seen in bootstrap enabled table with 
features having pagintation, sorting, search, ability to 
edit/delete/view individual record, add new record etc.


(See for link - web2py grid snapshot as well 
<http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-grid-and-SQLFORM-smartgrid>)


*What I want?*

I just wanted to have the end result similar to as of web2py grid 
where records (satisfying any query) can be seen inside a tabular form 
with the ability to search, sort, edit/delete individual record etc.


Since, I am new to Django, I am not sure if Django provides such a 
thing out of box or any third party app provides this capability.


If you just click on web2py link above, snapshot of web2py grid will 
give you a clear idea.


-Sarbjit

--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/719e8cc9-4c8e-4aaa-900b-a030c73eb1e7%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/719e8cc9-4c8e-4aaa-900b-a030c73eb1e7%40googlegroups.com?utm_medium=email_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/547839C9.8070402%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: i want to know how to use SlugField with slugify to generate url for detail_blog page without using get_absolute_url

2014-11-28 Thread aRkadeFR

Hello Kanchan,

Sorry to say, I didn't get your question. I don't see any get_absolute_url
in your email.

And your code seems legit.

Could you provide more information about the problem?

Thank you,

aRkadeFR

On 11/27/2014 10:26 PM, Kanchan Prasad wrote:

my model.py is
class BlogPost(models.Model):
title= models.CharField(max_length=100)
text = models.TextField()
created_on   = models.DateTimeField(auto_now_add=True,auto_now=False)
updated_on   = models.DateTimeField(auto_now_add=False,auto_now=True)
submitted_by = models.ForeignKey(User)
slug = models.SlugField(max_length=100,unique=True)
def __str__(self):
return self.title
def save(self, *args, **kwargs):
if not self.id:
self.slug = slugify(self.title)
super(BlogPost,self).save(*args,**kwargs)

urls.py

url(r'^profile/latest-quotation/(?P[\w-]+)/$',add_view, 
name='add_view'),


views.py
def add_view(request,slug):
blog = get_object_or_404(BlogPost, slug=slug)
com_form = CommentForm(request.POST or None)
if com_form.is_valid():
form = com_form.save(commit=False)
form.blogpost = blog
form.name = request.user
form.save()
return HttpResponseRedirect(reverse('socialnetwrok:add_view'))
return 
render(request,'socialnetwork/detailview.html',{'blog':blog,'com_form':com_form})


my template where i am using it
{% for quotation in latest_quotation_list %}

{{quotation.title}}


{{quotation.text|truncatewords:100}}

please help me i need 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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/45cb3726-5fd5-469b-b076-0eab453b95b5%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/45cb3726-5fd5-469b-b076-0eab453b95b5%40googlegroups.com?utm_medium=email_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/547838C3.9050108%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Best way to use a 'all' QuerySet as a dict with id first

2014-09-28 Thread aRkadeFR
Thanks for the answer, I just wondered if there was a built-in solution in
Django.

On 27/09/14 06:01, tkdchen wrote:
> 
> 
> On Saturday, September 27, 2014 9:06:58 PM UTC+8, aRkadeFR wrote:
> >
> > @James Brewer: 
> > If I change my code, I can have this user_ids list. 
> > btw, it's filter and not get if you're searching multiple objects (the 
> > user_ids). 
> >
> > @Alejandro Varas G.: 
> > That doesn't change the fact that 'User.objects.get(id=X)' will hit the 
> > database everytime. 
> >
> > Right now, the problem is solved, by creating the AllUserSet, but I think 
> > my 
> > code is pretty ugly, and it seems strange to me that the ORM can't handle 
> > that 
> > built-in, by caching the .all() or .filter(id__in=users_ids) 
> >
> >
> Django actually caches all objects fetched when it evaluates .all or 
> .filter method. The problem you are facing is that how to reuse the cached 
> objects efficiently to avoid hitting database with unnecessary SQL queries. 
> James gave you a good solution. Based on his solution, you don't need to 
> call the `get' method each time getting user by id. Just iterate users 
> object and find the right one by comparing id.
> 
> 
>  
> 
> > The ideally solution would be something like: 
> >
> > AllUser = User.objects.all() 
> >
> > for i in user_id: 
> > AllUser.get(id=i) 
> >
> >
> This piece of code would be changed to
> 
> AllUser = User.objects.all()
> for i in user_id:
> for user in AllUser:
> if user.pk == i:
> print 'find the user'
> 
> or, even you may construct AllUser to dict to simplify the search
> 
> AllUser = dict((user.pk, user) for user in User.objects.all()) # Here, hit 
> db, only once
> for i in user_id:
> user = AllUser.get(i, None) # search by id in memory
> if user is not None:
> print 'find the user'
> 
> Hope, this could help you. 
> 
> But this code hits the database every time the 'get' is called. 
> >
> >
> > On 26/09/14 12:36, James Brewer wrote: 
> > > Do you have a single list of the IDs you want? If so, you can do 
> > something 
> > > like `User.objects.get(id__in=user_ids)`. This will fetch all Users 
> > whose 
> > > `id` is in some list `user_ids`. 
> > > 
> > > Does that help? 
> > > 
> > > Happy hacking! 
> > > 
> > > James 
> > > 
> > > On Fri, Sep 26, 2014 at 11:43 AM, Alejandro Varas G. <alej0...@gmail.com 
> > > 
> > > wrote: 
> > > 
> > > > Hi, 
> > > > 
> > > > You should use User.objects.get(id=X) 
> > > > 
> > > > Best 
> > > > El 26/09/2014 15:28, "aRkadeFR" <con...@arkade.info > 
> > escribió: 
> > > > 
> > > > > 
> > > > > Hey! 
> > > > > 
> > > > > I'm having a hard time trying to reduce the number of SQL queries on 
> > a 
> > > > view. 
> > > > > 
> > > > > Basically, I'm fetching all my User, with User.objects.all(), and 
> > save 
> > > > this 
> > > > > queryset as AllUser. 
> > > > > 
> > > > > Then every time I need to get the user with the id = X , I'm calling 
> > a 
> > > > function 
> > > > > 'get_user_from_id', that iterate over the AllUser queryset variable, 
> > and 
> > > > when 
> > > > > it finds the id, returns it. 
> > > > > 
> > > > > I considerably reduced the number of SQL queries, but I would like 
> > to 
> > > > know if 
> > > > > you think of a better way? 
> > > > > 
> > > > > Thank you 
> > > > > 
> > > > > -- 
> > > > > 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/20140926182939.GA26744%40rkade-thinkpad
> >  
> > > > . 
> > > > > For more opti

Re: Best way to use a 'all' QuerySet as a dict with id first

2014-09-27 Thread aRkadeFR
@James Brewer:
If I change my code, I can have this user_ids list.
btw, it's filter and not get if you're searching multiple objects (the
user_ids).

@Alejandro Varas G.:
That doesn't change the fact that 'User.objects.get(id=X)' will hit the
database everytime.

Right now, the problem is solved, by creating the AllUserSet, but I think my
code is pretty ugly, and it seems strange to me that the ORM can't handle that
built-in, by caching the .all() or .filter(id__in=users_ids)

The ideally solution would be something like:

AllUser = User.objects.all()

for i in user_id:
AllUser.get(id=i)

But this code hits the database every time the 'get' is called.


On 26/09/14 12:36, James Brewer wrote:
> Do you have a single list of the IDs you want? If so, you can do something
> like `User.objects.get(id__in=user_ids)`. This will fetch all Users whose
> `id` is in some list `user_ids`.
> 
> Does that help?
> 
> Happy hacking!
> 
> James
> 
> On Fri, Sep 26, 2014 at 11:43 AM, Alejandro Varas G. <alej0va...@gmail.com>
> wrote:
> 
> > Hi,
> >
> > You should use User.objects.get(id=X)
> >
> > Best
> > El 26/09/2014 15:28, "aRkadeFR" <cont...@arkade.info> escribió:
> >
> > >
> > > Hey!
> > >
> > > I'm having a hard time trying to reduce the number of SQL queries on a
> > view.
> > >
> > > Basically, I'm fetching all my User, with User.objects.all(), and save
> > this
> > > queryset as AllUser.
> > >
> > > Then every time I need to get the user with the id = X , I'm calling a
> > function
> > > 'get_user_from_id', that iterate over the AllUser queryset variable, and
> > when
> > > it finds the id, returns it.
> > >
> > > I considerably reduced the number of SQL queries, but I would like to
> > know if
> > > you think of a better way?
> > >
> > > Thank you
> > >
> > > --
> > > 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/20140926182939.GA26744%40rkade-thinkpad
> > .
> > > 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/CAL60nj%2BBtqs9CXu8drOiWPoJ7aUkAKjLqXKCxmR_TMTeOOH%3DGw%40mail.gmail.com
> > <https://groups.google.com/d/msgid/django-users/CAL60nj%2BBtqs9CXu8drOiWPoJ7aUkAKjLqXKCxmR_TMTeOOH%3DGw%40mail.gmail.com?utm_medium=email_source=footer>
> > .
> >
> > For more options, visit https://groups.google.com/d/optout.
> >
> 
> 
> 
> -- 
> James Brewer
> jamesbrewer.io
> 
> -- 
> 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/CAKj8pVpqBgpFDQ0BruHXLWe2q1CRURMEejokhMKpD5bfs9hGGA%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/20140927130809.GA3104%40rkade-thinkpad.
For more options, visit https://groups.google.com/d/optout.


Best way to use a 'all' QuerySet as a dict with id first

2014-09-26 Thread aRkadeFR
Hey!

I'm having a hard time trying to reduce the number of SQL queries on a view.

Basically, I'm fetching all my User, with User.objects.all(), and save this
queryset as AllUser.

Then every time I need to get the user with the id = X , I'm calling a function
'get_user_from_id', that iterate over the AllUser queryset variable, and when
it finds the id, returns it.

I considerably reduced the number of SQL queries, but I would like to know if
you think of a better way?

Thank you

-- 
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/20140926182939.GA26744%40rkade-thinkpad.
For more options, visit https://groups.google.com/d/optout.


Re: How to call a function when a project starts.

2014-07-30 Thread aRkadeFR
Which version of Django are you running?

On 30/07/14 15:46, Chen Xu wrote:
> Hi Everyone:
> I would like to call a function when my project starts, basically I want to
> call a do_something() when I run python manage.py runserver. However, when
> I put it into settings.py, it gets called twice, but I only want it to
> execute once.
> 
> Is there a good way to do it.
> 
> Thanks
> 
> 
> -- 
> ⚡ Chen Xu ⚡
> 
> -- 
> 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/CACac-qbTXbMGmYU%3D5R618rbt7pT%3DgTL%3DWAxhCR-prmuLbz-VKw%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/20140730200231.GD2235%40rkade-thinkpad.
For more options, visit https://groups.google.com/d/optout.


Re: running script in django database

2014-07-30 Thread aRkadeFR
Agree with Jirka,

I'm just adding the link:
https://docs.djangoproject.com/en/1.6/howto/custom-management-commands/

On 30/07/14 07:53, jirka.vejra...@gmail.com wrote:
> 
> Hi Mohammad,
> 
>   this can be easily achieved using a custom management command - check the 
> Django documentation.
> 
>   HTH
> 
> Jirka
>  
> -Original Message-
> From: alghafli 
> Sender: django-users@googlegroups.com
> Date: Wed, 30 Jul 2014 07:02:59 
> To: 
> Reply-To: django-users@googlegroups.com
> Subject: running script in django database
> 
> Hello,
> I made a library application using django 1.6. currently I only need to 
> populate the database. at the beginning, it is easier to write the 
> information in a csv file and import it using a script.
> 
> the script is running fine if I use manage.py shell and import the 
> necessary file and call the necessary function. however, I want to make 
> the script run from the system commandline rather than from the python 
> interpreter since it is easier to pass arguments to it. I could not find 
> a way in the manage.py documentation page.
> 
> Is it possible?
> 
> thank you,
> Mohammad
> 
> -- 
> 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/53D86E73.9060806%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/417657233-1406705276-cardhu_decombobulator_blackberry.rim.net-1073591500-%40b4.c3.bise7.blackberry.
> 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/20140730194130.GC2235%40rkade-thinkpad.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 - What are you most excited about?

2014-07-30 Thread aRkadeFR
Definitely the schema migration :)

I enjoy lots the App Loading and the Check framework too.

On 29/07/14 18:12, Ryan Blunden wrote:
> Hi everyone,
> 
> I'm giving a lightening talk at the San Francisco Django meetup tomorrow 
> night about some of the awesome new features in Django 1.7.
> 
> I wanted to highlight not just what *I think* are the best new features, 
> but what members of the community are most excited about.
> 
> Would be great to hear from the Django core contributors too.
> 
> Thanks also Django Devs for getting RC 2 up in time for my talk, brilliant 
> timing there!
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to 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/afb4376a-853d-46df-8db3-e37e5740d91b%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/20140730193920.GB2235%40rkade-thinkpad.
For more options, visit https://groups.google.com/d/optout.


Re: simultaneously submit three forms on the same page

2014-07-30 Thread aRkadeFR
Excellent.

Thanks for the share.

How backward compatible is it?

On 29/07/14 17:51, Santiago Lamora wrote:
> 2014-07-29 16:50 GMT+02:00 John :
> 
> > How can one submit 3 forms simultaneously?? Even ajax, is on by one!
> >
> >
> Quotting
> https://docs.djangoproject.com/en/dev/ref/forms/api/#prefixes-for-forms
> > You can put several Django forms inside one  tag. To give each Form 
> > its
> own namespace, use the prefix keyword argument:
> 
> -- 
> 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/CAEaW5xwy2cimDTTv%3DAUyfEeDrcK6xTtDfQ4AC1jXD-u%3DDNMU9A%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/20140730193332.GA2235%40rkade-thinkpad.
For more options, visit https://groups.google.com/d/optout.


Re: django Page

2014-07-24 Thread aRkadeFR
If it's only static pages, you could look first django.contrib.flatpages to
see how to do it.

On 23/07/14 00:05, ngangsia akumbo wrote:
> I want to create an app where the user has the ability to create new pages 
> on their website
> 
> the app should be called pages 
> 
> can someone give me an idea pease?
> 
> -- 
> 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/e431fc80-fe0a-4eca-bfe3-70379906d1d9%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/20140724074947.GA2404%40rkade-thinkpad.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7c1 app without models data migrations

2014-07-17 Thread aRkadeFR

After some tests, the problem came from the lack of the file models.py
The __init__ is there and is ok.

If I run without models.py file:
python3 manage.py migrations  --empty
python3 manage.py migrate

-> that doesn't take into account my 

But if I run the same commands with models.py (even empty), it takes into
account my app and migrate it.

Seems to be something weird to me, cause the 0001_initial.py migration is
exactly the same generated file either case.

Anyway, problem solved, but weird behavior from my point of view? If anyone
can tell me why…

Thanks for the help :)

On 16/07/14 07:06, j1z0 wrote:
> Are you sure you have your django app in your settings.INSTALLED_APPS and 
> your django app has a migrations folder underneath it with an __init__.py 
> file?
> 
> I'm pretty sure that should be all you need to have in place so you can run 
> a migration.
> 
> Cheers,
> Jeremy
> 
> 
> 
> On Tuesday, 15 July 2014 22:20:57 UTC+8, aRkadeFR wrote:
> >
> > Hello everyone, 
> >
> > First post on this mailing list. Big thanks to the community and the core 
> > dev 
> > of Django! 
> >
> > I'm using Django 1.7c1 with python 3.2 or 3.4. 
> >
> > I'm splitting lots of my website as Django apps. So my main app is 
> > handling 
> > (only) the urls routing, the settings, some tests and that's it. 
> >
> > I want to do some data migrations. For example add some 
> > django.contrib.sites.models.Site objects to the database when I migrate my 
> > app. Or some flags (django-waffle) etc. All the data relates to this app. 
> >
> > I don't want to put this data migration into the django.contrib.sites 
> > folder 
> > cause it's already packaged as root etc. So it's not runnable from my 
> > development user (to create or read the file into the folder). And it's 
> > the 
> > same problem for all these apps I want to add data into. 
> >
> > If I run "python3 manage.py makemigrations --empty ", it create the 
> > 0001_initial.py migrations. I create the function to add the data inside 
> > the 
> > database, and try to run the migrations with "python3 manage.py migrate 
> > ", but get the error: 
> >
> > "CommandError: App  does not have migrations (you cannot 
> > selectively 
> > sync unmigrated apps)" 
> >
> > So I'm searching how can I make this  migrated? Create an empty 
> > initial 
> > migrations? so the django migrations take this app into account. 
> >
> > Thank you for all your help 
> >
> > aRkadeFR 
> >
> 
> -- 
> 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/2c369324-da9a-4e3e-a6f1-16cec96cc3cd%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/20140717115955.GA8280%40rkade-thinkpad.
For more options, visit https://groups.google.com/d/optout.


Django 1.7c1 app without models data migrations

2014-07-15 Thread aRkadeFR
Hello everyone,

First post on this mailing list. Big thanks to the community and the core dev
of Django!

I'm using Django 1.7c1 with python 3.2 or 3.4.

I'm splitting lots of my website as Django apps. So my main app is handling
(only) the urls routing, the settings, some tests and that's it.

I want to do some data migrations. For example add some
django.contrib.sites.models.Site objects to the database when I migrate my
app. Or some flags (django-waffle) etc. All the data relates to this app.

I don't want to put this data migration into the django.contrib.sites folder
cause it's already packaged as root etc. So it's not runnable from my
development user (to create or read the file into the folder). And it's the
same problem for all these apps I want to add data into.

If I run "python3 manage.py makemigrations --empty ", it create the
0001_initial.py migrations. I create the function to add the data inside the
database, and try to run the migrations with "python3 manage.py migrate
", but get the error:

"CommandError: App  does not have migrations (you cannot selectively
sync unmigrated apps)"

So I'm searching how can I make this  migrated? Create an empty initial
migrations? so the django migrations take this app into account.

Thank you for all your help

aRkadeFR

-- 
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/20140715142108.GA10827%40rkade-thinkpad.
For more options, visit https://groups.google.com/d/optout.