Help needed in constructing __in query

2014-08-04 Thread Subodh Nijsure
I have two tables as shown below.

class AlertTable(models.Model):
id = models.AutoField(primary_key=True)
alarm_text = models.CharField(max_length=800,blank=False,null=False)
event_type = models.SmallIntegerField(blank=False,null=False)
created = models.DateTimeField()
class Meta:
ordering = ['-id']
def __unicode__(self):
return str(self.id)

class PendingAlertsTable(models.Model):
id = models.AutoField(primary_key=True)
alerttable = models.ForeignKey(AlertTable)
created = models.DateTimeField()
class Meta:
ordering = ['-id']
def __unicode__(self):
return str(self.id)

Idea is PendingAlertsTable holds reference to alerts that have not
been acknowledged. And AlertTable holds all the alerts.

So I want to construct query such that I can get all entries from
AlertTable that are Pending.

So I constructed query like this:

inner_qs=PendingAlertsTable.objects.all()
all_pending_events = AlertTable.objects.filter(pk__in=inner_qs)

That doesn't give me query set in all_pending_event of expected
entries. What is the correct way to construct the __in query in this
case?

-Subodh

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


Re: Foreign key User on migration‏

2014-08-04 Thread Sam Contapay
I downloaded the latest code from stable/1.7.x branch and this problem no 
longer exists.

On Monday, August 4, 2014 8:06:00 AM UTC-7, Sam Contapay wrote:
>
> Hi,
>
> I tried adding a foreign key to a model in a Django app I'm building to 
> learn 1.7. I am using Python 3.4 and Django 1.7c2
>
> #blog/models.py
>
> from django.contrib.auth.models import User
> from django.db import models
>
> class Comment(models.Model):
> user = models.ForeignKey(User, blank=True, null=True)
> created_at = models.DateTimeField(auto_now=True)
> comment = models.CharField(max_length=255)
>
> This is an already existing database I ran "manage.py makemigrations" and 
> "manage.py migrate". Make migration works fine but running migrate 
> generates this error (I am not using a custom user model). I don't 
> understand 'auth' not found as it is in my project settings and I am using 
> the admin panel:
>
> (screens)*➜  **screens **git:(**master**) **✗* ./manage.py migrate
>
> *Operations to perform:*
>
> *  Synchronize unmigrated apps: *django_extensions, crispy_forms
>
> *  Apply all migrations: *auth, admin, contenttypes, sessions, website
>
> *Synchronizing apps without migrations:*
>
>   Creating tables...
>
>   Installing custom SQL...
>
>   Installing indexes...
>
> *Running migrations:*
>
>   Applying website.0004_comment_created_by_user...Traceback (most recent 
> call last):
>
>   File 
> "/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/apps/registry.py",
>  
> line 148, in get_app_config
>
> return self.app_configs[app_label]
>
> KeyError: 'auth'
>
>
> During handling of the above exception, another exception occurred:
>
>
> Traceback (most recent call last):
>
>   File 
> "/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/db/migrations/state.py",
>  
> line 79, in render
>
> model = self.apps.get_model(lookup_model[0], lookup_model[1])
>
>   File 
> "/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/apps/registry.py",
>  
> line 202, in get_model
>
> return self.get_app_config(app_label).get_model(model_name.lower())
>
>   File 
> "/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/apps/registry.py",
>  
> line 150, in get_app_config
>
> raise LookupError("No installed app with label '%s'." % app_label)
>
> LookupError: No installed app with label 'auth'.
>
>
> During handling of the above exception, another exception occurred:
>
>
> Traceback (most recent call last):
>
>   File "./manage.py", line 10, in 
>
> execute_from_command_line(sys.argv)
>
>   File 
> "/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/core/management/__init__.py",
>  
> line 385, in execute_from_command_line
>
> utility.execute()
>
>   File 
> "/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/core/management/__init__.py",
>  
> line 377, in execute
>
> self.fetch_command(subcommand).run_from_argv(self.argv)
>
>   File 
> "/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/core/management/base.py",
>  
> line 288, in run_from_argv
>
> self.execute(*args, **options.__dict__)
>
>   File 
> "/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/core/management/base.py",
>  
> line 337, in execute
>
> output = self.handle(*args, **options)
>
>   File 
> "/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/core/management/commands/migrate.py",
>  
> line 160, in handle
>
> executor.migrate(targets, plan, fake=options.get("fake", False))
>
>   File 
> "/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/db/migrations/executor.py",
>  
> line 63, in migrate
>
> self.apply_migration(migration, fake=fake)
>
>   File 
> "/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/db/migrations/executor.py",
>  
> line 91, in apply_migration
>
> if self.detect_soft_applied(migration):
>
>   File 
> "/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/db/migrations/executor.py",
>  
> line 135, in detect_soft_applied
>
> apps = project_state.render()
>
>   File 
> "/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/db/migrations/state.py",
>  
> line 89, in render
>
> model=lookup_model,
>
> ValueError: Lookup failed for model referenced by field 
> website.Comment.created_by_user: auth.User
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/46e2ed1b-caf7-43e3-9422-767c8b1eba13%40goog

