Query s in django 1.7

2014-10-03 Thread dk
*i am trying to query base on the id of the table and i get a big error,   
when i do it using .all()  i can get the objects*



*>>> Restaurant.objects.all()*
[, , , ]
this works for looping and getting the information such
for i in Restaurant.objects.all():
print i.id
print i.name

1
angry dog
2
cafe brazil
3
papa johns
4
lolos

and here when i want to get by  the id (or doing name="lolos")
*>>> Restaurant.objects.get(id=3)*
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python27\lib\site-packages\django\db\models\manager.py", line 
92, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "C:\Python27\lib\site-packages\django\db\models\query.py", line 345, 
in get
clone = self.filter(*args, **kwargs)
  File "C:\Python27\lib\site-packages\django\db\models\query.py", line 691, 
in filter
return self._filter_or_exclude(False, *args, **kwargs)
  File "C:\Python27\lib\site-packages\django\db\models\query.py", line 709, 
in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
  File "C:\Python27\lib\site-packages\django\db\models\sql\query.py", line 
1287, in add_q
clause, require_inner = self._add_q(where_part, self.used_aliases)
  File "C:\Python27\lib\site-packages\django\db\models\sql\query.py", line 
1314, in _add_q
current_negated=current_negated, connector=connector)
  File "C:\Python27\lib\site-packages\django\db\models\sql\query.py", line 
1138, in build_filter
lookups, parts, reffed_aggregate = self.solve_lookup_type(arg)
  File "C:\Python27\lib\site-packages\django\db\models\sql\query.py", line 
1076, in solve_lookup_type
_, field, _, lookup_parts = self.names_to_path(lookup_splitted, 
self.get_meta())
  File "C:\Python27\lib\site-packages\django\db\models\sql\query.py", line 
1339, in names_to_path
field, model, direct, m2m = opts.get_field_by_name(name)
  File "C:\Python27\lib\site-packages\django\db\models\options.py", line 
416, in get_field_by_name
cache = self.init_name_map()
  File "C:\Python27\lib\site-packages\django\db\models\options.py", line 
445, in init_name_map
for f, model in self.get_all_related_m2m_objects_with_model():
  File "C:\Python27\lib\site-packages\django\db\models\options.py", line 
563, in get_all_related_m2m_objects_with_model
cache = self._fill_related_many_to_many_cache()
  File "C:\Python27\lib\site-packages\django\db\models\options.py", line 
577, in _fill_related_many_to_many_cache
for klass in self.apps.get_models():
  File "C:\Python27\lib\site-packages\django\utils\lru_cache.py", line 101, 
in wrapper
result = user_function(*args, **kwds)
  File "C:\Python27\lib\site-packages\django\apps\registry.py", line 168, 
in get_models
self.check_models_ready()
  File "C:\Python27\lib\site-packages\django\apps\registry.py", line 131, 
in check_models_ready
raise AppRegistryNotReady("Models aren't loaded yet.")
AppRegistryNotReady: Models aren't loaded yet.


reading the tutorials and my book thats it, not sure if i have to activate 
something somewhere else? or linke bewteen all the files some code?
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+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/278ad24d-fe8f-4f92-8021-0e2b8de6d79c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Site specific additional configuration - extending Django Sites model

2014-10-03 Thread Rakan Alhneiti
Hello all,

I am currently trying to develop a blog engine which uses the sites 
framework provided by Django in order to add blog-specific settings. Such 
preferences could be something like blog_description, the user's twitter 
handle, pagination settings, widgets .. etc.

Looking at the sites framework, that only way you would use it is in one of 
the following options:
1) Create a model that extends Site model: this would result in South 
adding the migration into django itself rather than the app extending the 
Site model. I haven't got any further with this option as i hit this road 
block. I think i understand that given the Site model is not abstract, 
extending that module is a wrong approach.

