Re: How do I move a project from one computer to another?

2018-02-12 Thread Mike Dewhirst

On 13/02/2018 11:09 AM, Tom Tanner wrote:
I have a Django project that I want to work on with another computer. 
Do I need to backup my current project's Postgres database and restore 
it on the other computer's Postgres database to get my project up and 
running there? Or is there a Django way to do this?


There are at least two simple ways to do this. Both need a repo to keep 
your source code and requirements file (eg freeze.txt) in sync between 
your machines. Both need to run pip -r freeze.txt each time it changes.


1. Dump the "master" database into a text file, copy it to the "slave" 
machine and load it there. Obviously you can do this in both directions. 
You can use bash scripts or Windows batch files. Risk of human error in 
overwriting the wrong database is a constant possibility.


2. Establish your current Postgres as a more widely accessible server 
which can be seen from the slave machine. A bonus here is that 
migrations can be done from either machine and the database can never 
get out of sync. Every database dump is a backup if you include a date 
in the filename. And it can be dumped from either machine.


In both cases you will need to manage database credentials using 
identical source code in your settings. This is because after you merge 
your source from machine to machine in either direction the Django 
settings need to see the database. But that's a separate question.


hth

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b5ab2022-4fd1-4f8f-bb40-d4194bbf397f%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3054a69b-214a-c522-7e12-051e35d89e0d%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: How do I move a project from one computer to another?

2018-02-12 Thread Ramez Kabbani
You should  be using some kind of git system. Push your code to the repo 
and pull it on the new machine. There should be no really concern switching 
machines.
If your current DB has data that you need, export them and then import. 

You need to know how to do this for production code, so you might as well 
learn now. 

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4ba37cd6-eead-468f-9e90-b2cc42a03c88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I move a project from one computer to another?

2018-02-12 Thread sum abiut
It depends on where you want to house your app.if you need to house your
app on the new machine. Just pip install from your requirements.txt file,
then copy your django project to your new machine.

On 13/02/2018 11:10 AM, "Tom Tanner"  wrote:

> I have a Django project that I want to work on with another computer. Do I
> need to backup my current project's Postgres database and restore it on the
> other computer's Postgres database to get my project up and running there?
> Or is there a Django way to do this?
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/b5ab2022-4fd1-4f8f-bb40-d4194bbf397f%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y4zUGDgXEbj62x0mJcHxM1P7r-%3DjX3PgG%2B%3D0C4mb__Jnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I move a project from one computer to another?

2018-02-12 Thread Etienne Robillard

Hi,

you can use rsync for your project's source code.

Etienne


Le 2018-02-12 à 19:09, Tom Tanner a écrit :
I have a Django project that I want to work on with another computer. 
Do I need to backup my current project's Postgres database and restore 
it on the other computer's Postgres database to get my project up and 
running there? Or is there a Django way to do this?

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b5ab2022-4fd1-4f8f-bb40-d4194bbf397f%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c050701e-c4ac-d9e7-2931-a3d11540f144%40yandex.com.
For more options, visit https://groups.google.com/d/optout.


How do I move a project from one computer to another?

2018-02-12 Thread Tom Tanner
I have a Django project that I want to work on with another computer. Do I 
need to backup my current project's Postgres database and restore it on the 
other computer's Postgres database to get my project up and running there? 
Or is there a Django way to do this?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b5ab2022-4fd1-4f8f-bb40-d4194bbf397f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Saving Json data from javascript

2018-02-12 Thread Shazia Nusrat
Hi,

Below is the code for Javascript from Django template Google Maps API. I
need to be able to save this in my Django models with JSON response. I am
new user so an example will be really a great help.

Precisely I need to be able to save coordinates like latitude and longitude
and then convert it to an address.

Thanks

var map, infoWindow;
  function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
  center: {lat: -34.397, lng: 150.644},
  zoom: 6
});
infoWindow = new google.maps.InfoWindow;

// Try HTML5 geolocation.
if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
  lat: position.coords.latitude,
  lng: position.coords.longitude
};

