Re: I have created an app (total noob question)

2014-08-31 Thread Matt Gushee
Hi, Michael--

On Sun, Aug 31, 2014 at 10:28 PM, Michael Carey  wrote:
> That is assuming that you just upload the files?

Your doubt is justified. Just uploading the files is a bit of an
oversimplification. It would help if you gave some specifics about the
directory structure you're working with.

However, I can make a few general recommendations ...

1. Are you using version control? If not, you should - and it solves
part of your problem. I know it may seem like overkill to go through
all the steps of setting up a repo for just a little app, but if you
are at all serious about this Django development thing it will save
you a lot of work in the long run. I think these days Git is the most
popular version control system, but Mercurial (AKA hg) and Bazaar (AKA
bzr) are also very good (and both programmed in Python, yay!).

There is a good, concise tutorial online about setting up a Django
project to work with Git. I don't have a link for it, but I found it
very easily by Googling something like "Django version control."

So, assuming you have shell access (e.g., can log in via SSH) on your
web server, you would follow a procedure like this:

  git push
DEV MACHINE   -->   GIT REPOSITORY

  git pull
SERVER <--GIT REPOSITORY

That's *very* simplified. In reality, if you are trying to do
professional development, you need to at least have a test environment
online, so that you always test the code in conditions that are as
nearly identical as possible to your production server. But the above
will do if you're just experimenting. And if you don't have shell
access, someone else will have to help you with that.

Now, what files do you put under version control?

Let's say you follow the typical advice, and have a virtual
environment, with any Django projects/sites in separate directories.
For example, I'm using a setup like this (on Linux):

/srv/http/salixmedia.com/test/
pyenv/
 [virtual environment with Django and other
required libraries]
my_site/
 admin.py
 settings.py
 local_settings.py
 models.py
 wsgi.py
 
my_app/
 admin.py
 models.py
 views.py
 

In this setup, all of 'my_app' would go under version control.
Likewise, all of 'my_site' *except* for local_settings.py - or
whichever file contains your secret keys and database password. You
need to guard that information closely, so it should never go into
version control.

Some people think you should put the virtual env (my 'pyenv'
directory) under version control too; I say no. You do want to ensure
that you have all the same libraries installed everywhere, but there's
another way to do that:

  $ pip freeze  > requirements.txt  # on development box

  $ pip install -r requirements.txt   # on server

The requirements file lists all your installed packages, including
their versions. 'requirements.txt' should be under version control, so
you will have it on your server when you check out the code there. I'm
sure this approach is not totally foolproof, but I believe it is
fairly reliable, and will save you from cluttering your repo with a
great deal of third-party code that you will probably never modify.

Okay, so that takes care of all your python code and config files. You
also have to deal with your database. And honestly, I'm pretty new at
Django myself, and haven't completed figured out this aspect. When you
are setting up a site, you need to use commands such as

 python manage.py syncdb

and

 python manage.py migrate 

If you're not familiar with those, I'd suggest you go through the
online documentation. These commands take care of your schemas (to
oversimplify, those represent your models in the database), but they
don't, by default, handle any site content that you may have created.
That's the part I'm not too sure about, but I'm sure others on this
list will have good advice.

Hope that helps a bit.

--
Matt Gushee

-- 
You received this message because you are subscribed to the Google 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/CABrD0eeQoqMcMAiqmmyMgwxMbvZ01rj%2BC%2BkAzepjX%3D8EYDMZxg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: I have created an app (total noob question)

2014-08-31 Thread Kamal Kaur
On Mon, Sep 1, 2014 at 9:56 AM, Michael Carey  wrote:
> ). I cannot work out which files to upload to my website to veiw the page?


Do you mean to deploy on production server?

-- 
Kamaljeet Kaur

-- 
You received this message because you are subscribed to the Google 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/CAP8Q%2BxgNESQMtSGzvPxsbVFFc%3Dgx4AfudDxUs3QWTB7FuPf2_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: I have created an app (total noob question)

2014-08-31 Thread Michael Carey
That is assuming that you just upload the files?