2) Create a model that has a one-to-one relation with the Site module, 
unregister the Site from admin and add it back again with my own 
"StackedInline" blog model added to the SiteAdmin that is to handle the 
admin interface for the Site model itself. However, the downside of this 
approach is that it the stackedinline would add *multiple* "Blog" inline 
forms to the site's admin page making the one-to-one relation like a 
foreign key relation.

The task is simple, blog specific configurations. Other approaches would be 
to add a non-model admin page with a configurations table that holds a 
single record for these configurations or extending the Site model as 
explained above.

What do you think the best way to go about this?

Thanks,
Rakan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/7a55d4c9-d8d3-45a1-a5f5-d5c520eec284%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unable to import 3 modules when running tests

2014-10-03 Thread Mike Cameron
Also, I have re-created my virtualenv from scratch, but the error persists.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/32fb92ac-02f9-43b6-9970-320cf04e219a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Please help: urgent deployment problem with django post office

2014-10-03 Thread Sabine Maennel
Hello Collins, I need post office for other purposes not for error logging. 

I worte an issue in their issue queue, this is what they wrote back:
>>As explained by @RafRaf  , the emails are sent 
by BrokenLinkEmailsMiddleware, you can disable it insettings.py if you need 
to.

*But my settings.py has this middleware only:*
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

So should I remove Common Middleware for deployment. Could it be coming 
from that one? Can you please give me some advice, 

Thanks so much in advance!

Am Donnerstag, 2. Oktober 2014 20:42:19 UTC+2 schrieb Collin Anderson:
>
> It seems like django-post_office recommends using sentry for the errors. 
> Getting a better feel for your situation: Why django-post_office at all? 
> What's wrong with the error emails getting logged?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/7f3d7edc-cbfe-411a-9f16-7acc2044540c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Setting up Apache to be the web server for apache for Django 1.7 and python 3.3

2014-10-03 Thread robert brook
Can someone point me to a document on how to perform a setup for Apache.

What modules would it be good to install ( I presume as a site package for 
Python)?

What should the settings.py reflect to accept calls from Apache?

What do I need to configure in the apache config file?

What port should I use?

I assume that once I use Apache I no longer need to run python manage.py 
runserver, because I will no longer
be using the local server, but now the Apache server?

Any other suggestions would be helpful.

Is mod_wsgi for a medium traffic web site for https  the way to go?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f5cf6b83-7a90-4ffa-84de-c41aef1c68b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Query s in django 1.7

2014-10-03 Thread Collin Anderson
You need to call django.setup().

I can confirm, though, that using Model.objects.all() somehow sometimes 
seems to work without calling django.setup().

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/3f04ece4-5c72-44aa-bc36-a37ecc4f47eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting up Apache to be the web server for apache for Django 1.7 and python 3.3

2014-10-03 Thread Timothy W. Cook
Of course http://www.giyf.com/  but unless you have some very compelling
need to use Apache.  This may be a better choice.
http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/

I found it to be much easier to setup and maintain.



On Fri, Oct 3, 2014 at 9:42 AM, robert brook 
wrote:

> Can someone point me to a document on how to perform a setup for Apache.
>
> What modules would it be good to install ( I presume as a site package for
> Python)?
>
> What should the settings.py reflect to accept calls from Apache?
>
> What do I need to configure in the apache config file?
>
> What port should I use?
>
> I assume that once I use Apache I no longer need to run python manage.py
> runserver, because I will no longer
> be using the local server, but now the Apache server?
>
> Any other suggestions would be helpful.
>
> Is mod_wsgi for a medium traffic web site for https  the way to go?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f5cf6b83-7a90-4ffa-84de-c41aef1c68b0%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM http://www.mlhim.org

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/CA%2B%3DOU3V_FaqwM0d9D9Z67VUy55j%2Bo70GbD8t_kOTJS%3DEquVvkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


CSRF Token: is it okay if it is attached to my url when I enter my form?