Re: html response before saving object

2014-08-04 Thread pylo...@gmail.com

>
> - does the product exist?
>
Yes, 

- is the cart_item really not created? (or is the cart the thing not being 
> created?)
>
The cartItem is created, but it shown if I request again the url
1) request: /cart/?add=productslug
2) response: without the new item
3) request : /cart/
4) response: the item now is shown

- are you using transactions?
>
No 
 

> - is the prefetch_related pre-caching the related cart items, so in the 
> template it doesn't see the new item? (hint: redirect to the same page to 
> load the page again)
>
I did not know that about prefetch_related, I have removed it and now 
working as expected.
 

> also, while you're upgrading (or after), you can now use simpler code for 
> that last line:
> return render(request, 'products/cart.html', response_args)
>
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/91a72f12-14ab-4a38-b750-02b67cd6b16f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: html response before saving object

2014-08-04 Thread Collin Anderson
database save is not async.

a few possibilities:
- does the product exist?
- is the cart_item really not created? (or is the cart the thing not being 
created?)
- is the prefetch_related pre-caching the related cart items, so in the 
template it doesn't see the new item? (hint: redirect to the same page to 
load the page again)
- are you using transactions?
- you could moving around some print statements, or my favorite: assert 
False, to see what code is actually getting run.

also, while you're upgrading (or after), you can now use simpler code for 
that last line:
return render(request, 'products/cart.html', response_args)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/12912e81-254a-4704-8d62-343632c8bc55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


html response before saving object

2014-08-04 Thread pylo...@gmail.com
Hi Guys, 

I've update my site from django 1.3 to 1.5
The site works fine, except for a view, the template renders before the 
obj.save() in the view:

def cart(request):
try:
cart = 
Cart.objects.prefetch_related('cartitem_set__product__category').get(id=request.session['cart_id'])
except (KeyError, Cart.DoesNotExist) as e:
cart = Cart()
cart.save()
request.session['cart_id'] = cart.id

if 'add' in request.GET:
try:
product = Product.objects.get(slug=request.GET['add'], 
active=True)
cart_item = CartItem.objects.get(product=product, cart=cart)
except CartItem.DoesNotExist:
cart_item = CartItem(product=product, cart=cart)
cart_item.save()
except Product.DoesNotExist:
pass

response_args = {'cart': cart}
return render_to_response('products/cart.html', response_args, 
context_instance=RequestContext(request))

I don't know why this happens
any help? something has changed? now the database save is async?

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


Re: deploying django

2014-08-04 Thread Adrian Marshall
I've went through a few different ways. If your set on using apache, 
Configure Apache with Mod-WSGI on a server.

Here's a Good Tutorial: 
http://thecodeship.com/deployment/deploy-django-apache-virtualenv-and-mod_wsgi/