On Monday, 1 September 2014 14:26:07 UTC+10, Michael Carey wrote:
>
> I have created an app, and it works on the test server (port 8000). I 
> cannot work out which files to upload to my website to veiw the page?
>
> Thank you,
>
> Michael Carey
>

-- 
You received this message because you are subscribed to the Google 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/ce1f1efb-5cfd-42e9-94fa-25628b30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


I have created an app (total noob question)

2014-08-31 Thread Michael Carey
I have created an app, and it works on the test server (port 8000). I 
cannot work out which files to upload to my website to veiw the page?

Thank you,

Michael Carey

-- 
You received this message because you are subscribed to the Google 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/9639cab8-49e3-414c-a8a9-714940ff7628%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How create a custom permission for a model?

2014-08-31 Thread YusufSalahAdDin
Hi, how are you?

I have the next question:

Good Nights, this is a question, not a issue.

I need have to user's types: a default admin in django, and a author.
Default admin have a aditional permission: can publish a news.
And for author user i have the next constrains:

   - Can't publish news.
  - Can't create other users
  - Can't create other topics or subtopics
  - Can create a new, but, only can edit or delete his own news, no 
  other user's news.
   
I talked with other friend and he say me that i need per-objetcs 
permissions, but, i don't know how do this.

Can you help me?


Now i'm ussing django-permission, but i don't know how do a custom 
can_publish permission.


I wan't cread a custom view, no, i want used django's admin, news model 
have a boolean field, is_published, i want that if the user is Author, can 
modify this field, and if is admin, can modify this field, can anyone 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/06752534-dd11-4422-a0cb-25cc81ca077c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I create models which only required during tests in Django 1.7c1?

2014-08-31 Thread Alisue Lambda
> Alex
Well as Yo-Yo Ma said, sometime the tests stand for testing django's inner 
working thus the real models are required.

> Yo-Yo Ma
I haven't tried but thanks for the solution :-)