2014-10-03 Thread Sabine Maennel
Please help: I am confused whether it is okay that it is showing in the url 
like this:


http://netteachers.de/bewerbung/formular?csrfmiddlewaretoken=2jKsplZsQx5XpBfltUaDmgJjhRiCllxQ


This happens when I enter my form ( a CreateView Model Form)? Is that oky 
or a security risk of any kind?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/2e571910-4d1d-4066-9c60-9632f2613f88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Please help: urgent deployment problem with django post office

2014-10-03 Thread Brad Pitcher
If you want to simply disable logging, you could try setting the LOG_LEVEL
to 0:

POST_OFFICE = {
'LOG_LEVEL': 0  # Don't log anything
}


On Fri, Oct 3, 2014 at 4:55 AM, Sabine Maennel 
wrote:

> Hello Collins, I need post office for other purposes not for error
> logging.
>
> I worte an issue in their issue queue, this is what they wrote back:
> >>As explained by @RafRaf  , the emails are
> sent by BrokenLinkEmailsMiddleware, you can disable it insettings.py if
> you need to.
>
> *But my settings.py has this middleware only:*
> MIDDLEWARE_CLASSES = (
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> )
>
> So should I remove Common Middleware for deployment. Could it be coming
> from that one? Can you please give me some advice,
>
> Thanks so much in advance!
>
> Am Donnerstag, 2. Oktober 2014 20:42:19 UTC+2 schrieb Collin Anderson:
>>
>> It seems like django-post_office recommends using sentry for the errors.
>> Getting a better feel for your situation: Why django-post_office at all?
>> What's wrong with the error emails getting logged?
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send 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/7f3d7edc-cbfe-411a-9f16-7acc2044540c%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/CAMFpZrg2xopvfmY76_dJKDTgCNajk%2BQ-12b8OOwrk6c_NwC_ng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Site specific additional configuration - extending Django Sites model

2014-10-03 Thread Collin Anderson

>
> 1) Create a model that extends Site model: this would result in South 
> adding the migration into django itself rather than the app extending the 
> Site model. I haven't got any further with this option as i hit this road 
> block. I think i understand that given the Site model is not abstract, 
> extending that module is a wrong approach.
>
Subclassing Site should work. The tricky thing is creating a subclassed 
site object from a site object. If you always create subclassed site 
objects, you should be fine. Not a bad way to go, IMHO.

2) Create a model that has a one-to-one relation with the Site module, 
> unregister the Site from admin and add it back again with my own 
> "StackedInline" blog model added to the SiteAdmin that is to handle the 
> admin interface for the Site model itself. However, the downside of this 
> approach is that it the stackedinline would add *multiple* "Blog" inline 
> forms to the site's admin page making the one-to-one relation like a 
> foreign key relation.
>
I believe there are ways to limit the inline enough to make this work: 
extra=0, max_num=1, can_delete=False, etc.
 

> Other approaches would be to add a non-model admin page with a 
> configurations table that holds a single record for these configurations or 
> extending the Site model as explained above.
>
That should also work.

If it were me, I would start doing _each_ of the first two and pick the one 
that seems to be looking the most promising.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/636d560d-11a2-4b65-98c8-33cd68835f1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unable to import 3 modules when running tests

2014-10-03 Thread Collin Anderson
So there's no tracebacks for the error messages?

The test runner likes to search for tests in your current directory. Is 
trying to run code it shouldn't be running?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/1865a4f2-eb8e-4e48-8c50-b08720620793%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: CSRF Token: is it okay if it is attached to my url when I enter my form?

2014-10-03 Thread Babatunde Akinyanmi
I don't think its risky to have csrf token in the url since its in open
view in the page's source anyway (I'm not a security expert so that with a
very large bag of salt). However you would have that behavior when you are
submitting a form with a GET. You should use POST to submit your form
instead of GET.
On 3 Oct 2014 14:26, "Sabine Maennel"  wrote:

> Please help: I am confused whether it is okay that it is showing in the
> url like this:
>
>
>
> http://netteachers.de/bewerbung/formular?csrfmiddlewaretoken=2jKsplZsQx5XpBfltUaDmgJjhRiCllxQ
>
>
> This happens when I enter my form ( a CreateView Model Form)? Is that oky
> or a security risk of any kind?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send 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/2e571910-4d1d-4066-9c60-9632f2613f88%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/CA%2BWjgXPh7vr2TtjMitmmjsbWSDyUkxc3cSChpGf9HsbmAOn%2BSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting up Apache to be the web server for apache for Django 1.7 and python 3.3

2014-10-03 Thread robert brook
The requirements of the organization is to use Apache

On Friday, October 3, 2014 8:42:29 AM UTC-4, robert brook wrote:
>
> Can someone point me to a document on how to perform a setup for Apache.
>
> What modules would it be good to install ( I presume as a site package for 
> Python)?
>
> What should the settings.py reflect to accept calls from Apache?
>
> What do I need to configure in the apache config file?
>
> What port should I use?
>
> I assume that once I use Apache I no longer need to run python manage.py 
> runserver, because I will no longer
> be using the local server, but now the Apache server?
>
> Any other suggestions would be helpful.
>
> Is mod_wsgi for a medium traffic web site for https  the way to go?
>
> Thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/634381ee-57e5-49d1-91fd-aa23b392a15d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting up Apache to be the web server for apache for Django 1.7 and python 3.3

2014-10-03 Thread Collin Anderson
Here's your requested document: 
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/modwsgi/

If you're using ubuntu (though I assume you're not, based on your python 
version,) you just run:
sudo apt-get install apache2 libapache2-mod-wsgi-py3

> What should the settings.py reflect to accept calls from Apache?
You shouldn't need to do any additional configuration in django, besides 
the usual deployment configuration:
https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/

> What port should I use?
If you're using ssl, port 443 is the standard port to listen on, if that 
answers your question.

> I assume that once I use Apache I no longer need to run python manage.py 
runserver, because I will no longer be using the local server, but now the 
Apache server?
Basically, runserver is for development, apache is for production. You may 
still want to use the runserver for testing changes to your code.

> Is mod_wsgi for a medium traffic web site for https  the way to go?
If you're not going to use nginx, I'd recommend the event-mpm if you have 
the choice, which should help performance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/f8e9ccd4-ceb8-4b2e-aab6-13550410c307%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: CSRF Token: is it okay if it is attached to my url when I enter my form?

2014-10-03 Thread Collin Anderson

>
> However you would have that behavior when you are submitting a form with a 
> GET. You should use POST to submit your form instead of GET.
>
Yes, use:


 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/e81c5a95-c2d3-4dea-bcef-ca4f6b4b04a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to filter results that are not part of a ManyToManyField?

2014-10-03 Thread Neto
Hello,

I have it model:

class People(models.Model):
> children = models.ManyToManyField('self', blank=True, null=True)


I want to filter the first of each family tree. *Knowing that children can 
have children

How I do it?

People.objects.filter()

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


Re: Site specific additional configuration - extending Django Sites model

2014-10-03 Thread Rakan Alhneiti
Hello Collin,

The problem with the second approach is that it's ugly, i prefer the first 
one instead. However, i've got to figure out how to prevent South from 
creating the migration in the "django.contrib.site" directory in my 
virtualenv. 

Thanks,
Rakan

