Re: Looking for direction on some admin console customization.

2014-03-10 Thread Derek
Dennis

Your use case is not very clear; but it sounds more like you need a CMS, 
even a simple one.  There you can design templates that will hold all your 
page content in a layout of your choice.  There are many Django-based CMS 
e.g. https://pythonhosted.org/django-page-cms/

Derek

(PS  Your terminology is a bit mixed up here- when you say "add a text 
model, a video model", I think you mean "add a text object, a video 
object".  The models are the containers; the objects are the - crudely 
speaking - the data that makes those containers "exist")


On Monday, 10 March 2014 04:09:05 UTC+2, Dennis Marwood wrote:
>
> My goal is to be able to build a new blog entry via the admin console that 
> is comprised of text, image slider, and video models. 
>
> I would choose to create a new blog entry and then add a text model, a 
> video model, and another text model, or something like that. Each blog 
> entry could be unique in the models that it is made up of.
>
> I have messed around with adding the models via inlines. But that is just 
> not quite enough. Each of the entries ends up in its own fieldset in an 
> unintuitive disorganized display. 
>
> What are some approaches to implementing this? It would be great if I 
> could have a drop down or something that let me add a model entry, of my 
> choosing, and it was just pushed into the blog entry.
>
> Thanks in advance.
>

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


Re: Django cannot find my templates directory

2014-03-10 Thread Mike Dewhirst

On 11/03/2014 1:25pm, Cherrymae Tulfo wrote:

hi everyone!

i am looking for solutions with regards to templates directory . . i
have this results.html where the data should be displayed after it is
queried through views.py. . it should display the barangay id and the
name of the barangay itself. .

|*{% block content %}
{% if results %}
   {% for result in results %}
 {{ result.id }}
 {{ result.barangay }}
   {% endfor %}
{% else %}
 Please enter a valid UID
 
   Search Barangay: 
   
 
{% endif %}

{% endblock %}
*
|

i have also views.py that queries data from the postgresql

*|from django.template import RequestContext
def search(request):

 query = request.GET.get('q')
 try:
 query = int(query)
 except ValueError:
 query = None
 results = None
 if query:

 results = Butuan_Parcel.objects.get(id=query)

 context = RequestContext(request)

 return render('results.html', {"results": results}, 
context_instance=context)|*

*||
*i want also to know what am i missing with this. .urls.py*
*

|*(r'search', search)*


Might need to see a bit more of your urls.py file.




|

||when I search id in my index.html , the system can retrieve the data but it 
gives me an error
TemplateDoesNotExist at /search/. . what am I missing??


Django is looking in a default location for results.html. You need to 
make sure it is found or more particularly it is finding the correct 
results.html template. Check the following ...


In your settings.py module ...

TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)

# if templates are not found here, look in BASE_DIR/app_name/templates
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates/'),
# any other non-default dirs here
)

Also in your settings.py insert a print function to display your 
template dirs perhaps like this ...


if DEBUG:
for i in enumerate(TEMPLATE_DIRS, 1):
print(('TEMPLATE_DIRS#%s= %s' % i))


Note that with a specific template directory set as above, 
filesystem.Loader will look in there first before looking in the 
app_name/templates directories. I use that specific directory as a place 
for common templates which get inherited by all the application 
templates. I use it for the html error code templates which need to 
carry my error messages etc.


Where you see "# any other non-default dirs here" in my TEMPLATE_DIRS 
setting, I could have additional common template dirs if I needed to 
keep them separate for some reason.




it was also suggested to to declare my template directories
so i declared this in my settings.py

*
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
TEMPLATE_DIRS = (PROJECT_PATH+'/Apps/templates'*)


Provided you have the template loaders in the correct sequence it should 
work.


Although I'm not sure what those asterisks might be doing.



yet, nothing has worked . .i still get the error. . can anyone suggest
solutions with my problem?? Thanks in advance. .

||

||

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/6a0bc697-05bc-4952-9cd1-705422b9bbba%40googlegroups.com
.
For more options, visit https://groups.google.com/d/optout.


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