infoWindow.setPosition(pos);
infoWindow.setContent('Location found.');
infoWindow.open(map);
map.setCenter(pos);
  }, function() {
handleLocationError(true, infoWindow, map.getCenter());
  });
} else {
  // Browser doesn't support Geolocation
  handleLocationError(false, infoWindow, map.getCenter());
}
  }

  function handleLocationError(browserHasGeolocation, infoWindow, pos) {
infoWindow.setPosition(pos);
infoWindow.setContent(browserHasGeolocation ?
  'Error: The Geolocation service failed.' :
  'Error: Your browser doesn\'t support
geolocation.');
infoWindow.open(map);
  }

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD83tOzabkiPgniqofN6BH2tLogeiGE9JaZ5rppi3f44Hb0ybA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: UUIDs eventually choke as primary key

2018-02-12 Thread Ɐha Hah
Use a storage/caching layer of CUIDs instead? http://usecuid.org/

Aha

On Mon, Feb 12, 2018 at 11:24 AM, M Mackey  wrote:

> I've run into a strange issue with using a UUID as primary key, and I'm
> hoping we can either verify this is a bug, or figure out what I've done
> wrong.
>
> I've got a core model object with a UUID for it's primary key. (Generated
> external to this system, thus using that for when additional information
> comes in.) And there are other model objects referencing it. Normally
> everything runs fine. But after a while, web pages that have been running
> fine start telling me that the UUID isn't valid (even though it is). (Sorry
> I don't have a copy of the error at this moment, I'll post here when it
> happens again.) I know it's not a simple coding error, because I can simply
> restart Apache and everything is fine again. And these aren't POST
> responses or anything complex like that. It occurs on a simple listing page.
>
> When I dig into the exceptions, I see something that seems contradictory.
> It looks like the UUID constructor has been called with an instance of a
> UUID (it says type UUID doesn't have method 'replace'). But it doesn't seem
> like that should be possible because the code that calls that constructor
> first checks the type. (See django/db/models/fields/__init__.py -
> UUIDField.to_python)
> So it's a double head scratcher. Once this problem crops up, I have to
> restart the web server (but then it's okay for a while). And the errors it
> gives me don't make much sense.
> I don't know what kind of caching problem it could be - I haven't enabled
> any of the available caching systems. Also doesn't seem to crop up (at
> least not as often) in the built in dev test server.
>
> Anyone seen this, or have any ideas?
>
> Thanks,
> M
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/d283cde8-76ff-4218-a504-4a92508ae2a2%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPugQBMoQcth2AwK_KiqJ2ZGRC0Ns3Jurx6CXpvxf4Kp4id8Vw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to fetch data from sql server and display on django web pages

2018-02-12 Thread sum abiut
You may want to check out sqlalchemy they provide a pretty good
documentation on what you are aftering
http://docs.sqlalchemy.org/en/latest/dialects/mssql.html

>From you view you can defile a function like so.

view.py

from sqlalchemy import*
from django.shortcuts import render

def connectto_db(request):
engine=create_engine('mssql+pymssql://username:password@servername
/Ddabname')
connection=engine.connect()
metadata=MetaData()


table=Table('tablename',metadata,autoload=True,autoload_with=engine)
stmt='SELECT * FROM table'
results=connection.execute(stmt).fetchall()
return render(request,'template.html',locals())


then  you can pass the results to your template.html

Hope this helps.

Cheers

On Sun, Feb 11, 2018 at 4:37 PM, Amit Kadivar 
wrote:

> Please Help me.
> How to fetch data from sql server and display them on django web pages
> through nginx web server..
>
>
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/b5577524-e67d-465f-bb49-e54bca92c88b%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y5CZ-HAUSbGkTWKe23CfuCMWozoLqL85V52924NpDwd-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Email Notification System

2018-02-12 Thread Ramez Kabbani
I'm trying to build an email notification system, and would appreciate some 
guidance.

Triggers:

   1. New item created & user assigned to instance
   2. Existing item edited & user assigned to instance
   3. Comment added to object where user is involved
   4. Item date field expires & user opts in to this notification type & 
   user part of item's project

My thoughts:

   - I can use the post_save signal to trigger a Celery task that sends the 
   email.
   - I would need to create a decorator to register models to be monitored
   - I could create a separate notification app so I can build a setting 
   interface that exposes criteria like which projects get monitored.
   - For trigger #2 I can create a celery task that runs at, say, 9am 
   everyday and checks all instances for expired date. It would send an email 
   if the condition is True 
   
This is as much as I have figured out. I need to work on implementation 
now, but would like some feedback.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/462762b7-2b44-4c0d-989e-fe3036ae2ec9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


UUIDs eventually choke as primary key

2018-02-12 Thread M Mackey
I've run into a strange issue with using a UUID as primary key, and I'm 
hoping we can either verify this is a bug, or figure out what I've done 
wrong.

I've got a core model object with a UUID for it's primary key. (Generated 
external to this system, thus using that for when additional information 
comes in.) And there are other model objects referencing it. Normally 
everything runs fine. But after a while, web pages that have been running 
fine start telling me that the UUID isn't valid (even though it is). (Sorry 
I don't have a copy of the error at this moment, I'll post here when it 
happens again.) I know it's not a simple coding error, because I can simply 
restart Apache and everything is fine again. And these aren't POST 
responses or anything complex like that. It occurs on a simple listing page.

When I dig into the exceptions, I see something that seems contradictory. 
It looks like the UUID constructor has been called with an instance of a 
UUID (it says type UUID doesn't have method 'replace'). But it doesn't seem 
like that should be possible because the code that calls that constructor 
first checks the type. (See django/db/models/fields/__init__.py - 
UUIDField.to_python)
So it's a double head scratcher. Once this problem crops up, I have to 
restart the web server (but then it's okay for a while). And the errors it 
gives me don't make much sense.
I don't know what kind of caching problem it could be - I haven't enabled 
any of the available caching systems. Also doesn't seem to crop up (at 
least not as often) in the built in dev test server.

Anyone seen this, or have any ideas?

Thanks,
M

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d283cde8-76ff-4218-a504-4a92508ae2a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Basic note/trello app - how to link model object IDs

2018-02-12 Thread Lylio
Hi everyone,

I'm new to Django and currently working on a very simple app. It's 
basically a note app, a bit like a Trello board but aimed at creating 
user-story cards for software development teams (code at 
https://github.com/Lylio/scrumbuddy_project).

I made a mock-up in Photoshop of how it's supposed to look:

  


I've got some basic functionality up and running - users can register and 
create a user-story card. When a new card is created, a title, description, 
time estimation are inputted. Cards are just displayed as list items in 
columns. I'm trying to add a button to the cards so that when it's clicked, 
the details of the card open up in a new and a user can edit the card info 
or delete it. 

A couple of noob questions:

1. To click on a card so it opens up and displays the details, am I right 
to say I should create a card.html file in the templates folder for this? 

2. I'm confused about how Django keeps track of the cards in my app - I 
presume each card object has an ID in the database and I'd need this ID in 
order to retrieve the card's details when it's clicked - but I'm unsure of 
how to link the two. In the two pictures above, say someone clicked on the 
'class progression' card on the left... I'd like a new page to open up that 
display the details for that card and allows the user to edit the info or 
completely delete the card.

I'm maybe asking a bit much here - but I'm unsure of how complex these 
requirements are. It feels like it should be *fairly *straightforward. Any 
thoughts or advice would be greatly appreciated.

Thanks for your time

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0c63ef85-83be-4822-9aa8-0937b4213276%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Flakey tests and django.db.utils.InterfaceError: connection already closed

2018-02-12 Thread Peter Nociar
Thanks, this fixed my issue. 

On Tuesday, 12 April 2016 04:28:21 UTC+1, thinkwell wrote:
>
> I'd parked this problem for quite some time, until it finally became 
> incontestably necessary to wrestle the issue to the ground.
>
> What I found, after many hours of experimenting - too much like the random 
> walk, I suppose, is that every time I overrode setUpClass, I also had to 
> override tearDownClass. Before, if I had nothing to clean up after the 
> test, I wouldn't bother overriding tearDownClass.
>
> When I went to all my tests and added 
>
> @classmethod
> def tearDownClass(cls):
>  pass
>
> Then my problems went away. I reckon that's in the docs somewhere. But it 
> seems to me that tearDownClass should be able to degrade more gracefully. 
> :weary:
>
>
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/10b1b43c-8f7c-4f31-ac83-919c85673c3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to install and use Django

2018-02-12 Thread Etienne Robillard

Hi Mirek,

That's a good point. But for debugging and development purposes, i 
prefer using mercurial or git to upgrade my packages. Also, having 
access to the source tree while developing your app makes debugging more 
convenient than with the python eggs format.


Cheers,

Etienne


Le 2018-02-12 à 09:51, Mirek Zvolsky a écrit :

Hallo Etienne.

System Python and system python modules are provided for all system 
applications written in Python (made compatible with distributed 
python+modules versions).


Of course you can use it for your applications too, however you have 
no control over system upgrades. After a system upgrade you must 
always check which python modules were upgraded, and then make sure 
that ALL YOUR PYTHON APPS are still compatible with new versions. 
Maybe you can just say "ok, my tests have still passed", however I'm 
not sure that this is very liable.


With Virtualenv you run always your application(s) so as you have them 
developped and debugged. You can upgrade versions only when YOU DECIDE 
TO DO SO.


And Virtualenv is so easy today with Python 3! No installation at all:

python3 -m venv ve_application/
. ve_application/bin/activate

That's definitely all.
And you can generate the requirements file: pip freeze > requirements.txt
And you can reinstall all dependencies into a new environment with 
single command: pip install -r requirements.txt



Dne sobota 10. února 2018 11:56:00 UTC+1 Etienne Robillard napsal(a):

Salut Pascual,


Le 2018-02-10 à 05:47, PASCUAL Eric a écrit :


If virtualenv is to be avoided /(which I do not recommend anyway,
especially for a newbie, since it protects him from breaking his
Python system installation)/, my advice would be to go with:


$ python setup.py install *--user*



You're not going to break your Python setup just by installing a
package with distutils/setuptools. ;-)

In fact, the purpose of site-packages and dist-packages
directories is to provide a logical layout for Python packages.
There's no need in my opinion to not install Django in a standard
location.

Best regards,
Etienne

-- 
Etienne Robillard

tka...@yandex.com 
https://www.isotopesoftware.ca/ 

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6d034405-1eaf-4856-89fc-3d10c10c277b%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7000639c-8815-0bec-b448-bce979eaf231%40yandex.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to install and use Django

2018-02-12 Thread Mirek Zvolsky
>> inderjeet
What about this tutorial: 
https://simpleisbetterthancomplex.com/series/beginners-guide
(if you use it and will be confused about (old)virtualenv vs. python -m 
venv, read the discussion bellow the article)

My tip for IDE: PyCharm. PyCharm Community Edition for beginning.

And my other tip: What about to install double boot Windows+Debian/testing 
and develop under Debian/testing?
(Debian versions change very rare. Debian/testing is changed very often and 
still stable enough for developers work. This requires install the standard 
Debian and then make change in installation sources. Or you could use 
Ubuntu (or Mint) instead of Debian/testing. They are derrived from Debian 
but more often updated. - Of course you can find all articles in internet, 
but it is always nice if somebody could lead you in first weeks.)

https://medium.com/linode-cube/migrating-to-linux-from-windows-makes-for-good-business-d44888af3cec



Dne čtvrtek 8. února 2018 23:28:19 UTC+1 Inderjeet Kaur napsal(a):
>
> Hi 
>
> I am new to Django. can anyone please help me with installation and 
> starting a project. Does Django have IDE like dreamweaver or Visual studio 
> to design a website?
> I have installed Python 3.6 on my Windows machine. Also I have downloaded 
> and installed Django files at 
> location C:\Users\Vismaad\Documents\Django-2.0.2\build\lib\django.
>
>I have no idea how to move ahead. What are Django-admin-tools?
>
> Thanks!
>

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


Re: How to install and use Django

2018-02-12 Thread Mirek Zvolsky
>> inderjeet
What about this 
tutorial: https://simpleisbetterthancomplex.com/series/beginners-guide
(if you use it and will be confused about (old)virtualenv vs. python -m 
venv, read the discussion bellow the article)

My tip for IDE: PyCharm. PyCharm Community Edition for beginning.

And my other tip: What about to install double boot Windows+Debian and 
develop under Debian?




Dne čtvrtek 8. února 2018 23:28:19 UTC+1 Inderjeet Kaur napsal(a):
>
> Hi 
>
> I am new to Django. can anyone please help me with installation and 
> starting a project. Does Django have IDE like dreamweaver or Visual studio 
> to design a website?
> I have installed Python 3.6 on my Windows machine. Also I have downloaded 
> and installed Django files at 
> location C:\Users\Vismaad\Documents\Django-2.0.2\build\lib\django.
>
>I have no idea how to move ahead. What are Django-admin-tools?
>
> Thanks!
>

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


Re: How to install and use Django

2018-02-12 Thread Mirek Zvolsky
Hallo Etienne.

System Python and system python modules are provided for all system 
applications written in Python (made compatible with distributed 
python+modules versions).

Of course you can use it for your applications too, however you have no 
control over system upgrades. After a system upgrade you must always check 
which python modules were upgraded, and then make sure that ALL YOUR PYTHON 
APPS are still compatible with new versions. Maybe you can just say "ok, my 
tests have still passed", however I'm not sure that this is very liable.

With Virtualenv you run always your application(s) so as you have them 
developped and debugged. You can upgrade versions only when YOU DECIDE TO 
DO SO.

And Virtualenv is so easy today with Python 3! No installation at all:

python3 -m venv ve_application/
. ve_application/bin/activate

That's definitely all.
And you can generate the requirements file: pip freeze > requirements.txt
And you can reinstall all dependencies into a new environment with single 
command: pip install -r requirements.txt


Dne sobota 10. února 2018 11:56:00 UTC+1 Etienne Robillard napsal(a):
>
> Salut Pascual,
>
> Le 2018-02-10 à 05:47, PASCUAL Eric a écrit :
>
> If virtualenv is to be avoided *(which I do not recommend anyway, 
> especially for a newbie, since it protects him from breaking his Python 
> system installation)*, my advice would be to go with:
>
>
> $ python setup.py install *--user*
>
>
> You're not going to break your Python setup just by installing a package 
> with distutils/setuptools. ;-)
>
> In fact, the purpose of site-packages and dist-packages directories is to 
> provide a logical layout for Python packages. 
> There's no need in my opinion to not install Django in a standard location.
>
> Best regards,
> Etienne
>  
>
> -- 
> Etienne robillardtka...@yandex.com 
> https://www.isotopesoftware.ca/
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6d034405-1eaf-4856-89fc-3d10c10c277b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch error raise when adding a new entry in django admin

2018-02-12 Thread Julio Biason
Hi Weifeng,

I think the problem is here:

django.urls.exceptions.NoReverseMatch: Reverse for
'nmm_tokenservice_userprofile_change' with arguments '('',)' not found. 1
pattern(s) tried: ['admin/nmm_tokenservice\\/userprofile\\/(?P.+
)\\/change\\/$']

By all the Django is saying, you're trying to reverse the URL for
`mm_tokenservice_userprofile_change` passing an empty string as args; but
your regex por it requres an `object_id` that must have at least 1
character (that's what `.+` means). So, because you're passing no
parameters, it can't resolve the URL properly.

You *need* to pass the object_id, as per your URL specification, on your
reverse.

Hope that helps.

On Mon, Feb 12, 2018 at 1:20 AM, Weifeng Pan  wrote:

> I got this wired issue. who can help.
>
> Python 3.6
> Django Latest 2.0.2
>
> following are stack trace---
> Internal Server Error: /admin/nmm_tokenservice/userprofile/add/ Traceback
> (most recent call last): File "C:\Python36\lib\site-
> packages\django\core\handlers\exception.py", line 35, in inner response =
> get_response(request) File "C:\Python36\lib\site-
> packages\django\core\handlers\base.py", line 128, in _get_response
> response = self.process_exception_by_middleware(e, request) File
> "C:\Python36\lib\site-packages\django\core\handlers\base.py", line 126,
> in _get_response response = wrapped_callback(request, *callback_args,
> **callback_kwargs) File "C:\Python36\lib\site-
> packages\django\contrib\admin\options.py", line 574, in wrapper return
> self.admin_site.admin_view(view)(*args, **kwargs) File
> "C:\Python36\lib\site-packages\django\utils\decorators.py", line 142, in
> _wrapped_view response = view_func(request, *args, **kwargs) File
> "C:\Python36\lib\site-packages\django\views\decorators\cache.py", line
> 44, in _wrapped_view_func response = view_func(request, *args, **kwargs)
> File "C:\Python36\lib\site-packages\django\contrib\admin\sites.py", line
> 223, in inner return view(request, *args, **kwargs) File
> "C:\Python36\lib\site-packages\django\contrib\admin\options.py", line
> 1553, in add_view return self.changeform_view(request, None, form_url,
> extra_context) File 
> "C:\Python36\lib\site-packages\django\utils\decorators.py",
> line 62, in _wrapper return bound_func(*args, **kwargs) File
> "C:\Python36\lib\site-packages\django\utils\decorators.py", line 142, in
> _wrapped_view response = view_func(request, *args, **kwargs) File
> "C:\Python36\lib\site-packages\django\utils\decorators.py", line 58, in
> bound_func return func.__get__(self, type(self))(*args2, **kwargs2) File
> "C:\Python36\lib\site-packages\django\contrib\admin\options.py", line
> 1450, in changeform_view return self._changeform_view(request, object_id,
> form_url, extra_context) File "C:\Python36\lib\site-
> packages\django\contrib\admin\options.py", line 1495, in _changeform_view
> return self.response_add(request, new_object) File "C:\Python36\lib\site-
> packages\django\contrib\admin\options.py", line 1098, in response_add
> current_app=self.admin_site.name, File 
> "C:\Python36\lib\site-packages\django\urls\base.py",
> line 88, in reverse return iri_to_uri(resolver._reverse_with_prefix(view,
> prefix, *args, **kwargs)) File 
> "C:\Python36\lib\site-packages\django\urls\resolvers.py",
> line 632, in _reverse_with_prefix raise NoReverseMatch(msg)
> django.urls.exceptions.NoReverseMatch: Reverse for
> 'nmm_tokenservice_userprofile_change' with arguments '('',)' not found. 1
> pattern(s) tried: ['admin/nmm_tokenservice\\/
> userprofile\\/(?P.+)\\/change\\/$']
>
> * here is my model---*
> class UserProfile(models.Model):
> #base information
> user = models.OneToOneField(User, on_delete=models.deletion.CASCADE,
> verbose_name='系统账户', related_name='profile')
> uid = UIDField(verbose_name='用户ID', primary_key=True, editable=False, null
> =False, blank=False)
> imuid = UIDField(verbose_name='IM用户ID', editable=False, null=True, blank=
> True)
> nickname = models.CharField(verbose_name='昵称', max_length=20, null=True,
> blank=True, db_index=True)
> tel = models.CharField(verbose_name='手机号码', max_length=20, null=True,
> blank=False)
> #status and level
> status = models.CharField(verbose_name='状态', max_length=20, null=False,
> blank=False, default=USER_STATUS[0][0], choices=USER_STATUS)
> level = models.PositiveIntegerField(verbose_name='级别', null=False, blank=
> False, default=1, db_index=True)
> #org information
> city = CityCodeField(verbose_name='城市', null=True, blank=False)
> org = CodeField(verbose_name='学校或组织机构代码', null=True, blank=True, db_index=
> True)
> textbookcode = LabelCodeField(verbose_name='教材(标签代码)', help_text='请填写标签代码',
> null=True, blank=True, db_index=True)
> gradecode = LabelCodeField(verbose_name='年级/级别(标签代码)', help_text='请填写标签代码',
> null=True, blank=True, db_index=True)
> #role
> role = UserRoleField(verbose_name='角色', null=False, blank=False, 
> choices=UserRole_CHOICES,
> default=UserRole.user.name)
> ### teacher specific

Re: NoReverseMatch error raise when adding a new entry in django admin

2018-02-12 Thread Etienne Robillard

Hi Weifeng,

plz show us your urls.py...

Etienne


Le 2018-02-11 à 22:20, Weifeng Pan a écrit :

I got this wired issue. who can help.
Python 3.6
Django Latest 2.0.2
following are stack trace---
Internal Server Error: /admin/nmm_tokenservice/userprofile/add/ 
Traceback (most recent call last): File 
"C:\Python36\lib\site-packages\django\core\handlers\exception.py", 
line 35, in inner response = get_response(request) File 
"C:\Python36\lib\site-packages\django\core\handlers\base.py", line 
128, in _get_response response = 
self.process_exception_by_middleware(e, request) File 
"C:\Python36\lib\site-packages\django\core\handlers\base.py", line 
126, in _get_response response = wrapped_callback(request, 
*callback_args, **callback_kwargs) File 
"C:\Python36\lib\site-packages\django\contrib\admin\options.py", line 
574, in wrapper return self.admin_site.admin_view(view)(*args, 
**kwargs) File 
"C:\Python36\lib\site-packages\django\utils\decorators.py", line 142, 
in _wrapped_view response = view_func(request, *args, **kwargs) File 
"C:\Python36\lib\site-packages\django\views\decorators\cache.py", line 
44, in _wrapped_view_func response = view_func(request, *args, 
**kwargs) File 
"C:\Python36\lib\site-packages\django\contrib\admin\sites.py", line 
223, in inner return view(request, *args, **kwargs) File 
"C:\Python36\lib\site-packages\django\contrib\admin\options.py", line 
1553, in add_view return self.changeform_view(request, None, form_url, 
extra_context) File 
"C:\Python36\lib\site-packages\django\utils\decorators.py", line 62, 
in _wrapper return bound_func(*args, **kwargs) File 
"C:\Python36\lib\site-packages\django\utils\decorators.py", line 142, 
in _wrapped_view response = view_func(request, *args, **kwargs) File 
"C:\Python36\lib\site-packages\django\utils\decorators.py", line 58, 
in bound_func return func.__get__(self, type(self))(*args2, **kwargs2) 
File "C:\Python36\lib\site-packages\django\contrib\admin\options.py", 
line 1450, in changeform_view return self._changeform_view(request, 
object_id, form_url, extra_context) File 
"C:\Python36\lib\site-packages\django\contrib\admin\options.py", line 
1495, in _changeform_view return self.response_add(request, 
new_object) File 
"C:\Python36\lib\site-packages\django\contrib\admin\options.py", line 
1098, in response_add current_app=self.admin_site.name, File 
"C:\Python36\lib\site-packages\django\urls\base.py", line 88, in 
reverse return iri_to_uri(resolver._reverse_with_prefix(view, prefix, 
*args, **kwargs)) File 
"C:\Python36\lib\site-packages\django\urls\resolvers.py", line 632, in 
_reverse_with_prefix raise NoReverseMatch(msg) 
django.urls.exceptions.NoReverseMatch: Reverse for 
'nmm_tokenservice_userprofile_change' with arguments '('',)' not 
found. 1 pattern(s) tried: 
['admin/nmm_tokenservice\\/userprofile\\/(?P.+)\\/change\\/$']

* here is my model---*
class UserProfile(models.Model):
#base information
user = models.OneToOneField(User, on_delete=models.deletion.CASCADE, 
verbose_name='系统账户', related_name='profile')
uid = UIDField(verbose_name='用户ID', primary_key=True, editable=False, 
null=False, blank=False)
imuid = UIDField(verbose_name='IM用户ID', editable=False, null=True, 
blank=True)
nickname = models.CharField(verbose_name='昵称', max_length=20, 
null=True, blank=True, db_index=True)
tel = models.CharField(verbose_name='手机号码', max_length=20, null=True, 
blank=False)

#status and level
status = models.CharField(verbose_name='状态', max_length=20, 
null=False, blank=False, default=USER_STATUS[0][0], choices=USER_STATUS)
level = models.PositiveIntegerField(verbose_name='级别', null=False, 
blank=False, default=1, db_index=True)

#org information
city = CityCodeField(verbose_name='城市', null=True, blank=False)
org = CodeField(verbose_name='学校或组织机构代码', null=True, blank=True, 
db_index=True)
textbookcode = LabelCodeField(verbose_name='教材(标签代码)', 
help_text='请填写标签代码', null=True, blank=True, db_index=True)
gradecode = LabelCodeField(verbose_name='年级/级别(标签代码)', 
help_text='请填写标签代码', null=True, blank=True, db_index=True)

#role
role = UserRoleField(verbose_name='角色', null=False, blank=False, 
choices=UserRole_CHOICES, default=UserRole.user.name)

### teacher specific attributes ###
synopsis = models.TextField(verbose_name='个人简介', max_length=500, 
null=True, blank=True)
workhistory = models.TextField(verbose_name='工作经历', max_length=500, 
null=True, blank=True)
cert = models.TextField(verbose_name='荣誉证书', max_length=500, 
null=True, blank=True)
labels = models.CharField(verbose_name='个人标签', max_length=100, 
null=True, blank=True)
scope = models.CharField(verbose_name='出题范围', 
help_text='老师的出题范围,仅对老师角色有效', max_length=100, null=True, 
blank=True)
title = models.PositiveIntegerField(verbose_name='头衔级别', null=False, 
blank=False, default=1, db_index=True)

### promotion and relation ###
promotioncode = PromotionCodeField(verbose_name='推荐码', 
help_text='用于推荐其他用户或者老师', null=True, blank=True)
broker_pr