On Friday, October 3, 2014 5:14:34 PM UTC+3, Collin Anderson wrote:
>
> 1) Create a model that extends Site model: this would result in South 
>> adding the migration into django itself rather than the app extending the 
>> Site model. I haven't got any further with this option as i hit this road 
>> block. I think i understand that given the Site model is not abstract, 
>> extending that module is a wrong approach.
>>
> Subclassing Site should work. The tricky thing is creating a subclassed 
> site object from a site object. If you always create subclassed site 
> objects, you should be fine. Not a bad way to go, IMHO.
>
> 2) Create a model that has a one-to-one relation with the Site module, 
>> unregister the Site from admin and add it back again with my own 
>> "StackedInline" blog model added to the SiteAdmin that is to handle the 
>> admin interface for the Site model itself. However, the downside of this 
>> approach is that it the stackedinline would add *multiple* "Blog" inline 
>> forms to the site's admin page making the one-to-one relation like a 
>> foreign key relation.
>>
> I believe there are ways to limit the inline enough to make this work: 
> extra=0, max_num=1, can_delete=False, etc.
>  
>
>> Other approaches would be to add a non-model admin page with a 
>> configurations table that holds a single record for these configurations or 
>> extending the Site model as explained above.
>>
> That should also work.
>
> If it were me, I would start doing _each_ of the first two and pick the 
> one that seems to be looking the most promising.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/c88a7e33-44b9-48bf-8e93-5fb2ff90a925%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Site specific additional configuration - extending Django Sites model

2014-10-03 Thread Rakan Alhneiti
It seems like the issue was with my app naming ("site") with south actually
creating the migration into Django's site package directory.

Table inheritance seems the way to go.

Thanks again,
Rakan

Best Regards,

*Rakan AlHneiti*
Find me on the internet:
*Online Blog*: http://rakan.me

 Rakan Alhneiti  |  @rakanalh
 |  Rakan Alhneiti
 |   alhneiti
- Mobile: +962-798-910 990

On Fri, Oct 3, 2014 at 11:14 PM, Rakan Alhneiti 
wrote:

> Hello Collin,
>
> The problem with the second approach is that it's ugly, i prefer the first
> one instead. However, i've got to figure out how to prevent South from
> creating the migration in the "django.contrib.site" directory in my
> virtualenv.
>
> Thanks,
> Rakan
>
>
> On Friday, October 3, 2014 5:14:34 PM UTC+3, Collin Anderson wrote:
>>
>> 1) Create a model that extends Site model: this would result in South
>>> adding the migration into django itself rather than the app extending the
>>> Site model. I haven't got any further with this option as i hit this road
>>> block. I think i understand that given the Site model is not abstract,
>>> extending that module is a wrong approach.
>>>
>> Subclassing Site should work. The tricky thing is creating a subclassed
>> site object from a site object. If you always create subclassed site
>> objects, you should be fine. Not a bad way to go, IMHO.
>>
>> 2) Create a model that has a one-to-one relation with the Site module,
>>> unregister the Site from admin and add it back again with my own
>>> "StackedInline" blog model added to the SiteAdmin that is to handle the
>>> admin interface for the Site model itself. However, the downside of this
>>> approach is that it the stackedinline would add *multiple* "Blog"
>>> inline forms to the site's admin page making the one-to-one relation like a
>>> foreign key relation.
>>>
>> I believe there are ways to limit the inline enough to make this work:
>> extra=0, max_num=1, can_delete=False, etc.
>>
>>
>>> Other approaches would be to add a non-model admin page with a
>>> configurations table that holds a single record for these configurations or
>>> extending the Site model as explained above.
>>>
>> That should also work.
>>
>> If it were me, I would start doing _each_ of the first two and pick the
>> one that seems to be looking the most promising.
>>
>  --
> 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/kjFDIyjA2SY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c88a7e33-44b9-48bf-8e93-5fb2ff90a925%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/CA%2B4Y%3DOigNXF%2BV3O-Dbfd3znT1JiOTjo6z3BUAkYhmCLcxjTVyA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Failure to get data from database and onto template.