Re: Trying to set up hashed versioning in Django for static files

2014-03-10 Thread Vernon Burt
That seemed to do it.. I definitly learned a lot about serving these files. 
Thank you to both Tom and Camilo, you helped me a lot!

Thanks again,

Vernon Burt

On Monday, March 10, 2014 6:02:30 AM UTC-7, Tom Evans wrote:
>
> On Mon, Mar 10, 2014 at 1:02 AM, Vernon Burt 
> > 
> wrote: 
> > I suppose that's my confusion - before this, each application directory 
> had 
> > it's own /static/ directory with /css/, /js/ and /img/ directories as 
> > needed. I adjusted the settings as mentioned and tried the following: 
>
> Yes - that is how it should be, apart from for project static files, 
> if you have any of those. You do not move the static files out of the 
> applications. 
>
> > 
> > DEBUG = False 
> > PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) 
> > STATIC_ROOT = os.path.join(PROJECT_PATH, 'static') 
> > STATIC_URL = '/static/' 
> > STATICFILES_DIRS = ( os.path.join(PROJECT_PATH, 'static'),) 
>
> So, a slight problem here. STATIC_ROOT and STATICFILES_DIRS should be 
> different. 
>
> STATICFILES_DIRS is a list of _additional_ directories that are copied 
> to STATIC_ROOT when you run collectstatic. This is where you list your 
> project static file directories, if you have any. You do not _need_ to 
> have any project static files, if all your static files are in 
> my_app/static, then you do not need to put anything in 
> STATICFILES_DIRS. 
>
> STATIC_ROOT is where files are collected to, IE it should be an empty 
> folder, it should not be the origin of your static files, it is where 
> your static files are copied to so that they can be efficiently 
> delivered to your users. 
>
> > 
> > 
> > CollectStatic now works properly - it collects everything into the 
> project 
> > root under static. File linking isn't though - the links dont work, and 
> so 
> > none of the css or javascript loads. I'm wondering if I'm misusing the 
> css 
> > tags I'm testing with. An example from my base template: 
> > 
> > {% load static %} 
> >  
> > 
> > Thank you for your time, 
> > 
>
> Have you configured apache or nginx (or whatever you use) to serve the 
> directory STATIC_ROOT at the url STATIC_URL? 
>
> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2df88053-dbf3-4517-9c94-33514942448e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django cannot find my templates directory

2014-03-10 Thread Cherrymae Tulfo
hi everyone!

i am looking for solutions with regards to templates directory . . i have 
this results.html where the data should be displayed after it is queried 
through views.py. . it should display the barangay id and the name of the 
barangay itself. . 


*{% block content %}
{% if results %}
  {% for result in results %}
{{ result.id }}
{{ result.barangay }}
  {% endfor %}
{% else %}
Please enter a valid UID

  Search Barangay: 
  

{% endif %}

{% endblock %}*

i have also views.py that queries data from the postgresql

*from django.template import RequestContext
def search(request):

query = request.GET.get('q')
try:
query = int(query)
except ValueError:
query = None
results = None
if query:

results = Butuan_Parcel.objects.get(id=query)

context = RequestContext(request)

return render('results.html', {"results": results}, 
context_instance=context)*


i want also to know what am i missing with this. .urls.py

*(r'search', search)*


when I search id in my index.html , the system can retrieve the data but it 
gives me an error 
TemplateDoesNotExist at /search/. . what am I missing?? 
it was also suggested to to declare my template directories 
so i declared this in my settings.py



*PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))TEMPLATE_DIRS = 
(PROJECT_PATH+'/Apps/templates'*)

yet, nothing has worked . .i still get the error. . can anyone suggest 
solutions with my problem?? Thanks in advance. .

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6a0bc697-05bc-4952-9cd1-705422b9bbba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Ticket #7231, join in extra for querysets ?

2014-03-10 Thread Russell Keith-Magee
On Tue, Mar 11, 2014 at 2:14 AM, Matthieu Rigal
wrote:

> Hi guys,
>
> I wanted to talk about the ticket
> https://code.djangoproject.com/ticket/7231 in the django-dev forum, but
> my contribution was just deleted, so I'm posting it here to at least get a
> chance for a discussion.
>

