static file rendering help

2013-04-04 Thread Fatih Tiryakioglu
Hi all,

I want to render back "user uploaded images" via template. I pass the 
shortcuts to the template, but template can't show it: only small image 
symbol. How can i show it up. I tryed some 'MEDIA_ROOT', 'MEDIA_URL' 
settings, and read some info, but i couldn't figure out..

I appreciate your helps..


--

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Job opportunity in Silicon Valley

2013-04-04 Thread Daniel França
Hello people,
We've  a good job opportunity on a startup at Silicon Valley with Django.

We look for people motivated and with passion for development to bring new
ideas to life.
The work can be done in home office.

The skills needed:
Good technical skills in Python/Django.
Good english (for meetings/conversation).
Allowed to move to Silicon Valley.

Plus
Good knowledge in TDD.

If you feel you fit the job please send your resume to
dan...@weddingsnap.com.

-- 
Daniel França,
about.me/danielfranca

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Trouble with CSS/Static Files

2013-04-04 Thread Vibhu Rishi
Hi,

>Have you ran
>$ manage.py collectstatic

Can you explain why I need to do this on my dev machine when I am not
deploying it to production ? If I look at the docs at
https://docs.djangoproject.com/en/dev/howto/static-files/#deployment , it
mentions that I need to run this to deploy it. However, the problem I was
getting was on my local system.


Vibhu


On Fri, Apr 5, 2013 at 4:00 AM, CJ Milholland  wrote:

> Have you ran
>
> $ manage.py collectstatic
>
> On Thursday, April 4, 2013 12:49:11 AM UTC-7, Vibhu Rishi wrote:
>>
>> I am not sure where I am going wrong, but the CSS files are just not
>> getting picked up. I have just started a project and am using the dev
>> server with the runserver command.
>>
>> Here's my relevant settings.py :
>>
>>
>> STATIC_ROOT = os.path.join(os.path.dirname(_**_file__),'/static/')
>> STATIC_URL = '/static/'
>>
>> My directory structure :
>> .
>> ├── homepage
>> │   └── templates
>> │   └── homepage
>> ├── qj
>> └── static
>> ├── css
>> ├── img
>> └── js
>>
>> qj is where my settings.py file is.
>> static is where i have the css. I am using bootstrap css files. I want it
>> to be at the top location as these files are going to be used in all the
>> apps that i will be writing.
>> homepage is where i have the index page that I am trying to link the css
>> to. the html is as follows :
>>
>> $ cat homepage/templates/homepage/**index.html
>>
>> 
>> 
>>   
>>   {% load static %}
>> Hello World!
>> 
>>  
>> > media="screen">
>>   
>>   
>>   Hello World
>>  > src="http://code.jquery.com/**jquery.js<http://code.jquery.com/jquery.js>
>> ">
>> 
>>   
>> 
>>
>> I am trying both the {% static  %} and the hardcoded static/js to
>> see if it is working. The following is the output i get on loading the /
>> page:
>>
>> [04/Apr/2013 12:23:38] "GET / HTTP/1.1" 200 413
>> [04/Apr/2013 12:23:38] "GET /static/css/bootstrap.min.css HTTP/1.1" *404*1667
>> [04/Apr/2013 12:23:38] "GET /static/js/bootstrap.min.js HTTP/1.1" *404*1661
>>
>> It just is not picking up the css or the js file. What am I doing wrong ?
>>
>> Regards,
>> Vibhu
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Simplicity is the ultimate sophistication. - Leonardo da Vinci
Life is really simple, but we insist on making it complicated. - Confucius

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




RE: Help in making a portal

2013-04-04 Thread Anoop Nayak
I had already posted in the that group but there was no answer. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: General Apache Deploy Strategy

2013-04-04 Thread Mike Dewhirst

On 5/04/2013 12:36am, Bill Freeman wrote:

It is also possible to use a non-distribted VCS, like Subversion, but
you lose, IIUC, the ability to check in incremental stuff


If you work in (say) your own branch of a SVN repo you can check in as 
often as you like. And you can merge other branches - including trunk - 
into your own as often as you like. That is the "way" it is intended to 
be used. Only when you are convinced all the merged changes (including 
trunk) in your own branch work properly would you be confident in 
merging back into trunk.


So if "the network is the computer", SVN *is* distributed and 
increment-friendly. I think git and friends are very popular because so 
many devs like to operate with laptops in cafes and trains etc.


or check what

was their in an older version, when not connected.


That is true if the SVN repo is on the network. But there are a number 
of ways to organise things with a local repo if that is your situation. 
However, if that is your situation, I agree git or hg would be better.


I'm just planning a deployment scenario with SVN: dev --> staging 
(sharing the dev database) --> production.


I'll open up a deploy branch in the repo and merge trunk into that when 
I'm ready to deploy. Then I only need a script on the production server 
to fetch the deploy branch whenever I want to update production.


Mike

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: 'url' template tag throws and error after upgrading to 1.4

2013-04-04 Thread Bastian
I am trying now in a brand new environment, I have set up a new os, a new 
virtualenv with all the dependencies upgraded to latest versions, and I 
installed the project from the repository. It loads with debug = False, quite 
strange. I need it to work with debug = True and I want to understand what is 
wrong. Thanks for the 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: 'url' template tag throws and error after upgrading to 1.4

2013-04-04 Thread Bastian
I'm not sure what you mean with 'connect to views'. In this case Django is 
complaining about the URL tags, the first one that gives an error tries to load 
django.views.i18n.javascript_catalog. When I manage.py shell I can do from 
django.views import * without problem. 
I really have no clue, maybe it is related to the static files in 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: 'url' template tag throws and error after upgrading to 1.4

2013-04-04 Thread Mark Furbee
Can you run manage.py shell and connect to 'views?'


On Thu, Apr 4, 2013 at 4:13 PM, Mark Furbee  wrote:

> It would appear to me that your missing the path to django in your
> environment. When you upgraded did you also upgrade to another version of
> Python, perhaps? Is the dist-packages/site-packages django folder in the
> same place it was?
>
>
> On Thu, Apr 4, 2013 at 3:58 PM, Bastian wrote:
>
>> I have tried with runserver and debug = True and it gives me the error
>> but when I turn off debug then the site loads fine.
>> Then I installed gunicorn and with debug = true and the error appears but
>> with debug = False the site loads fine but without the static content.
>> I don't know if this is a clue about something wrong in the static
>> settings or if it's just a setting in gunicorn.
>>
>> Any idea?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: 'url' template tag throws and error after upgrading to 1.4

2013-04-04 Thread Mark Furbee
It would appear to me that your missing the path to django in your
environment. When you upgraded did you also upgrade to another version of
Python, perhaps? Is the dist-packages/site-packages django folder in the
same place it was?


On Thu, Apr 4, 2013 at 3:58 PM, Bastian  wrote:

> I have tried with runserver and debug = True and it gives me the error but
> when I turn off debug then the site loads fine.
> Then I installed gunicorn and with debug = true and the error appears but
> with debug = False the site loads fine but without the static content.
> I don't know if this is a clue about something wrong in the static
> settings or if it's just a setting in gunicorn.
>
> Any idea?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [django-users] How to dynamically set crop processor parameters in django-imagekit ?

2013-04-04 Thread CJ Milholland
Not sure if this is the direction you are looking to go but I have had 
great luck using 

http://sorl-thumbnail.readthedocs.org/en/latest/examples.html

You do your template cropping in the template, This does require you to 
setup a caching server. 

Hope this helps! 

On Thursday, April 4, 2013 2:44:31 PM UTC-7, leonardo wrote:
>
> Hi,
>
> I am using django-imagekit to crop images.
> I have this model:
>
> *from imagekit.models import ImageSpecField*
> *from imagekit.processors import Crop*
>
> *class Image(models.Model):*
> *x1 = models.IntegerField(blank=True, default=0)*
> *y1 = models.IntegerField(blank=True, default=0)*
> *height = models.IntegerField(blank=True, default=0)*
> *width = models.IntegerField(blank=True, default=0)*
> *image_file = models.ImageField(upload_to='images/')*
> *
> *
> *cropped_image = ImageSpecField(*
> *[Crop(width=171, height=82, anchor=None, x=-224, y=-283)],*
> *image_field='image_file',*
> *format='JPEG', options={'quality': 90})*
>
> How can I use the object's attributes x1, y1, width and height as 
> parameters to Crop processor ?
>
> Regards,
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Trouble with CSS/Static Files

2013-04-04 Thread CJ Milholland
Have you ran 

$ manage.py collectstatic

On Thursday, April 4, 2013 12:49:11 AM UTC-7, Vibhu Rishi wrote:
>
> I am not sure where I am going wrong, but the CSS files are just not 
> getting picked up. I have just started a project and am using the dev 
> server with the runserver command. 
>
> Here's my relevant settings.py : 
>
>  
> STATIC_ROOT = os.path.join(os.path.dirname(__file__),'/static/')
> STATIC_URL = '/static/'
>
> My directory structure : 
> .
> ├── homepage
> │   └── templates
> │   └── homepage
> ├── qj
> └── static
> ├── css
> ├── img
> └── js
>
> qj is where my settings.py file is. 
> static is where i have the css. I am using bootstrap css files. I want it 
> to be at the top location as these files are going to be used in all the 
> apps that i will be writing.
> homepage is where i have the index page that I am trying to link the css 
> to. the html is as follows : 
>
> $ cat homepage/templates/homepage/index.html 
>
> 
> 
>   
>   {% load static %}
> Hello World!
> 
>  
>  media="screen">
>   
>   
>   Hello World
>  http://code.jquery.com/jquery.js";>
> 
>   
> 
>
> I am trying both the {% static  %} and the hardcoded static/js to see 
> if it is working. The following is the output i get on loading the / page: 
>
> [04/Apr/2013 12:23:38] "GET / HTTP/1.1" 200 413
> [04/Apr/2013 12:23:38] "GET /static/css/bootstrap.min.css HTTP/1.1" *404*1667
> [04/Apr/2013 12:23:38] "GET /static/js/bootstrap.min.js HTTP/1.1" *404*1661
>
> It just is not picking up the css or the js file. What am I doing wrong ? 
>
> Regards,
> Vibhu
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django 1.4 - how to display a success message on form save

2013-04-04 Thread Zach Mance
Hi Kurtis,

I saw your SO post, and I'm trying trigger success messages from my CBV's, 
and I'm just wondering how your "MessageMixin" methods work with your 
CBV's. For example, where/how does the form_valid() get called to pass the 
success_message from the CBV's. 

Also, will this work with 1.4? 


On Tuesday, June 26, 2012 10:31:17 AM UTC-5, Kurtis wrote:
>
> We do it all over our site. I use class-based views but you can checkout 
> my "MessageMixin". I have the code on this stackoverflow page:
>
>
> http://stackoverflow.com/questions/5531258/example-of-django-class-based-deleteview/10903943#10903943
>
> It will show up wherever you send the user to next, as long as your 
> template is coded to display the message.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: 'url' template tag throws and error after upgrading to 1.4

2013-04-04 Thread Bastian
I have tried with runserver and debug = True and it gives me the error but when 
I turn off debug then the site loads fine.
Then I installed gunicorn and with debug = true and the error appears but with 
debug = False the site loads fine but without the static content.
I don't know if this is a clue about something wrong in the static settings or 
if it's just a setting in gunicorn.

Any idea?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[django-users] How to dynamically set crop processor parameters in django-imagekit ?

2013-04-04 Thread Leonardo S
Hi,

I am using django-imagekit to crop images.
I have this model:

*from imagekit.models import ImageSpecField*
*from imagekit.processors import Crop*

*class Image(models.Model):*
*x1 = models.IntegerField(blank=True, default=0)*
*y1 = models.IntegerField(blank=True, default=0)*
*height = models.IntegerField(blank=True, default=0)*
*width = models.IntegerField(blank=True, default=0)*
*image_file = models.ImageField(upload_to='images/')*
*
*
*cropped_image = ImageSpecField(*
*[Crop(width=171, height=82, anchor=None, x=-224, y=-283)],*
*image_field='image_file',*
*format='JPEG', options={'quality': 90})*

How can I use the object's attributes x1, y1, width and height as
parameters to Crop processor ?

Regards,

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




request.FILES empty, I think I am doing everything correctly

2013-04-04 Thread John
This is Django 1.5
Python 2.7.3
MYSQL Database

Here is the model that I am using:

class SupportingDocument(models.Model):

"""Defines an archived attachment."""

provision = models.ForeignKey(Provision, null = False, blank = False)

submitted_by = models.CharField(max_length = 64, null = False, blank = 
True, default = "")

source_file_name = models.CharField(max_length = 256, null = False, 
blank = False)

content_type = models.CharField(max_length = 64, null = True, blank = 
True, default = "")

submission_time = models.DateTimeField()

version = models.CharField(max_length = 32, null = True, blank = True, 
default = "")

comment = models.TextField(null = True, blank = True, default = "")

saved_file = models.FileField(upload_to = "supporting_documents", null 
= True, blank = True)



def __init__(self, *args, **kwargs):

super(SupportingDocument, self).__init__(*args, **kwargs)

self.submission_time = datetime.today()



def __unicode__(self):

return self.source_file_name + ':' + unicode(self.submission_time)


and the form definition

class SupportingDocumentForm(ModelForm):

def __init__(self, *args, **kwargs):

try:

provision = None

if 'provision' in kwargs:

self.provision = kwargs.pop('provision')

if 'user' in kwargs:

self.submitted_by = kwargs.pop('user')

except Exception, e:

pass

return super(SupportingDocumentForm, self).__init__(*args, **kwargs)



class Meta:

model = SupportingDocument

exclude = ('provision', 'submitted_by', 'source_file_name', 
'content_type', 'submission_time')


def save(self, request=None, commit=True):

try:

supporting_document = super(SupportingDocumentForm, 
self).save(commit=False)

supporting_document.source_file = self.source_file

supporting_document.provision = self.provision

supporting_document.submitted_by = self.submitted_by

supporting_document.save()

except Exception, e:

provisionLogger.error('Failure:%s when supplementing group 
details' %(repr(e)))



def as_table(self):

try:

response = super(SupportingDocumentForm, self).as_table()

except Exception, e:

pass

return response

and the code to handle the request

def supporting_document_new(request):

current_tab = "Data"

current_section = "SUPDOCS"

action_url = urlresolvers.reverse('provision-supporting-document-new')

if request.POST:

try:

form = SupportingDocumentForm(request.POST,

  request.FILES,

  provision=request.provision,

  user=request.user)

if form.is_valid():

supporting_document = form.save()

return redirect_to_url("provision-supporting-document-list")

except Exception, e:

modal_error_message = "Fatal error:" + repr(e)

provisionLogger.error("Error saving Supporting Document %s" % 
(supporting_document.source_file))

else:

try:

form = SupportingDocumentForm(provision=request.provision, 
user=request.user)

except Exception, e:

pass

return render_to_response("provision/suppdocform.html", locals(), 
context_instance=RequestContext(request))

and the html for the form

Supporting Document {{ sourcefile }}





{{ form.as_table }}

 





   











{% if modal_error_message %}

{{ modal_error_message }}

{% else %}

 

{% endif %}





 



{% csrf_token %}

I am sure that there must be a problem with the html but this is driving me 
crazy.  Probably some stupid typo.

When I set a breakpoint following the if request.POST the request.FILES is 
an empty dictionary.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




RE: Help in making a portal

2013-04-04 Thread Babatunde Akinyanmi
Hi,
Try the django filer group http://groups.google.com/group/django-filer

Sent from my Windows Phone
--
From: Anoop Nayak
Sent: 4/4/2013 3:58 PM
To: django-users@googlegroups.com
Subject: Help in making a portal

I'm a newbie to django and I was trying to make a portal where the users
can upload and download files. I found this plugin called django-filer and
i integrated to my site. The problem now I'm facing is that this plugin can
only be accessible to admins. or it is present only to admins. How can I
make it available for users. Please advice. Do I need to define my own
models, templates and views for this. Could anybody guide me through?

thanks in advance.
-a helpless noob in django

-- 
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: 'url' template tag throws and error after upgrading to 1.4

2013-04-04 Thread Bastian
Thanks for the answer. But it does not really make any difference. I am still 
trying to figure out what is wrong in 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Can i access my database with Django?(Urgent)

2013-04-04 Thread Bill Freeman
I believe that additional tables are required to run Django, such as
session and user tables, stuff to do with permissions, stuff to do with
content types.  Maybe you can avoid these by not including the core
applications in INSTALLED_APPS, but then you couldn't log in to or be
designated an superuser to see the admin.  I don't know that code deeply
enough to suggest a work around.


On Thu, Apr 4, 2013 at 2:22 PM, Giorgos Kontogiorgakis <
shortgeorge...@yahoo.com> wrote:

> So,after i run the inspectdb i have a model.py file generated that creates
> models by introspecting my existing database,right?After that thing i must
> create an app and place the models.py that generated after running
> inspectdb in there and then add the app to my INSTALLED_APPS setting and
> run the python manage.py syncdb last?
> With this way will i be able to see the tables of my database on my webui
> and NOT creating additional tables,right?Or i am wrong!?Please help 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.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Suddenly manage.py syncdb fails with 'no such table django_session'

2013-04-04 Thread Thomas Weholt
I'm using django 1.5.1, python 2.7.3, ubuntu 12.10 and sqlite. My project
has been running flawlessly, but I added a database field, deleted my
sqlite database-file and ran python manage.py syncdb. Now it suddenly fails
with

DatabaseError: no such table: django_session.

I haven't changed settings.py since my last successful run. I've also
googled the problem (and it seem to pop up once in a while), but none of
the solutions provided solved the problem. I've also made the path to the
databasefile absolute, like so:

import os
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(PROJECT_PATH, 'database.db'),
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}

What's going on?

-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Password reset email not sent

2013-04-04 Thread Max Lynch
I had the same problem, and it turned out to be that I didn't have a value 
set for DEFAULT_FROM_EMAIL.

Hope that helps someone in the future.

On Tuesday, May 4, 2010 4:28:04 PM UTC-5, Shawn Milochik wrote:
>
> I don't know why your e-mail isn't being sent, but I know that if multiple 
> User instances have the same e-mail address, then that e-mail address will 
> receive one message per User. Each one will specify the username, so it's 
> easy to reset the correct password. 
>
> Shawn 
>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group. 
> To post to this group, send email to django...@googlegroups.com. 
>
> To unsubscribe from this group, send email to 
> django-users...@googlegroups.com . 
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Can i access my database with Django?(Urgent)

2013-04-04 Thread Giorgos Kontogiorgakis
So,after i run the inspectdb i have a model.py file generated that creates 
models by introspecting my existing database,right?After that thing i must 
create an app and place the models.py that generated after running 
inspectdb in there and then add the app to my INSTALLED_APPS setting and 
run the python manage.py syncdb last?
With this way will i be able to see the tables of my database on my webui 
and NOT creating additional tables,right?Or i am wrong!?Please help 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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Problems receiving data from DB (sqlite3)

2013-04-04 Thread Alexis Roda

Al 03/04/13 19:38, En/na Johannes ha escrit:

Hi list,
I have a confusing behaviour when I try to access some data in the DB.
I created a model and build the database with syncdb.
I can create and save data via python manage.py shell and it's still
available after I a restart of the shell.
But this data is not visible from the testserver. Even more, If I create
and save data from the testserver, it's only available until I restart
the server.


Sounds like you're using two DBs ... does not make much sense since I'd 
expect you're using the same settings.py in both cases, so the same 
database. In the testserver it looks like an in memory database which is 
destroyed upon restart.


Out of curiosity, what happens to the data created through the shell 
after starting/stoping the testserver, it's still there?


In order to diagnose what the problem really is I'd suggest to add a 
print to some of your views:


def your_view(request, ...):
from django.conf import settings
print "databases", settings.DATABASES
...
rest of your code

and in the shell just:

from django.conf import settings
print "databases", settings.DATABASES

Compare both outputs to make sure you're using the same database.


HTH

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django 1.5 with uwsgi(threaded)/mysql seems to magically cache querysets

2013-04-04 Thread budlight
I would say its definitely not isolation level, as restarting the django 
instance made this issue go away for a few hours.  I would setup a test for 
this, but don't really know if there already exist any per thread tests for 
django sanity I could look at for examples. 


The caching change is about related models, this doesn't use any real 
related models, it does use them through the .values() call.  Maybe this is 
a side affect of that caching, but that mentions nothing about the caching 
persisting past a single request.  If that actually happens, i'm sure many 
people using django 1.5 are going to run into all kinds of data loss 
scenarios.  

On Tuesday, April 2, 2013 11:09:19 AM UTC-6, Alan Johnson wrote:
>
> It's tough to know what the deal is without any info on your code or 
> database, but two things come to mind. One is some of the new caching in 
> Django 1.5 for related models (
> https://docs.djangoproject.com/en/dev/releases/1.5/#caching-of-related-model-instances),
>  
> and the other is database isolation level (e.g. for Postgres: 
> http://www.postgresql.org/docs/9.1/static/transaction-iso.html)
>
> On Monday, April 1, 2013 9:40:08 AM UTC-4, budl...@gmail.com wrote:
>>
>> So I have some stats reports that I run that it almost seems as if each 
>> thread has its own queryset cached.  Each time I refresh they change.  I'm 
>> going to revert back to 1.4 due to this bug.  I wish I could come up with a 
>> simple example, to demonstrate this, the problem is that the underlying 
>> database needs to change between the time each thread serves a request. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Adding context data to a TemplateView?

2013-04-04 Thread Dan Gentry
Roy, I agree with Fallen that a subclass of TemplateView is required here. 
 I have used this technique often.  Dan

class MyTemplateView(TemplateView):
template_name = 'my_template.html'

def get_context_data(self, **kwargs):
context = super(MyTemplateView, self).get_context_data(**kwargs)
context['custom_variable'] = u'my special data'
return context

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Can i access my database with Django?(Urgent)

2013-04-04 Thread Giorgos Kontogiorgakis
So,after i run the inspectdb i have a model.py file generated that creates 
models by introspecting my existing database,right?After that thing i must 
create an app and place the models.py that generated after running 
inspectdb in there and then add the app to my INSTALLED_APPS setting and 
run the python manage.py syncdb last?
With this way will i be able to see the tables of my database on my webui 
and not creating additional tables,right?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Can i access my database with Django?(Urgent)

2013-04-04 Thread Bill Freeman
Be sure that you back up your  database first, or at least soon, just in
case...


On Thu, Apr 4, 2013 at 11:35 AM, Giorgos Kontogiorgakis <
shortgeorge...@yahoo.com> wrote:

> Thanks a lot Tom for your time and for your help.i'll check what u've send
> me and i'll inform you right after!
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Can i access my database with Django?(Urgent)

2013-04-04 Thread Giorgos Kontogiorgakis
Thanks a lot Tom for your time and for your help.i'll check what u've send 
me and i'll inform you right after!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Can i access my database with Django?(Urgent)

2013-04-04 Thread Tom Evans
On Thu, Apr 4, 2013 at 4:11 PM, Giorgos Kontogiorgakis
 wrote:
> Hi there!
> I am new to Django and Python as well!I have a project to make and i'm
> really confused of what i must do to start it!I hope that you can help me
> somehow to make a start!First of all i have been given an existing database
> with existing tables and columns in it!I started reading Django tutorial 1 &
> 2,i edited the setting.py  (DATABASES 'default' item) to match my database
> connection settings.I made the admin part as well and i can log in
> successfully!The thing is that i want to inform the webui from my
> database.For example,i have a table named Nodes with many fields in it and i
> want my webui to "see" this table and its fields so i can see them in my
> webui,access them and edit them!At the tutorial making classes is like
> creating new Tables,and this is not the thing i want to do!Is there any way
> that i can access my already existing database and inform my webui?
>

Django models can specify the table name for a model, or the column
names for a particular field. It can also automatically inspect your
database and produce models from it:

https://docs.djangoproject.com/en/1.5/howto/legacy-databases/

Bear in mind that it will not always make the right choice when
translating a column field to a model field.

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Problem with intermediary table from legacy database

2013-04-04 Thread Vittorio
Thanks a lot Russ Magee, now it works.
Ciao
Vittorio
Il giorno 04/apr/2013, alle ore 14:24, Russell Keith-Magee ha scritto:

> 
> 
> On Thu, Apr 4, 2013 at 6:48 PM, Tom Evans  wrote:
> On Thu, Apr 4, 2013 at 11:35 AM, Russell Keith-Magee
>  wrote:
> >
> >
> > On Thu, Apr 4, 2013 at 5:28 PM, Vittorio  wrote:
> >>
> >> Under Django 1.5.1 I'm having a go at using ManyToManyField (see below 
> >> models.py and admin.py files) referring to an Sqlite3 legacy db.
> >>
> >> I'm receiving the following fatal error message in admin
> >>
> >> Exception Value:
> >>
> >> 'LibroOption.fields' can't include the ManyToManyField field
> >>
> >> 'autore' because 'autore' manually specifies a 'through' model
> >
> >
> > The error is telling you exactly what the problem is. You can't put autore 
> > in the list of admin-displayed fields (or, for that matter, the list of 
> > filter_horizontal) because it uses a through model.
> >
> > There's a very simple reason for this - a through model exists to allow you 
> > to specify additional data on a relation. The basic m2m widget (in any of 
> > it's forms, including raw_id_field and filter_horizontal/vertical) only 
> > allow you to define the "other" object that you want a relation with. You 
> > can't set up a 'through' relation without specifying the extra data as 
> > well, so you're prohibited from using the basic m2m widgets on m2m 
> > relations with a through model.
> >
> > If you want to have an admin representation for an m2m relation with a 
> > through model, you need to add an inline to represent the through model. 
> > See [1] for more details.
> >
> > That said, if I'm reading your models correctly, it looks like the 
> > "through" model isn't actually required, it's just been introspected that 
> > way -- it's easier for the introspector to create a model for *every* 
> > table, rather than try to work out which tables are actually m2m tables.
> >
> > It should be possible to remove the explicit definition of the LibriAutori 
> > model, and replace the autori m2m relation with:
> >
> >autori = models.ForeignKey(Autore,db_column='autori', 
> > db_table='LibriAutori')
> >
> 
> This should be a ManyToMany field with the same options, no?
> 
> /facepalm
> 
> You are completely correct. I lose my keyboard privileges for the evening :-)
> 
> Yours
> Russ Magee %-)
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Can i access my database with Django?(Urgent)

2013-04-04 Thread Giorgos Kontogiorgakis
Hi there!
I am new to Django and Python as well!I have a project to make and i'm 
really confused of what i must do to start it!I hope that you can help me 
somehow to make a start!First of all i have been given an existing database 
with existing tables and columns in it!I started reading Django tutorial 1 
& 2,i edited the setting.py 
 
(DATABASES 
'default' item) to match my database connection settings.I made the admin 
part as well and i can log in successfully!The thing is that i want to 
inform the webui from my database.For example,i have a table named Nodes 
with many fields in it and i want my webui to "see" this table and its 
fields so i can see them in my webui,access them and edit them!At the 
tutorial making classes is like creating new Tables,and this is not the 
thing i want to do!Is there any way that i can access my already existing 
database and inform my webui?

Sorry for some syntax error but my native lang isn't english!
Waiting for your help as soon as possilbe!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Trouble with CSS/Static Files

2013-04-04 Thread Vibhu Rishi
Thanks Tom, your post got me thinking ! If the problem was the pathing then
using the absolute path should have worked. So , I put in
STATIC_ROOT="/home/vibhu/Programming/qj/static/"

But that still did not work - which means that I was still doing something
wrong. Finally, it hit me - I was using the wrong variable (see comment
copied below).

Instead of STATIC_ROOT , I should have been using STATICFILES_DIR

So, now my settings.py is as follows :

# Absolute path to the directory static files should be collected to.
# *Don't put anything in this directory yourself*; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
STATIC_ROOT=""
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
 os.path.join(os.path.dirname(__file__),'../static/'),
)


And this is working ! Thanks for the tip for going up a directory else i
would still be floundering !

Vibhu



On Thu, Apr 4, 2013 at 7:24 PM, Tom Evans  wrote:

> On Thu, Apr 4, 2013 at 8:49 AM, Vibhu Rishi  wrote:
> > I am not sure where I am going wrong, but the CSS files are just not
> getting
> > picked up. I have just started a project and am using the dev server with
> > the runserver command.
> >
> > Here's my relevant settings.py :
> >
> >
> > STATIC_ROOT = os.path.join(os.path.dirname(__file__),'/static/')
> > STATIC_URL = '/static/'
> >
> > My directory structure :
> > .
> > ├── homepage
> > │   └── templates
> > │   └── homepage
> > ├── qj
> > └── static
> > ├── css
> > ├── img
> > └── js
> >
> > qj is where my settings.py file is.
> > static is where i have the css.
>
> You've told it to look in the wrong place:
>
> >>> os.path.dirname('/path/to/project/qj/settings.py')
> '/path/to/project/qj'
> >>> os.path.join(os.path.dirname('/path/to/project/qj/settings.py'),
> 'static')
> '/path/to/project/qj/static'
>
> Try this instead:
>
> STATIC_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__),
> '..', '/static/'))
>
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
Simplicity is the ultimate sophistication. - Leonardo da Vinci
Life is really simple, but we insist on making it complicated. - Confucius

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Trouble with CSS/Static Files

2013-04-04 Thread Vibhu Rishi
Hi Jack,

Template is fine as the Hello World is getting rendered correctly. I also
get the 200 for /

Vibhu


On Thu, Apr 4, 2013 at 6:33 PM, Jacky Tedy  wrote:

> it looks like you don't have the right template ! You sure you have the
> right path?
>
>
> 2013/4/4 Vibhu Rishi 
>
>> I am not sure where I am going wrong, but the CSS files are just not
>> getting picked up. I have just started a project and am using the dev
>> server with the runserver command.
>>
>> Here's my relevant settings.py :
>>
>>
>> STATIC_ROOT = os.path.join(os.path.dirname(__file__),'/static/')
>> STATIC_URL = '/static/'
>>
>> My directory structure :
>> .
>> ├── homepage
>> │   └── templates
>> │   └── homepage
>> ├── qj
>> └── static
>> ├── css
>> ├── img
>> └── js
>>
>> qj is where my settings.py file is.
>> static is where i have the css. I am using bootstrap css files. I want it
>> to be at the top location as these files are going to be used in all the
>> apps that i will be writing.
>> homepage is where i have the index page that I am trying to link the css
>> to. the html is as follows :
>>
>> $ cat homepage/templates/homepage/index.html
>>
>> 
>> 
>>   
>>   {% load static %}
>> Hello World!
>> 
>>  
>> > media="screen">
>>   
>>   
>>   Hello World
>>  http://code.jquery.com/jquery.js";>
>> 
>>   
>> 
>>
>> I am trying both the {% static  %} and the hardcoded static/js to
>> see if it is working. The following is the output i get on loading the /
>> page:
>>
>> [04/Apr/2013 12:23:38] "GET / HTTP/1.1" 200 413
>> [04/Apr/2013 12:23:38] "GET /static/css/bootstrap.min.css HTTP/1.1" *404*1667
>> [04/Apr/2013 12:23:38] "GET /static/js/bootstrap.min.js HTTP/1.1" *404*1661
>>
>> It just is not picking up the css or the js file. What am I doing wrong ?
>>
>> Regards,
>> Vibhu
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Simplicity is the ultimate sophistication. - Leonardo da Vinci
Life is really simple, but we insist on making it complicated. - Confucius

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Help in making a portal

2013-04-04 Thread Anoop Nayak
I'm a newbie to django and I was trying to make a portal where the users 
can upload and download files. I found this plugin called django-filer and 
i integrated to my site. The problem now I'm facing is that this plugin can 
only be accessible to admins. or it is present only to admins. How can I 
make it available for users. Please advice. Do I need to define my own 
models, templates and views for this. Could anybody guide me through?

thanks in advance.
-a helpless noob in django

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Trouble with CSS/Static Files

2013-04-04 Thread Tom Evans
On Thu, Apr 4, 2013 at 8:49 AM, Vibhu Rishi  wrote:
> I am not sure where I am going wrong, but the CSS files are just not getting
> picked up. I have just started a project and am using the dev server with
> the runserver command.
>
> Here's my relevant settings.py :
>
>
> STATIC_ROOT = os.path.join(os.path.dirname(__file__),'/static/')
> STATIC_URL = '/static/'
>
> My directory structure :
> .
> ├── homepage
> │   └── templates
> │   └── homepage
> ├── qj
> └── static
> ├── css
> ├── img
> └── js
>
> qj is where my settings.py file is.
> static is where i have the css.

You've told it to look in the wrong place:

>>> os.path.dirname('/path/to/project/qj/settings.py')
'/path/to/project/qj'
>>> os.path.join(os.path.dirname('/path/to/project/qj/settings.py'), 'static')
'/path/to/project/qj/static'

Try this instead:

STATIC_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__),
'..', '/static/'))

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: e commerce django framwork

2013-04-04 Thread Kelly Nicholes
I recommend you take a look at 
https://www.djangopackages.com/grids/g/ecommerce/.  I've used satchmo a 
couple times.  I recall setting it up having a couple snags, but nothing 
unmanageable.  Overriding the templates isn't a big deal if you understand 
the TEMPLATE_URLS setting.  I haven't customized it extensively, but for 
what I needed, it was great for me right out of the box.



On Wednesday, April 3, 2013 2:03:51 AM UTC-6, mds...@gmail.com wrote:
>
> I have heard about Satchmo and would love to hear about anyone's 
> experience using it. Are there any other Python/Django based e-commerce 
> (a.k.a. shopping cart) solutions out there that you would recommend? 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: General Apache Deploy Strategy

2013-04-04 Thread Bill Freeman
Scripting is fine, but I've survived pretty well using a DVCS for
deployment.  Whether you force everything through a separate "definitive"
repository machine, to aid in knowing when you have to merge first, or
whether you simply push to a deployment box, only the changes are sent, and
only files under revision control at that, keeping your wireless bandwidth
down.  If you need deployment to multiple boxes, you can update the rest
from the one already updated, so only the commands must be sent (or one
command if you script it cleverly on the deployment boxes) for the
additional deploys.  The cost is that you have a clone of the entire
repository on your local device, but in exchange you get the benefit of
being able to work locally when you don't have a connection.

Git is a big favorite, and works fine, but as a python guy, I've always
liked Mercurial.  It is also possible to use a non-distribted VCS, like
Subversion, but you lose, IIUC, the ability to check in incremental stuff
or check what was their in an older version, when not connected.

Bill


On Wed, Apr 3, 2013 at 2:54 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

> Fabric is helpful for scripting deployment process:
> http://docs.fabfile.org/en/1.6/
>
> _Nik
>
> On 4/2/2013 4:51 PM, Mike Dewhirst wrote:
> > On 3/04/2013 1:04am, Sells, Fred wrote:
> >> We use django for intranet applications.  There is minimal coupling
> >> between applications and we generally dedicate a virtual server for each
> >> application.  Perhaps not the most efficient, but it works for our
> >> environment.
> >>
> >> In django 1.3 I just copied the “site” directory to the deploy location
> >> and since the app directory was below that, it was a simple deploy.
> >>
> >> With the revised directory structure of 1.4/1.5  I would need to copy
> >> the project root directory to the production server when deploying.
> >> That’s acceptable, except that I prefer to create a “docs” directory
> >> under the project to hold any specifications, critical instructions, etc
> >> and there is no need to deploy this, nor would I want to make it
> >> accessible to our user base.  Also I frequently work remotely on a
> >> wireless connection and copying unnecessary files is a pain.
> >
> > Can you script the deployment? Perhaps a single command can get all
> > the necessary bits from the repo?
> >
> > Non-automated deployment used to go wrong for me more often than not.
> > I use Buildbot now to get it right without fail every time.
> >
> > Mike
> >
> >>
> >> It’s not that I can’t live with copying the project in its entirety, but
> >> is there a better, more django-esque way?
> >>
> >> Thanks,
> >>
> >> Fred.
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> >> Groups "Django users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> >> an email to django-users+unsubscr...@googlegroups.com.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> Visit this group at http://groups.google.com/group/django-users?hl=en.
> >> For more options, visit https://groups.google.com/groups/opt_out.
> >>
> >>
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Trouble with CSS/Static Files

2013-04-04 Thread Jacky Tedy
it looks like you don't have the right template ! You sure you have the
right path?


2013/4/4 Vibhu Rishi 

> I am not sure where I am going wrong, but the CSS files are just not
> getting picked up. I have just started a project and am using the dev
> server with the runserver command.
>
> Here's my relevant settings.py :
>
>
> STATIC_ROOT = os.path.join(os.path.dirname(__file__),'/static/')
> STATIC_URL = '/static/'
>
> My directory structure :
> .
> ├── homepage
> │   └── templates
> │   └── homepage
> ├── qj
> └── static
> ├── css
> ├── img
> └── js
>
> qj is where my settings.py file is.
> static is where i have the css. I am using bootstrap css files. I want it
> to be at the top location as these files are going to be used in all the
> apps that i will be writing.
> homepage is where i have the index page that I am trying to link the css
> to. the html is as follows :
>
> $ cat homepage/templates/homepage/index.html
>
> 
> 
>   
>   {% load static %}
> Hello World!
> 
>  
>  media="screen">
>   
>   
>   Hello World
>  http://code.jquery.com/jquery.js";>
> 
>   
> 
>
> I am trying both the {% static  %} and the hardcoded static/js to see
> if it is working. The following is the output i get on loading the / page:
>
> [04/Apr/2013 12:23:38] "GET / HTTP/1.1" 200 413
> [04/Apr/2013 12:23:38] "GET /static/css/bootstrap.min.css HTTP/1.1" *404*1667
> [04/Apr/2013 12:23:38] "GET /static/js/bootstrap.min.js HTTP/1.1" *404*1661
>
> It just is not picking up the css or the js file. What am I doing wrong ?
>
> Regards,
> Vibhu
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Problem with intermediary table from legacy database

2013-04-04 Thread Russell Keith-Magee
On Thu, Apr 4, 2013 at 6:48 PM, Tom Evans  wrote:

> On Thu, Apr 4, 2013 at 11:35 AM, Russell Keith-Magee
>  wrote:
> >
> >
> > On Thu, Apr 4, 2013 at 5:28 PM, Vittorio  wrote:
> >>
> >> Under Django 1.5.1 I'm having a go at using ManyToManyField (see below
> models.py and admin.py files) referring to an Sqlite3 legacy db.
> >>
> >> I'm receiving the following fatal error message in admin
> >>
> >> Exception Value:
> >>
> >> 'LibroOption.fields' can't include the ManyToManyField field
> >>
> >> 'autore' because 'autore' manually specifies a 'through' model
> >
> >
> > The error is telling you exactly what the problem is. You can't put
> autore in the list of admin-displayed fields (or, for that matter, the list
> of filter_horizontal) because it uses a through model.
> >
> > There's a very simple reason for this - a through model exists to allow
> you to specify additional data on a relation. The basic m2m widget (in any
> of it's forms, including raw_id_field and filter_horizontal/vertical) only
> allow you to define the "other" object that you want a relation with. You
> can't set up a 'through' relation without specifying the extra data as
> well, so you're prohibited from using the basic m2m widgets on m2m
> relations with a through model.
> >
> > If you want to have an admin representation for an m2m relation with a
> through model, you need to add an inline to represent the through model.
> See [1] for more details.
> >
> > That said, if I'm reading your models correctly, it looks like the
> "through" model isn't actually required, it's just been introspected that
> way -- it's easier for the introspector to create a model for *every*
> table, rather than try to work out which tables are actually m2m tables.
> >
> > It should be possible to remove the explicit definition of the
> LibriAutori model, and replace the autori m2m relation with:
> >
> >autori = models.ForeignKey(Autore,db_column='autori',
> db_table='LibriAutori')
> >
>
> This should be a ManyToMany field with the same options, no?


/facepalm

You are completely correct. I lose my keyboard privileges for the evening
:-)

Yours
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: No Module Named Module Name

2013-04-04 Thread Sreenivas Reddy T
include polls application in installed_applications in settings.py file and
do this import

from polls.models import Poll in shell , let me know if that works.

HTH.

Best Regards,
Srinivas Reddy Thatiparthy
9703888668.

"Anyone who has never made a mistake has never tried anything new !!! "
--Albert Einstein


On Thu, Apr 4, 2013 at 9:48 AM, sharath bangera wrote:

>  I have Created the Project and App using Python And Django.
>  This is My Model in my model.py
>  --**--**
> --
>  class Poll(models.Model):
>  question = models.CharField(max_length=**200)
>  pub_date = models.DateTimeField('date published')
>  --**--**
> --
>  Now When run "import Poll or from polls.models import Model" through
> python shell , it gives no module named
>  Poll Error.
>
>  Project Structure :
>  mysite [project name]
> manage.py
> mysite
> files under mysite
> polls [my app]
> __init__
> models
> views
> tests
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




No Module Named Module Name

2013-04-04 Thread sharath bangera
 I have Created the Project and App using Python And Django.
 This is My Model in my model.py
 
--
 class Poll(models.Model):
 question = models.CharField(max_length=200)
 pub_date = models.DateTimeField('date published')
 
--
 Now When run "import Poll or from polls.models import Model" through 
python shell , it gives no module named
 Poll Error.

 Project Structure :
 mysite [project name]
manage.py
mysite
files under mysite
polls [my app]
__init__
models
views
tests


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Problem with intermediary table from legacy database

2013-04-04 Thread Tom Evans
On Thu, Apr 4, 2013 at 11:35 AM, Russell Keith-Magee
 wrote:
>
>
> On Thu, Apr 4, 2013 at 5:28 PM, Vittorio  wrote:
>>
>> Under Django 1.5.1 I'm having a go at using ManyToManyField (see below 
>> models.py and admin.py files) referring to an Sqlite3 legacy db.
>>
>> I'm receiving the following fatal error message in admin
>>
>> Exception Value:
>>
>> 'LibroOption.fields' can't include the ManyToManyField field
>>
>> 'autore' because 'autore' manually specifies a 'through' model
>
>
> The error is telling you exactly what the problem is. You can't put autore in 
> the list of admin-displayed fields (or, for that matter, the list of 
> filter_horizontal) because it uses a through model.
>
> There's a very simple reason for this - a through model exists to allow you 
> to specify additional data on a relation. The basic m2m widget (in any of 
> it's forms, including raw_id_field and filter_horizontal/vertical) only allow 
> you to define the "other" object that you want a relation with. You can't set 
> up a 'through' relation without specifying the extra data as well, so you're 
> prohibited from using the basic m2m widgets on m2m relations with a through 
> model.
>
> If you want to have an admin representation for an m2m relation with a 
> through model, you need to add an inline to represent the through model. See 
> [1] for more details.
>
> That said, if I'm reading your models correctly, it looks like the "through" 
> model isn't actually required, it's just been introspected that way -- it's 
> easier for the introspector to create a model for *every* table, rather than 
> try to work out which tables are actually m2m tables.
>
> It should be possible to remove the explicit definition of the LibriAutori 
> model, and replace the autori m2m relation with:
>
>autori = models.ForeignKey(Autore,db_column='autori', 
> db_table='LibriAutori')
>

This should be a ManyToMany field with the same options, no?

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Show label next to Foreing key raw_id_field

2013-04-04 Thread Almudena Vila Forcén
Hi,

I have a model with a Foreing key raw_id_field. Now, when I choose 
something and I return to the model I can only see the id. But when I save 
it and I open it again, I can see the unicode next to search button. 

I want to show the unicode as soon as I return to the model. 
I've tried to use this snippet: http://djangosnippets.org/snippets/2217/, 
but it only puts a link on the label when I can see it (when I save it and 
I open it again).

Is there any way to do this? Can I override some method and put the unicode 
inside?

Thank you very much


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Problem with intermediary table from legacy database

2013-04-04 Thread Russell Keith-Magee
On Thu, Apr 4, 2013 at 5:28 PM, Vittorio  wrote:

> Under Django 1.5.1 I'm having a go at using ManyToManyField (see below
> models.py and admin.py files) referring to an Sqlite3 legacy db.
>
> I'm receiving the following fatal error message in admin
>
> Exception Value:
>
> 'LibroOption.fields' can't include the ManyToManyField field
>
> 'autore' because 'autore' manually specifies a 'through' model
>
>
The error is telling you exactly what the problem is. You can't put autore
in the list of admin-displayed fields (or, for that matter, the list of
filter_horizontal) because it uses a through model.

There's a very simple reason for this - a through model exists to allow you
to specify additional data on a relation. The basic m2m widget (in any of
it's forms, including raw_id_field and filter_horizontal/vertical) only
allow you to define the "other" object that you want a relation with. You
can't set up a 'through' relation without specifying the extra data as
well, so you're prohibited from using the basic m2m widgets on m2m
relations with a through model.

If you want to have an admin representation for an m2m relation with a
through model, you need to add an inline to represent the through model.
See [1] for more details.

That said, if I'm reading your models correctly, it looks like the
"through" model isn't actually required, it's just been introspected that
way -- it's easier for the introspector to create a model for *every*
table, rather than try to work out which tables are actually m2m tables.

It should be possible to remove the explicit definition of the LibriAutori
model, and replace the autori m2m relation with:

   autori = models.ForeignKey(Autore,db_column='autori',
db_table='LibriAutori')

That is - explicitly provide the name of the table you want to use as an
m2m relation. See [2] for more details.

[1]
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#working-with-many-to-many-intermediary-models
[2]
https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ManyToManyField.db_table

Yours,
Russ Magee %-)



> (I've also tried to let Django to automagically define the intermediary
> table eliminating from models.py the through option, and it works like a
> charm: that is, when as admin  I open the Libri model I see the autore
> field horizontally filtered.)
>
> How can I solve this problem having to necessarily use this legacy db and
> its tables which are fed by a Filemaker procedure too?
>
> Thanks from Rome
> Vittorio
>
> 
> models.py
> from django.db import models
>
> # Create your models here.
> class Autore(models.Model):
>nome = models.CharField(db_index=True,max_length=50)
>cognome = models.CharField(db_index=True,max_length=50)
>def __unicode__(self):
>return u"%s %s" % (self.nome, self.cognome)
>class Meta:
> verbose_name_plural = "Autori"
> db_table="Autori"
> ordering=['cognome', 'nome']
> ...
> ...
> class Libro(models.Model):
>titolo = models.CharField(db_index=True,max_length=200)
>autore = models.ManyToManyField(Autore,through='LibriAutori')
>def __unicode__(self):
>   return self.titolo
>class Meta:
> verbose_name_plural = "Libri"
> db_table="Libri"
> ordering=['titolo']
>
> class LibriAutori(models.Model):
>libro = models.ForeignKey(Libro,db_column='libro')
>autori = models.ForeignKey(Autore,db_column='autori')
>class Meta:
> verbose_name_plural = "LibriAutori"
> db_table='LibriAutori'
> =
> admin.py
> from django.contrib import admin
> from biblio.models import *
> from django import forms
> #
>
> class LibroOption(admin.ModelAdmin):
> list_display = ('titolo','autore')
> fields=(('titolo'),'autore')
> filter_horizontal = ['autore', ]
> order_by= ['titolo', ]
>
>
> admin.site.register(Autore)
> admin.site.register(Libro, LibroOption)
> admin.site.register(LibriAutori)
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Problem with intermediary table from legacy database

2013-04-04 Thread Vittorio
Under Django 1.5.1 I'm having a go at using ManyToManyField (see below 
models.py and admin.py files) referring to an Sqlite3 legacy db. 

I'm receiving the following fatal error message in admin

Exception Value:
'LibroOption.fields' can't include the ManyToManyField field 
'autore' because 'autore' manually specifies a 'through' model

(I've also tried to let Django to automagically define the intermediary table 
eliminating from models.py the through option, and it works like a charm: that 
is, when as admin  I open the Libri model I see the autore field horizontally 
filtered.)

How can I solve this problem having to necessarily use this legacy db and its 
tables which are fed by a Filemaker procedure too?

Thanks from Rome
Vittorio


models.py
from django.db import models

# Create your models here.
class Autore(models.Model):
   nome = models.CharField(db_index=True,max_length=50) 
   cognome = models.CharField(db_index=True,max_length=50)
   def __unicode__(self):
   return u"%s %s" % (self.nome, self.cognome)
   class Meta:
verbose_name_plural = "Autori" 
db_table="Autori"
ordering=['cognome', 'nome']
...
...
class Libro(models.Model):
   titolo = models.CharField(db_index=True,max_length=200) 
   autore = models.ManyToManyField(Autore,through='LibriAutori')
   def __unicode__(self):
  return self.titolo
   class Meta:
verbose_name_plural = "Libri"
db_table="Libri"
ordering=['titolo']

class LibriAutori(models.Model):
   libro = models.ForeignKey(Libro,db_column='libro')
   autori = models.ForeignKey(Autore,db_column='autori') 
   class Meta:
verbose_name_plural = "LibriAutori"
db_table='LibriAutori'
=
admin.py
from django.contrib import admin
from biblio.models import *
from django import forms
#

class LibroOption(admin.ModelAdmin):
list_display = ('titolo','autore')
fields=(('titolo'),'autore')
filter_horizontal = ['autore', ]
order_by= ['titolo', ]


admin.site.register(Autore)
admin.site.register(Libro, LibroOption)
admin.site.register(LibriAutori)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Trouble with CSS/Static Files

2013-04-04 Thread Vibhu Rishi
I am not sure where I am going wrong, but the CSS files are just not
getting picked up. I have just started a project and am using the dev
server with the runserver command.

Here's my relevant settings.py :


STATIC_ROOT = os.path.join(os.path.dirname(__file__),'/static/')
STATIC_URL = '/static/'

My directory structure :
.
├── homepage
│   └── templates
│   └── homepage
├── qj
└── static
├── css
├── img
└── js

qj is where my settings.py file is.
static is where i have the css. I am using bootstrap css files. I want it
to be at the top location as these files are going to be used in all the
apps that i will be writing.
homepage is where i have the index page that I am trying to link the css
to. the html is as follows :

$ cat homepage/templates/homepage/index.html



  
  {% load static %}
Hello World!

 

  
  
  Hello World
 http://code.jquery.com/jquery.js";>

  


I am trying both the {% static  %} and the hardcoded static/js to see
if it is working. The following is the output i get on loading the / page:

[04/Apr/2013 12:23:38] "GET / HTTP/1.1" 200 413
[04/Apr/2013 12:23:38] "GET /static/css/bootstrap.min.css HTTP/1.1" *404*1667
[04/Apr/2013 12:23:38] "GET /static/js/bootstrap.min.js HTTP/1.1" *404* 1661

It just is not picking up the css or the js file. What am I doing wrong ?

Regards,
Vibhu

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Adding context data to a TemplateView?

2013-04-04 Thread Fallen Flint
Take a look at 
https://docs.djangoproject.com/en/1.4/topics/generic-views-migration/#extra-context
There's no way for provide an extra_context to a TemplateView. You need to 
subclass TemplateView and re-implement get_context_data in the way 
described in aforementioned topic.

On Monday, April 23, 2012 1:20:09 AM UTC+4, Roy Smith wrote:
>
> I'm using a generic TemplateView (django-1.4), but I want to be able to 
> add something to the context.  Is that possible?
>
> The docs at 
> https://docs.djangoproject.com/en/1.4/topics/generic-views/#adding-extra-context
>  talk 
> about "an extra optional parameter, extra_context", but I don't get what 
> they're trying to explain.  I tried the obvious:
>
> url(r'^about$',
> TemplateView.as_view(template_name='legal_ipsum/about.html',
>  extra_context={'pagename': 'about'})
> ),
>
> in my urls.py file, but that just raises: "TemplateView() received an 
> invalid keyword 'extra_context'".  What am I missing here?
>
> --
> Roy Smith
> r...@panix.com 
>
>
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: foreign key with unique versus one-to-one

2013-04-04 Thread Mike Dewhirst

On 4/04/2013 5:15pm, Russell Keith-Magee wrote:


On Thu, Apr 4, 2013 at 1:01 PM, Mike Dewhirst > wrote:

I have noticed that there appears to be no difference in Postgres
between a OneToOneField and a ForeignKey with unique=True

Is there any/much difference in Django?

At a database level - no. The implementation is identical, to the extent
that OneToOneField is a subclass of ForeignKey that forces unique=True.

At an API level, there is one very small difference. The default reverse
accessor for a Foreign Key will be named '_set', and it
will return a QuerySet. The default reverse accessor for a OneToOne Key
will be named '', and it will return a single object.


Thank you. Makes good sense. It is nice to have that flexibility for my 
own API. And obviously I can change my mind and rework the code without 
touching the database.


Much appreciated.

Mike




Yours,
Russ Magee %-)

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: foreign key with unique versus one-to-one

2013-04-04 Thread Russell Keith-Magee
On Thu, Apr 4, 2013 at 1:01 PM, Mike Dewhirst  wrote:

> I have noticed that there appears to be no difference in Postgres between
> a OneToOneField and a ForeignKey with unique=True
>
> Is there any/much difference in Django?
>

At a database level - no. The implementation is identical, to the extent
that OneToOneField is a subclass of ForeignKey that forces unique=True.

At an API level, there is one very small difference. The default reverse
accessor for a Foreign Key will be named '_set', and it will
return a QuerySet. The default reverse accessor for a OneToOne Key will be
named '', and it will return a single object.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.