2014-10-03 Thread Malik Rumi
I just wanted to report back and see if you had any additional ideas to 
offer. I did change the meta from id to pk, but there was no change. Then I 
took reverse off the template for loop and (almost) everything was the way 
I wanted it. For some reason, Article 4 came out Sections 3,4,1,2, in that 
order. Their ids, in that same order, are 16, 15, 13, 14. In other words, 
if they were ordered by pk like the rest, they would be in proper order, 
but they are not. Since it is only this one group, I don't want to mess 
with the whole thing anymore, but I don't know what to do about these. The 
only thing I can think of is to delete 3 and 4 and then re-create them and 
hope that puts them in the right order. Any other ideas?

I was wrong about the Articles and Sections on the same view. Turns out it 
was the ID that was controlling everything, Django wasn't even looking at 
the slug, even when I put unique_together on the meta. Changing the names 
of the Sections didn't even work. Neither did putting article_id in the 
Sections regex. If I put sectionView first in the urlconf, all the sections 
would come up fine but none of the articles. If I put articleView first in 
the urlconf, the articles all came up and the sections got doesnotexist. 
The only thing that worked (and I tried A LOT of variations) was to put the 
Sections on (?P) only, no id, no digits.

So even though that problem is technically solved, if you have some best 
practices to share with me so I can get this done better next time, I am 
all ears. 

Thanks again for all the help.

On Thursday, October 2, 2014 4:08:24 PM UTC-5, Malik Rumi wrote:
>
> Collin, 
> Thank you for the suggestion. I will try it tonight after I get off work 
> and can finish cleaning up the code following Daniel's answer. sectionView 
> is supposed to be id/slug, but I included the Article name in the Section 
> names, because I can't put a fk in the slug. So maybe that was also a newby 
> mistake. This must be why Django is sending Article 1 and Article 2 Section 
> 1 to the same view, it sees the match for 'Article' and stops there. So 
> I'll probably end up renaming them, so as you can see, I have (made for 
> myself) a lot of (re)work to do. But I am learning! 
>
> On Thursday, October 2, 2014 12:49:47 PM UTC-5, Collin Anderson wrote:
>>
>> For the ordering issue, I'd recommend setting ordering = ['pk'] in the 
>> Model class Meta, then you don't need to try to handle it in your view.
>>
>> What does your sectionView look like? Does /{{ id }}/{{ slug }}/ uniquely 
>> identify both an article and a section, or should it be /{{ article_id 
>> }}/{{ article_slug }}/{{ section_id }}/ ?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/75b7a838-6433-4cc8-a499-577b37245132%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to filter results that are not part of a ManyToManyField?

2014-10-03 Thread Collin Anderson
This may look totally crazy, but does this do what you want?
People.objects.filter(people=None)

It may make more sense to do this:
class Person(models.Model):
children = models.ManyToManyField('self', blank=True, related_name=
'parents')
Person.objects.filter(parents=None)


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an 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/c84d0f39-10dd-46fd-bde8-d072a76f86a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Query s in django 1.7

2014-10-03 Thread dk
yes,that did the trick, odd that on .all does work fine,  i wish the error 
was more descriptive.

On Friday, October 3, 2014 7:52:40 AM UTC-5, Collin Anderson wrote:
>
> You need to call django.setup().
>
> I can confirm, though, that using Model.objects.all() somehow sometimes 
> seems to work without calling django.setup().
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/1664d4a8-45ff-4b6f-818e-2cf3f54c5413%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


help with idea

2014-10-03 Thread carlos
Hi i need have this in my views! but not working

dicc_one = {'string1': 'fieldsFK__total_one__gt=0',
   'string2': 'fieldsFK__total_two__gt=0',
   'string3': 'fieldsFK__total_three__gt=0',
   'string4': 'fieldsFK__total_four__gt=0',
  }
results = {}

for k,v in dicc_one.items():
print v
results[k] = Model.objects.filter(v).count()  # this fail no
working any idea

this error show me:

too many values to unpack
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.
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/CAM-7rO1ex0mxrtV7_JUiCqZ%2BaOVSh2ebkVqusVjsAVA7GJHr4w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.