If you're having trouble with that and your app isn't too demanding you can 
easily upload on Heroku and control it easily using Git commands.

check out the docs: 
https://devcenter.heroku.com/articles/getting-started-with-django

An alternative to both of those would be to use Nginx with uWSGI. If you 
want to go that route here's a good tutorial:
http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html#concept

Good luck!

On Monday, August 4, 2014 4:53:00 AM UTC-4, ngangsia akumbo wrote:
>
> I have created a complete site, 
>
> i have configured it to run with mysql using wamp
>
> i have also configured apache in wamp which is up and running
>
> so i want to deploy the site to run as a life page on the internet using 
> apache
>
> what should i do next
>

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


Django - Login from Android

2014-08-04 Thread Adrian Marshall
I have a Django app up and running and It's more mobile based than a web 
app. I'm new to development with both Django and Android. I've setup an API 
using Django-Tasty pie and I can get JSON data from my models,including the 
user model that comes with Django. I've implemented logging in functions in 
the backend and tested it out. It works good like it's supposed to. Now I'm 
trying to see how to go about registering and logging in users from Android?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/0549624b-79f2-4b0e-86e6-3685951f7a59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Redirect with string?

2014-08-04 Thread Lachlan Musicman
Collin, worked a charm - thankyou!
L.

On 1 August 2014 22:51, Lachlan Musicman  wrote:
> Thanks Collin, I'll test on Monday
> L.
>
> On 1 August 2014 22:47, Collin Anderson  wrote:
>> redirect is a django shortcut for an http redirect response, not a file/pipe
>> redirect. You need to use a python socket to connect to the ip address.
>>
>> http://stackoverflow.com/questions/68774/best-way-to-open-a-socket-in-python
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send 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/4fa95d46-e174-4ece-a3b0-82050d97458b%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> You have to be really clever to come up with a genuinely dangerous
> thought. I am disheartened that people can be clever enough to do that
> and not clever enough to do the obvious thing and KEEP THEIR IDIOT
> MOUTHS SHUT about it, because it is much more important to sound
> intelligent when talking to your friends.
> This post was STUPID.
> ---
> The Most Terrifying Thought Experiment of All Time
> http://www.slate.com/articles/technology/bitwise/2014/07/roko_s_basilisk_the_most_terrifying_thought_experiment_of_all_time.html



-- 
You have to be really clever to come up with a genuinely dangerous
thought. I am disheartened that people can be clever enough to do that
and not clever enough to do the obvious thing and KEEP THEIR IDIOT
MOUTHS SHUT about it, because it is much more important to sound
intelligent when talking to your friends.
This post was STUPID.
---
The Most Terrifying Thought Experiment of All Time
http://www.slate.com/articles/technology/bitwise/2014/07/roko_s_basilisk_the_most_terrifying_thought_experiment_of_all_time.html

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


Re: Changing website version written in python+django

2014-08-04 Thread Jagger
Hi Clifford,

Thanks for your detailed answer.

Regards,
Zoli