This statement is a little concerning. We're not in the habit of deleting
contributions to django-dev, and we certainly don't censor posts that we
don't like (which is what it sounds like we're being accused of). What are
you basing your assertion on?

Is it just that you posted a message, and it didn't appear in the forum? If
that's the case, I should let you know that the group is set to "moderate
first post" - so your first post to django-dev may take a few hours to get
posted to everyone else. This is done as a spam prevention measure.


> One argument of the core devs in the ticket is that extra is a bad thing
> to have, only there because it was there before raw() came. I think that
> this is wrong, for example when you want to have all the power of the
> filters and the sortings but still be able to make complex queries that the
> ORM can't handle in a decent time.
>
> And I think that the ability to add join to extra would be a great plus.
> For example in the admin, you may want to display the number of foreign
> keys for each row, and eventually, two different counts. Two counts as
> annotate returns wrong results, where as the possibility to add something
> like the following resolves the problem and reduces dramatically the query
> time (by factor 120 in my case).
>
> LEFT OUTER JOIN (SELECT COUNT(*) AS "devices_count",
> "accounts_venuedevice"."venue_id" FROM "accounts_venuedevice" WHERE
> "accounts_venuedevice"."enabled"=true GROUP BY
> "accounts_venuedevice"."venue_id" ) AS "enabled_devices" ON (
> "accounts_venue"."id" = "enabled_devices"."venue_id")
>
> On the other hand, having to add the filters and the sorting by hand to
> the RawQuerySet is a pain in the ass.
>
> Even if extra joins shouldn't be used for production code, it could be
> very helpful for some edge-cases like for the admin interface.
>

The short answer to this -- if you think this is easy, go ahead and produce
a patch. There's a reason we haven't done this.

The longer answer:

The core team's position on extra() doesn't exist because we've got some
sort of theoretical purity that we want to maintain. It's come as a result
of *many* years wrestling with a concept that, at it's core, is badly
formed. extra() has been the cause of more headaches and sleepless nights
on my part than I care to count. If I could kill it with fire, I would.

As I indicated in a different thread about Marc Tamlyn's Kickstarter
project -- Django's ORM is very deliberately *not* a SQL generation engine.
When  we talk about aggregates, we don't talk about "GROUP BY" clauses - we
are expressing the idea of building an average/sum/etc over a group of
objects. When we talk about related objects, we talk about filtering
related object, not the construction of JOIN clauses.

This is a deliberate decision. Django's ORM is designed to make 90% of
common SQL queries easy to generate. It also had the original idea that it
should be possible to express *non* SQL queries as well - although this
hasn't actually manifested in practice.

Django's ORM *does not* have "join", "group by", "having" or other
SQL-specific API endpoints -- and it won't gain them without a *massive*
shift occurring in the fundamental design of the ORM.

I'm not saying that JOIN etc clauses aren't useful - I'm saying it's a
deliberate design decision of Django's ORM to *not* support that use case.

If you're looking at a problem, and thinking "I need a LEFT OUTER JOIN",
then the answer to your problem is raw SQL, not to introduce SQL concepts
into Django's ORM. Alternatively, use an ORM that *does* give first-class
representation of SQL concepts, like SQLAlchemy.

Yours,
Russ Magee %-)

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


Re: Gunicor + Postgres + Python 3

2014-03-10 Thread Henrique Oliveira
The request do not reach the view