On Wednesday, July 16, 2014 11:17:56 PM UTC+9, Alisue Lambda wrote:
>
> Hi all. 
>
> Well today I tried Django 1.7c1 with my program and found that the 
> previous testing strategy seems not work.
>
> I have several models which only required during tests. Before Django 1.7, 
> I could create these kind of temporary models by defining these in 
> `app/tests/models.py` with `app_label` specification like this (
> https://github.com/lambdalisue/django-permission/blob/master/src/permission/tests/models.py).
>  
> It was quite good strategy for me because I could reduce the dependency of 
> the apps and make the app independent.
>
> But now, it seems Django 1.7c1 cannot find this kind of definitions. I 
> have to add `app.tests` in `INSTALLED_APPS` which was not required before 
> Django 1.7c1.
> However, if I add `app.tests` and `app2.tests`, I have to modify `label` 
> of the `app2.tests` because there is already `app_label='tests'` in the 
> registry. It is quite tough job while I have a lot of apps which follow 
> this strategy to test the app.
> Additionally, I don't really want to list `app.tests` in my 
> `INSTALLED_APPS` while it is not actually app which required for the site.
>
> So I wonder if there are any better way to define the temporary models. In 
> summary, what I want to do is
>
> 1. I want to add temporary models which only required during tests
> 2. I don't want to mess the db with temporary models (except during tests)
>
> Any idea? Thank you for your cooperation.
>
>
> Best regard,
>
>

-- 
You received this message because you are subscribed to the Google 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/c4ee6dc3-79c5-4222-8309-662aefc1d354%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to make a widget with no history?

2014-08-31 Thread Yarick Antonov
For example this widget: http://i.imgur.com/ExaZt8l.png

And as you can see there are the history of previous inputs.

And i need to get rid of that.

Meaning: i don't want any history of previous inputs to be displayed.

-- 
You received this message because you are subscribed to the Google 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/1a38b0d7-2201-4d07-a2dc-ef64cef924b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: response to ajax (jquery) with variables

2014-08-31 Thread Antonio Russoniello

Thank you Andreas ... I got it !!!

AR

El 30/08/2014 05:04 a.m., Andreas Kuhne escribió:

Hi again Antonio,

First of all, make sure you are using a good browser with debugging 
capabilities (I prefer Chrome), because you'll need it.


Secondly, I usually use the $.ajax request, instead of the post. 
Mainly because post is a wrapper around ajax and you can more finely 
change the settings of ajax.


So the post in your case would be:

$.ajax({
type: 'POST',   // Make sure you post
dataType: 'json',  // Use this so that you request json 
from the server

url: "/sitioweb/json/",
data: data,
success: function(data) {
// The data that is returned is your json data, already 
parser, so you don't have to parse it!
alert(data.array[0]); // Need to write "array" because 
that is what you are sending to the browser (your structure looks like 
that, check what the server is responding with)

},
error: function(xhr, textStatus, errorThrown) {
console.log('AJAX communication failed:', textStatus, 
errorThrown);// In case there is an error (for example a 500)

}
});

Regards,

Andréas

2014-08-30 4:57 GMT+02:00 Antonio Russoniello 
>:


Now I can read data from  ajax to my def but I have not idea to
how send, for examle, an array to jquery and manage this from
javascript...

I tried:

def json_prueba(request):
arrg = [1,2,3,4]
if request.method == 'POST':
return HttpResponse(simplejson.dumps({'array': arrg}),
content_type="application/json")
return HttpResponse('FAIL!')

from the page side:

function updateDB(){
$.post("/sitioweb/json/", data, function(response){
if(response){
var data = JSON.parse(*response*); <- NOT
SURE IF THIS IS CORRECT
alert(data[0]); }  <- I´m trying
to put on an alert windows the first item of my array arrg
else{ alert('Error! :(');}
});
}

Thanks in advande.

AR


El 28/08/2014 02:57 a.m., Andreas Kuhne escribió:

Hi Antonio,

import simplejson as json

return HttpResponse(
json.dumps({
'array': example
}),
content_type="application/json"
)

That would do the trick. This is returned as JSON. Remember to
set the content_type, otherwise the client can get confused.

Regards,

Andréas

2014-08-28 2:56 GMT+02:00 Antonio Russoniello
>:

Hello,

i hope you can help me with this, I'm trying to send to an
ajax (jquery from my html template) a response but i would
like to send also a new variable.

in my html template I have:

$("#init_date").click(function(){
var some_date = {'init_date': init_date, 'end_date':
end_date};
$.post("/filter_dates/", some_date, function(response){
if(response === 'success'){
/MAKE SOMETHING//!!!/
else{ alert('error'); }
});
});

my django view look like:

def filter_date(request):
if request.method == 'POST':
example = ['A','B','C']
init_date = request.POST['init_date']
end_date = request.POST['end_date']
 MAKE SOMETHING!!
return HttpResponse('success') /AND HERE I WOULD LIKE
TO SEND THE example ARRAY.../
else:
return HttpResponse('error')

How can I send the array o some other variable as response?

Regards,
AR
-- 
You received this message because you are subscribed to the

Google 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/53FE7E44.4020104%40musicparticles.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

Re: how to get a list of all installed applications

2014-08-31 Thread Cj Welborn
On Saturday, August 30, 2014 6:02:57 PM UTC-5, Collin Anderson wrote:
>
> The soon-to-be-released version 1.7 has a documented API for accessing all 
> models and apps:
>
> https://docs.djangoproject.com/en/1.7/ref/applications/
>

That's awesome, I'll be on the lookout for it. 

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


Re: Guidance needed - Real time and django

2014-08-31 Thread Amirouche Boubekki
Hello,


2014-08-29 17:26 GMT+02:00 Aamu Padi :

> Hello,
> I would like to build a real time web application, but have little idea of
> where to start to from. It will have notification and feed system like
> facebook or instagram. Would really appreciate if anyone who have already
> done this type of web application could kindly guide me through. I will be
> very grateful.
>

I never done such things besides small experiments and research...

Here are some pointers:

- search://django+gevent
- search://django+asyncio among other things django-c10k-demo
 created by Aymeric Augustin
django core contributor which use websockets
- search://tornado
- search://django+SSE
- search://django+webRTC
- search://django+pjax

HTH,

Amirouche

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

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