> Hi Zoli, 
>
> I'm assuming that you're not using virtualenv right now. The best way to 
> do this is to use virtualenv, virtualenwrapper, and a revision control 
> system like Mercurial. The workflow goes something like this. 
>
> mkvirtualenv new_site 
> # pip install (all the bits that make up your site with the versions 
> that you want) 
> # hg clone (/path/to/old_site) 
> # run automated tests 
> # cd (to wherever manage.py is) 
> python manage.py runserver 
>
> That will enable you to test the upgraded site without any risk of 
> breaking the currently working site. Once you're satisfied that it's 
> working as you expect, you can "pip freeze > requirements.txt" and use 
> that as the basis of seeding an installation on the production server. 
> Again, use virtualenv on the server so that you can isolate the 
> environment for your site from the system-wide site-packages. 
>
> We have a site we built using Mezzanine 3.0.9. It pulled in Django 1.6.2 
> as a dependency when we did "pip install Mezzanine". In a test 
> virtualenv, we duplicated the production virtualenv so we had Mezzanine 
> 3.0.9 and all its dependencies. We then ran "pip install --upgrade 
> Mezzanine" and that pulled in Mezzanine 3.1.9 with Django 1.6.5. 
> Immediately, we noticed there was some breakage on the site we built. We 
> downgraded to Mezzanine 3.0.9 in the test environment while leaving 
> Django 1.6.5 alone and that breakage disappeared so it's clear that it's 
> not Django but Mezzanine at the source of the breakage. 
>
> We upgraded Django to 1.6.5 in the production environment while leaving 
> Mezzanine at 3.0.9 and we'll have to deal with the breakage of our site 
> with Mezzanine 3.1.9 in the test environment before we can upgrade 
> Mezzanine in production, too. If we weren't using virtualenv, that would 
> have been an ordeal. 
>
> -- 
> Regards, 
>
> Clifford Ilkay 
>
> 647-778-8696 
>
> Dinamis 
>
>  
>
>

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


Re: unsupported opperand type(s)

2014-08-04 Thread Collin Anderson
If you have no data that is important, I'd just delete the database and 
start fresh. If you're using sqlite you can simply `rm db.sqlite3` and then 
run python manage.py migrate again.

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


Re: unsupported opperand type(s)

2014-08-04 Thread Mariusz Wilk
Django-1.6.5

W dniu poniedziałek, 4 sierpnia 2014 13:34:41 UTC+1 użytkownik Collin 
Anderson napisał:
>
> What version of django are you using?
>

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


Re: Javascript loading while executing backend python query.

2014-08-04 Thread Collin Anderson
You are saying you have a div with id="loading" with the image in it that 
is not being shown?

loading image here


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


Re: How to Construct a View with multiple and singular objects?

2014-08-04 Thread Collin Anderson
Do you get an error if you wrap it in an if statement?