On Monday, March 10, 2014 1:14:18 AM UTC-3, Henrique Oliveira wrote:
>
> Hi there,
>
> I have set Django + gunicorn + python 3 in a production env, but I am 
> gettin critical timeout on simple request(home).
> Any Ideas?
>
> 14-03-09 23:11:21 [14029] [INFO] Listening at: http://127.0.0.1:8001(14029)
> 2014-03-09 23:11:21 [14029] [INFO] Using worker: sync
> 2014-03-09 23:11:21 [14039] [INFO] Booting worker with pid: 14039
> 2014-03-09 23:11:21 [14040] [INFO] Booting worker with pid: 14040
> 2014-03-09 23:11:21 [14041] [INFO] Booting worker with pid: 14041
> 2014-03-09 23:11:31 [14040] [DEBUG] GET /done
> 2014-03-09 23:12:02 [14029] [CRITICAL] WORKER TIMEOUT (pid:14040)
> 2014-03-09 23:12:02 [14029] [CRITICAL] WORKER TIMEOUT (pid:14040)
>
> Cheers
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a2270155-a256-4040-88b9-9df9afcf86b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Supporting a wider range of awesome PostgreSQL features in Django - including hstore, JSON and full text search

2014-03-10 Thread Russell Keith-Magee
On Mon, Mar 10, 2014 at 7:22 PM, Matthieu Rigal
wrote:

> Is it somehow planned that Django Users can dialog with him to express
> some desires ?
>
> For example, I would be very happy to see a reimplementation of the
> annotate and aggregate functions, as they make the queries so slow by
> grouping by all the fields that I always have to use raw SQL to group only
> by id.
>
> In one case in my admin, it is trying to group by 40 fields (I have 5
> foreign keys and more than 20 fields) instead of 4 IDs and it requires 6
> seconds instead of 160 ms...
>

Again, I can't speak for Marc; once the Kickstarter has finalised, I'm sure
he'll be in contact with backers to describe the process he'll take. I'd be
guessing it's either going to be through his blog, or through
django-developers (and possibly both, depending on the level of interaction
you're looking for).

That said, the issue you describe sounds like it's outside the scope of
what he's looking at. The annotate query you describe may be sub-optimal,
but it does *work*. Marc's project is looking at adding the features that
PostgreSQL has, but aren't currently accessible using Django's core feature
set. This means new field types, new index types, and so on. This is all
possible by making a concerted effort to use the features Django already
provides, like custom fields and custom lookups.

What you've described is a specific SQL query optimization that presumably
would have applicability across multiple database backends. If you've got a
proposal for what this would look like at an API level, feel free to
propose it. However, keep in mind that Django's ORM is very deliberately
*not* a SQL generation engine. There are very few "SQL" concepts at the API
level, and discussing "grouping" clauses is very much in that space. You
may find that the answer to your question is "use raw SQL".

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJxq84_hkv9AAXg-b%2BC1usw-6F%3DW22SkfasMyv4jH9Se%2BwAu7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: FieldError with ManyToMany relationship in ModelAdmin list_display item when server is not in DEBUG mode

2014-03-10 Thread Andrew Niccolo Pangilinan
Hi,
Have you had any solutions to this yet?

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


Ticket #7231, join in extra for querysets ?

2014-03-10 Thread Matthieu Rigal
Hi guys,

I wanted to talk about the 
ticket https://code.djangoproject.com/ticket/7231 in the django-dev forum, 
but my contribution was just deleted, so I'm posting it here to at least 
get a chance for a discussion.

One argument of the core devs in the ticket is that extra is a bad thing to 
have, only there because it was there before raw() came. I think that this 
is wrong, for example when you want to have all the power of the filters 
and the sortings but still be able to make complex queries that the ORM 
can't handle in a decent time.

And I think that the ability to add join to extra would be a great plus. 
For example in the admin, you may want to display the number of foreign 
keys for each row, and eventually, two different counts. Two counts as 
annotate returns wrong results, where as the possibility to add something 
like the following resolves the problem and reduces dramatically the query 
time (by factor 120 in my case).

LEFT OUTER JOIN (SELECT COUNT(*) AS "devices_count", 
"accounts_venuedevice"."venue_id" FROM "accounts_venuedevice" WHERE 
"accounts_venuedevice"."enabled"=true GROUP BY 
"accounts_venuedevice"."venue_id" ) AS "enabled_devices" ON ( 
"accounts_venue"."id" = "enabled_devices"."venue_id") 

On the other hand, having to add the filters and the sorting by hand to the 
RawQuerySet is a pain in the ass.

Even if extra joins shouldn't be used for production code, it could be very 
helpful for some edge-cases like for the admin interface.

Best,
Matthieu

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f15e3c9a-6810-44fb-928d-75f31fc4f87f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ".count" in template does not work for "raw" queries

2014-03-10 Thread C. Kirby
The reason .count() doesn't work there is because count() runs a select 
count(*) query, but that can't run correctly with .raw().
The way to get the count is to cast the Resulting RawQuerySet to a list and 
run len() on it. This will result in the RawQuerySet getting evaluated 
however. 

Alternatively, you could run the query twice using a django.db.connection 
object to run 'select count(*) from table s where s.col3 = to_char(%s)', 
[xxx] to get the count.

http://stackoverflow.com/questions/3037273/get-number-of-results-from-djangos-raw-query-function
http://stackoverflow.com/questions/2317452/django-count-rawqueryset

On Monday, March 10, 2014 6:21:27 AM UTC-5, bikeridercz wrote:
>
> Dear colleagues,
>
> please help, it seem that count method used in template does not work for 
> collections of records populated in views via direct "raw" query.
>
> *Example in view:*
>
> recordset = ASSETS.objects.raw('select s.col1, s.col2 from table s where 
> s.col3 = to_char(%s)', [xxx])
>
>
> *Example in template:*
>
> {% with total=recordset.count %}
>
> {{ total|default:"0" }} record{{ total|pluralize }} 
> found
>
> {% endwith %}
>
>  
> Select returns approx. 20 rows, they are successfully populated into 
> "recordset", they are iterable, can be accessed and displayed with no 
> problem.
>
> However "recordset.count" returns nothing.
>
> In case that the recordset is populated in standard way through 
> ASSETS.object.filter, the "count" method works fine. Unfortunately, 
> "objets.filter" can not be used in this case.
>
> Thanks for help.
>
>
>

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


Re: DDT not showing

2014-03-10 Thread ajohnston

Make sure you include your client/browser IP address in the INTERNAL_IPS 
setting (settings.py) something like this:

INTERNAL_IPS = ('127.0.0.1','192.168.1.112')



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0116975b-627a-4769-95ae-2350e35284ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trying to set up hashed versioning in Django for static files

2014-03-10 Thread Tom Evans
On Mon, Mar 10, 2014 at 1:02 AM, Vernon Burt  wrote:
> I suppose that's my confusion - before this, each application directory had
> it's own /static/ directory with /css/, /js/ and /img/ directories as
> needed. I adjusted the settings as mentioned and tried the following:

Yes - that is how it should be, apart from for project static files,
if you have any of those. You do not move the static files out of the
applications.

>
> DEBUG = False
> PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
> STATIC_ROOT = os.path.join(PROJECT_PATH, 'static')
> STATIC_URL = '/static/'
> STATICFILES_DIRS = ( os.path.join(PROJECT_PATH, 'static'),)

So, a slight problem here. STATIC_ROOT and STATICFILES_DIRS should be different.

STATICFILES_DIRS is a list of _additional_ directories that are copied
to STATIC_ROOT when you run collectstatic. This is where you list your
project static file directories, if you have any. You do not _need_ to
have any project static files, if all your static files are in
my_app/static, then you do not need to put anything in
STATICFILES_DIRS.

STATIC_ROOT is where files are collected to, IE it should be an empty
folder, it should not be the origin of your static files, it is where
your static files are copied to so that they can be efficiently
delivered to your users.

>
>
> CollectStatic now works properly - it collects everything into the project
> root under static. File linking isn't though - the links dont work, and so
> none of the css or javascript loads. I'm wondering if I'm misusing the css
> tags I'm testing with. An example from my base template:
>
> {% load static %}
> 
>
> Thank you for your time,
>

Have you configured apache or nginx (or whatever you use) to serve the
directory STATIC_ROOT at the url STATIC_URL?

Cheers

Tom

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


Re: Gunicor + Postgres + Python 3

2014-03-10 Thread Henrique Oliveira
Hi Nick,

views.py

class LaunchRockForm(ModelForm):
class Meta:
model = LaunchRock
exclude = ['sign_date', 'ip', 'http_refer']

def clean_email(self):
try:
LaunchRock.objects.get(email=self.cleaned_data['email'])
except LaunchRock.DoesNotExist:
return self.cleaned_data['email']
raise forms.ValidationError(_("This is email is already in 
database."))


def signup(request):
if request.method == 'POST':
form = LaunchRockForm(data=request.POST)
if form.is_valid():
launch = 
LaunchRock.objects.create(email=form.cleaned_data['email'], 
sign_date=datetime.datetime.now(),
   
ip=request.META['REMOTE_ADDR'], http_refer=request.META['HTTP_REFERER'])
return HttpResponseRedirect("/done/")
else:
form = LaunchRockForm()
return render_to_response('launch.html', {'form': form}, 
context_instance=RequestContext(request))


def done(request):
return render_to_response('done.html')


models.py

class LaunchRock(models.Model):
email = models.EmailField()
sign_date = models.DateTimeField(default=datetime.datetime.now)
ip = models.IPAddressField()
http_refer = models.TextField(blank=True, null=True)

class Meta:
db_table = 'launch'

def __unicode__(self):
return self.email


On Monday, March 10, 2014 2:01:13 AM UTC-3, Nick Santos wrote:
>
> Hey Henrique,
>
> Can you send the code for the view that generates the page?
>
> -Nick 
>  
>
> On Sun, Mar 9, 2014 at 9:14 PM, Henrique Oliveira 
> 
> > wrote:
>
>> Hi there,
>>
>> I have set Django + gunicorn + python 3 in a production env, but I am 
>> gettin critical timeout on simple request(home).
>> Any Ideas?
>>
>> 14-03-09 23:11:21 [14029] [INFO] Listening at: http://127.0.0.1:8001(14029)
>> 2014-03-09 23:11:21 [14029] [INFO] Using worker: sync
>> 2014-03-09 23:11:21 [14039] [INFO] Booting worker with pid: 14039
>> 2014-03-09 23:11:21 [14040] [INFO] Booting worker with pid: 14040
>> 2014-03-09 23:11:21 [14041] [INFO] Booting worker with pid: 14041
>> 2014-03-09 23:11:31 [14040] [DEBUG] GET /done
>> 2014-03-09 23:12:02 [14029] [CRITICAL] WORKER TIMEOUT (pid:14040)
>> 2014-03-09 23:12:02 [14029] [CRITICAL] WORKER TIMEOUT (pid:14040)
>>
>> Cheers
>>  
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@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/641f550d-4e8b-4a36-b76f-93d8100f3500%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


django-quiz modification

2014-03-10 Thread orchid barua
I want to modify the django-quiz 
application.https://github.com/tomwalker/django_quiz

The quesiton will be a multiple true false type. Each question will have 5 
stem, each will be tested for true/false. Each will carry partial marks eg. 
1 will be awarded for a correct ans. And there will be a system for penalty 
eg. deduct 0.5 marks for a wrong answer of a stem. 

I am modifying the model like this:

*Question model:*
class Question(models.Model):

quiz = models.ManyToManyField(Quiz, blank=True, )

category = models.ForeignKey(Category, blank=True, null=True, )

content = models.CharField(max_length=1000, 
   blank=False, 
   help_text="Enter the question text that you 
want displayed",
   verbose_name='Question',
   )

explanation = models.TextField(max_length=2000,
   blank=True,
   help_text="Explanation to be shown after 
the question has been answered.",
   verbose_name='Explanation',
   )


class Answer(models.Model):
question = models.ForeignKey(Question)

content = models.CharField(max_length=1000, 
   blank=False, 
   help_text="Enter the answer text that you 
want displayed",
   )

correct = models.BooleanField(blank=False, 
  default=False,
  help_text="Is this a correct answer?"
  )
incorrect = models.BooleanField(blank = False, default =False, 
help_text = "is this incorrect ?")

The original quiz model is here:
https://github.com/tomwalker/django_quiz/blob/master/quiz/models.py

How can I modify the view and models to achieve my functionality? Can you 
please atleast suggest an algorithm for the process?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/923ba439-5f98-4788-8b29-71559380db3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Regarding Django job market here in Perth

2014-03-10 Thread Robbie Nolan
Hi Calvin,

I hope you are well.

Are you still looking for work?
Some of the companies I work with are definitely keeping an eye out for 
talented Python/Django developers at the moment.

If you'd like to have a confidential chat about your career options you can 
get me on 0415 779 338 or email rob...@beachamaddis.com

Kind regards,

Robbie

On Sunday, 2 February 2014 20:11:23 UTC+8, Calvin Chen wrote:
>
> Hi Guys,
>
> Sorry to be bothersome.
> Do you guys happen to know any local company (based in Perth) that 
> actually uses Python/Django technology? I have visited all of the major job 
> websites and a few other Django-specific job websites like djangojobs.netand 
> djangogigs.com. But I only find one or two companies that hires 
> Python/Django programmers.
>
> Any advice would be appreciated.
>
> BTW, is it appropriate to ask job-related question in the Users Group? 
>

-- 
*Notice:*  Information contained in this email may be confidential. If you 
receive this email in error, please immediately notify the sender and 
delete it from your system. Please do not disclose, copy or rely on any 
part of this email if you are not the intended recipient.  Any views 
expressed in this email are those of the individual sender, except where 
the sender specifically states them to be the views of Beacham Addis.  
While we believe the information contained herein is correct, no warranty 
or guarantee of accuracy, reliability, completeness or of the communication 
being free of errors, viruses or interference is given and, except for 
liability under statute which cannot be excluded, no liability for errors 
or omissions is accepted.
--

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


".count" in template does not work for "raw" queries

2014-03-10 Thread bikeridercz
Dear colleagues,

please help, it seem that count method used in template does not work for 
collections of records populated in views via direct "raw" query.

*Example in view:*

recordset = ASSETS.objects.raw('select s.col1, s.col2 from table s where 
s.col3 = to_char(%s)', [xxx])


*Example in template:*

{% with total=recordset.count %}

{{ total|default:"0" }} record{{ total|pluralize }} 
found

{% endwith %}

 
Select returns approx. 20 rows, they are successfully populated into 
"recordset", they are iterable, can be accessed and displayed with no 
problem.

However "recordset.count" returns nothing.

In case that the recordset is populated in standard way through 
ASSETS.object.filter, the "count" method works fine. Unfortunately, 
"objets.filter" can not be used in this case.

Thanks for help.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e9f583aa-0cde-443c-88b4-b381cbf67d69%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Supporting a wider range of awesome PostgreSQL features in Django - including hstore, JSON and full text search

2014-03-10 Thread Matthieu Rigal
Is it somehow planned that Django Users can dialog with him to express some 
desires ?

For example, I would be very happy to see a reimplementation of the 
annotate and aggregate functions, as they make the queries so slow by 
grouping by all the fields that I always have to use raw SQL to group only 
by id.

In one case in my admin, it is trying to group by 40 fields (I have 5 
foreign keys and more than 20 fields) instead of 4 IDs and it requires 6 
seconds instead of 160 ms...

All the best to Marc

On Monday, February 24, 2014 2:59:28 AM UTC+1, Russell Keith-Magee wrote:
>
>
> On Sun, Feb 23, 2014 at 10:45 PM, Federico Capoano 
> 
> > wrote:
>
>> I found this on django's blog:
>>
>>
>> https://www.kickstarter.com/projects/mjtamlyn/improved-postgresql-support-in-django
>>
>> Very interesting!
>>
>> Anybody knows if they intend to redevelop everything from scratch or 
>> reuse and improve existing implementations?
>>
>>
> Marc will be the ultimate authority on this, but from my conversations 
> with him, I believe that his intention is to:
>
>  * use existing implementations where possible, 
>  * merge the best parts of existing implementations where multiple options 
> exist, 
>  * rebuild implementations that need significant improvement, and 
>  * build from scratch where no existing solutions exist.
>
> Yours,
> Russ Magee %-)
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/58ed5785-e424-42f2-b560-0692ce66fc43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.