{% if object.sub_object %}{{ object.sub_object }}{% endif %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/77240158-8dc9-43c7-90f3-403d2b263902%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Javascript loading while executing backend python query.

2014-08-04 Thread G Z

Hi I'm trying to write a loading script that displays a loading image while 
the django backend queries i have written are exectuting. This is to say i 
have some very complicated sql queries i call mannually with python by 
watching for specific post from the webpage to execute different queries. I 
want to display a loading while the query is executing one of them takes 
upwards of a minute because it is looking through very large amounts of 
data.

Right now I have 

$(document).ready(function(){
$('#loading').hide();});$('#queryForm').on("submit", function () {
$('#loading').show();});


This is to say that while the page is loading it will be displayed and when 
the document is ready it will hide it. 
However it doesn't show the div tag when I click any of my buttons.

   
   

I don't understand why this isn't working any suggestions?






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


Re: What is the difference between running manage.py and ./manage.py?

2014-08-04 Thread Malik Rumi
Thanks for the clarification!

On Sunday, August 3, 2014 9:16:01 PM UTC-5, Lachlan Musicman wrote:
>
> Not really, it's a Nix thing (ie, OSX and BSD as well as linux). 
>
> Basically, if you set the file to be executable (chmod +x) then 
> ./filename is a way of executing using the default file association 
> (.py is python usually). 
>
> The ./ bit indicates "look in the folder we are in" - if the file is 
> not in the folder you run it from, you will need to use the full path. 
>
> In other words, the difference is merely one of execution, both give 
> the same result, since it's two ways of doing the same thing. 
>
> cheers 
> L. 
>
> On 4 August 2014 12:03, Malik Rumi > 
> wrote: 
> > Is this a Linux thing? 
> > 
> > -- 
> > You received this message because you are subscribed 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/4b5c91a6-3ee8-4855-96fb-011e87d10d7d%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
> -- 
> You have to be really clever to come up with a genuinely dangerous 
> thought. I am disheartened that people can be clever enough to do that 
> and not clever enough to do the obvious thing and KEEP THEIR IDIOT 
> MOUTHS SHUT about it, because it is much more important to sound 
> intelligent when talking to your friends. 
> This post was STUPID. 
> ---
>  
>
> The Most Terrifying Thought Experiment of All Time 
>
> http://www.slate.com/articles/technology/bitwise/2014/07/roko_s_basilisk_the_most_terrifying_thought_experiment_of_all_time.html
>  
>

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


How to Construct a View with multiple and singular objects?

2014-08-04 Thread Malik Rumi


I have a model with numerous objects. However, some of these objects have 
sub-objects and some do not. When calling up an object with sub-objects, 
(linked by a foreign key) I’d like to display 

Object

1.Sub object

2.Sub object

And when the user requests an object with no subs, they get

Object

However, if I have a ‘get’ for objects in my view, I am going to get an 
error for all objects that have sub objects.

Similarly, if I use a listview, I will get all the objects and sub objects 
on one long page, which I don’t want. 

My tentative solution is to put this in the template:

If objects with sub objects

{{List of linked sub objects}}

else

{{object}}

Assuming that works, my difficulty is with the view. How do I write it to 
cover both situations without putting them in separate models?

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


Foreign key User on migration‏

2014-08-04 Thread Sam Contapay
Hi,

I tried adding a foreign key to a model in a Django app I'm building to 
learn 1.7. I am using Python 3.4 and Django 1.7c2

#blog/models.py

from django.contrib.auth.models import User
from django.db import models

class Comment(models.Model):
user = models.ForeignKey(User, blank=True, null=True)
created_at = models.DateTimeField(auto_now=True)
comment = models.CharField(max_length=255)

This is an already existing database I ran "manage.py makemigrations" and 
"manage.py migrate". Make migration works fine but running migrate 
generates this error (I am not using a custom user model). I don't 
understand 'auth' not found as it is in my project settings and I am using 
the admin panel:

(screens)*➜  **screens **git:(**master**) **✗* ./manage.py migrate

*Operations to perform:*

*  Synchronize unmigrated apps: *django_extensions, crispy_forms

*  Apply all migrations: *auth, admin, contenttypes, sessions, website

*Synchronizing apps without migrations:*

  Creating tables...

  Installing custom SQL...

  Installing indexes...

*Running migrations:*

  Applying website.0004_comment_created_by_user...Traceback (most recent 
call last):

  File 
"/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/apps/registry.py",
 
line 148, in get_app_config

return self.app_configs[app_label]

KeyError: 'auth'


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File 
"/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/db/migrations/state.py",
 
line 79, in render

model = self.apps.get_model(lookup_model[0], lookup_model[1])

  File 
"/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/apps/registry.py",
 
line 202, in get_model

return self.get_app_config(app_label).get_model(model_name.lower())

  File 
"/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/apps/registry.py",
 
line 150, in get_app_config

raise LookupError("No installed app with label '%s'." % app_label)

LookupError: No installed app with label 'auth'.


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "./manage.py", line 10, in 

execute_from_command_line(sys.argv)

  File 
"/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/core/management/__init__.py",
 
line 385, in execute_from_command_line

utility.execute()

  File 
"/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/core/management/__init__.py",
 
line 377, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)

  File 
"/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/core/management/base.py",
 
line 288, in run_from_argv

self.execute(*args, **options.__dict__)

  File 
"/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/core/management/base.py",
 
line 337, in execute

output = self.handle(*args, **options)

  File 
"/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/core/management/commands/migrate.py",
 
line 160, in handle

executor.migrate(targets, plan, fake=options.get("fake", False))

  File 
"/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/db/migrations/executor.py",
 
line 63, in migrate

self.apply_migration(migration, fake=fake)

  File 
"/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/db/migrations/executor.py",
 
line 91, in apply_migration

if self.detect_soft_applied(migration):

  File 
"/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/db/migrations/executor.py",
 
line 135, in detect_soft_applied

apps = project_state.render()

  File 
"/Users/scontapay/.pyenv/versions/screens/lib/python3.4/site-packages/django/db/migrations/state.py",
 
line 89, in render

model=lookup_model,

ValueError: Lookup failed for model referenced by field 
website.Comment.created_by_user: auth.User

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/74e54208-83b0-44b9-b556-99950af3a78f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: unsupported opperand type(s)

2014-08-04 Thread Collin Anderson
What version of django are you using?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/dbb2256d-82e4-46c5-b3d9-1910e385e809%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: deploying django

2014-08-04 Thread Collin Anderson
I'd start by reading the docs on deploying with apache and 
mod_wsgi https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/

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


Re: Get latest timestamp+value from each group

2014-08-04 Thread Collin Anderson
Or if you have a "latest" boolean, that would also work.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/506723be-1f3c-4049-911b-d4f462e2d24e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Please help:ImportError: No module named django

2014-08-04 Thread Collin Anderson
in the python shell try running:

import sys
sys.path

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


Re: How to modify subpackage in django project

2014-08-04 Thread Collin Anderson
I recommend not messing with sys.modules. Does your huge package not have 
any other way to override things? Is there a smaller package that you can 
use instead?

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


Re: Image upload problem with UserProfile and my form

2014-08-04 Thread Collin Anderson
Set MEDIA_URL to '/media/' or something.

Then add static() to your urls.py if you haven't.

https://docs.djangoproject.com/en/dev/howto/static-files/#serving-files-uploaded-by-a-user-during-development

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


Re: unsupported opperand type(s)

2014-08-04 Thread Mariusz Wilk
Kinda worked. I deleted my Poll objects and created a new one. But then, a 
few more lines into the tutorial, there are these commands one after 
another:

p = Poll.objects.get(pk=1)

p.choice_set.all()

I get: *OperationalError: no such column: polls_choice.choice_text*

It should be simply:

[]

P.S. I'm using Python 3.4.1

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


deploying django

2014-08-04 Thread ngangsia akumbo
I have created a complete site, 

i have configured it to run with mysql using wamp

i have also configured apache in wamp which is up and running

so i want to deploy the site to run as a life page on the internet using 
apache

what should i do next

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


Re: How to use send_mail function.

2014-08-04 Thread Andreas Kuhne
Hi Chen,

Check this post:
http://stackoverflow.com/questions/15985191/how-can-i-send-e-mail-from-django-using-the-google-smtp-server

I think you are missing the settings for secure SMTP (which google
requires).

Regards,

Andréas


2014-08-04 9:42 GMT+02:00 Chen Xu :

> Hi Everyone,
> I am trying to send emails from gmail, I know I can do it if I put the
> following in settings.py:
>
> EMAIL_USE_TLS = True
> EMAIL_HOST = 'smtp.gmail.com'
> EMAIL_HOST_USER = 'exam...@gmail.com'
> EMAIL_HOST_PASSWORD = 'password'
>
> But I wonder if I dont specify them, and call it in the following way.
>
> send_mail('Subject here', 'Here is the message.', 'f...@example.com',
> ['t...@gmail.com'], fail_silently=False, auth_user='example@
> gmail.com', auth_password='password').
>
> It says connection refused. How do I fix this.
>
> 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-qbGz_g31Cah4bR9iRLwNMyQiwYh%2Bv81qbROY6%2BdwJOXxw%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/CALXYUbmcZ2QsXNdCctx%2B1cY1%2Bz8jBR40RjLFwdMXSujznAEALg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to use send_mail function.

2014-08-04 Thread Chen Xu
Hi Everyone,
I am trying to send emails from gmail, I know I can do it if I put the
following in settings.py:

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'exam...@gmail.com'
EMAIL_HOST_PASSWORD = 'password'

But I wonder if I dont specify them, and call it in the following way.

send_mail('Subject here', 'Here is the message.', 'f...@example.com',
['t...@gmail.com'], fail_silently=False, auth_user='exam...@gmail.com',
auth_password='password').

It says connection refused. How do I fix this.

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