Re: Django Video Conferencing-Reg

2020-04-11 Thread Yoo
I recommend you implement video conferencing yourself using native Django 3.0 
websockets OR Django channels. You just have to figure out how to 1. get camera 
input, 2. convert it into base64, 3. send it over the socket, then 4. in HTML, 
show the image. My issue with that is 1. you need to send images at a certain 
rate because the server has to send BACK the image to everyone and 2. figure 
out the HTML tag.

Videos are just images played at high rate of speed, but I can’t tell if you 
should use a video or img tag. Good luck!

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5a1c1e99-6457-4a64-bec6-4c83a4cbec82%40googlegroups.com.


AWS API or EC2 for chat?

2020-03-24 Thread Yoo
Hi all! I built a chat app without dj channels, but now I’m stuck with 
pricing... and just AWS in general. Every time I look up Websockets, I’m told 
to use AWS API Gateway. Why? And if so, how would I split my project between 
EC2 for website and API Gateway for my mobile users and for chats?

Or am I comparing the wrong things? Is the comparison between gateway and load 
balancer?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0babe8f3-1472-4bae-bab9-73e265969a87%40googlegroups.com.


Monitoring Production Cookiecutter-Django

2019-11-28 Thread Yoo
I’m using cookiecutter-django and Docker for production, and I’m looking for 
some kind of monitoring package that comes with a GUI. My website is heavy on 
memory for calculations, so I’m testing it with locust.io. I want to be able to 
monitor a bunch of things such as firewall for SIEM and simple network 
monitoring and other things like memory allocation, caches, and db size.

I took a look at datadog but am afraid I can’t actually monitor it once I send 
the site into production (using docker-compose -f production.yml up -d for 
background deployment). 

Any other packages? Maybe a package that integrates with Docker so I can also 
run it via compose? Or maybe something more network/remote based?

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1e09cf01-ecf2-481a-b97c-94bee8147bda%40googlegroups.com.


Re: reg: django Model for MCQs type project

2019-11-20 Thread Yoo
Have a Test model which as a unique identifier (BigAutoField). Get a Questions 
model with a foreign key to a test and a charfield for the question itself (you 
can add BrinIndex for optimization). You can add a booleanfield if the question 
is optional and whatever else you need (like the correct answer letter). Get an 
Answers model with a foreign key to a specific question. This is the most 
efficient.

You say you don’t need authentication, but it looks like students need some 
kind of it... BUT there is an alternative. If the student doesn’t have to fill 
out their name, then, using paths, you can show the student a URL that is 
connected to a record on another model. 

It could look like this: example.com/test/3?completed=846

With the path of completed=846, a view can query this new model, we’ll call 
Completed, that has the following attributes (columns): id (BigAutoField) and 
Your_Answers (ArrayField/JSONField Both PostgreSQL only). The view does a query 
on the test (test 3) to show and now also has data from the Completed table at 
the row with id=846.

Just to open your mind up to another world WHICH IS NOT EFFICIENT AND NOT 
PRETTY TO IMPLEMENT SO PLEASE DO NOT DO IT... You could also try it with 
PostgreSQL’s JSON attribute. Just make a test model which includes a unique 
identifier and a json field. The JSON field would just have keys be the 
question number (1-10) and then a... nvm here’s an example of a piece of json.

{
  1: {“question”: “What is your name?”,
   “answers”: [“blah1”, “blah2”, “blah3”] }
   2: {“question”: “What is your ethnicity?”,
   “answers”: [“blah1”, “blah2”, “blah3”] }
}

You could also try it NoSQL style with MongoDB. Each document is a test with a 
unique identifier
Good luck!
On Wednesday, November 20, 2019 at 12:21:38 AM UTC-5, Amitesh Sahay wrote:
> Hello Members,
> 
> 
> I have below requirements for a project where I need to develop the model 
> based on "multiple Choice Questions". Below are the criteria:-
> 
> 
> 
> Admin can create/edit/delete(soft delete only) a "Test" in the form of 
> MCQs.Admin can then create/edit/delete a "Question"
>  to each test. Each question contains the actual question, the correct 
> answer and 3 incorrect answers. An admin can mark a question as mandatory or 
> optional. An optional question can be skipped by the student.Admin can also 
> set the marks for each questionStudent
>  can view a testStudent can attempt a test. Every test can be attempted 
> multiple times. Each attempt is scored and saved separately. Since the 
> questions are in MCQ format, the students answers are auto-evaluated by the 
> application.
> 
> 
> This is something very new for me. So, I am little reluctant on how to create 
> the model for the above requirement. Here I do not need to develop any 
> authentication environment. 
> 
> 
> 
> Any help would be highly appreciated.
> 
> 
> 
> 
> 
> 
> 
> Regards,
> Amitesh

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8c6eb210-dfe4-42e4-8d16-71aa78ebceb5%40googlegroups.com.


Re: Problem trying to use postgresql and psycopg2 in a django project

2019-11-20 Thread Yoo
Hey, I think for OSX (Mac) or anything using the Darwin OS (basically apple) 
has to use psycopg2’s binary. Just install psycopg2-binary and it should work.

On Wednesday, November 20, 2019 at 6:50:01 AM UTC-5, tramites xpress drive 
wrote:
> Hi, I Have been trying to setup my django 2 developement environment and to 
> connect it to postgresql but whern I change the parameters in settings.py on 
> the sections of DATABASES to use POSTGRES and Psycopg2  I Receive the 
> following error
> 
> 
> 
> 
> 
> 
> 
> eztve) Indiras-MBP-16a3:ezt Sindira$ python manage.py runserver
> 
> 
> 
> 
> 
> Watching for file changes with StatReloader
> 
> Exception in thread django-main-thread:
> 
> Traceback (most recent call last):
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/backends/postgresql/base.py",
>  line 20, in 
> 
>     import psycopg2 as Database
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/psycopg2/__init__.py",
>  line 50, in 
> 
>     from psycopg2._psycopg import (                     # noqa
> 
> ImportError: 
> dlopen(/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/psycopg2/_psycopg.cpython-37m-darwin.so,
>  2): Library not loaded: libssl.1.1.dylib
> 
>   Referenced from: 
> /Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/psycopg2/_psycopg.cpython-37m-darwin.so
> 
>   Reason: image not found
> 
> 
> 
> 
> 
> During handling of the above exception, another exception occurred:
> 
> 
> 
> 
> 
> Traceback (most recent call last):
> 
>   File 
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py",
>  line 926, in _bootstrap_inner
> 
>     self.run()
> 
>   File 
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py",
>  line 870, in run
> 
>     self._target(*self._args, **self._kwargs)
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/utils/autoreload.py",
>  line 54, in wrapper
> 
>     fn(*args, **kwargs)
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/core/management/commands/runserver.py",
>  line 109, in inner_run
> 
>     autoreload.raise_last_exception()
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/utils/autoreload.py",
>  line 77, in raise_last_exception
> 
>     raise _exception[1]
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/core/management/__init__.py",
>  line 337, in execute
> 
>     autoreload.check_errors(django.setup)()
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/utils/autoreload.py",
>  line 54, in wrapper
> 
>     fn(*args, **kwargs)
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/__init__.py",
>  line 24, in setup
> 
>     apps.populate(settings.INSTALLED_APPS)
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/apps/registry.py",
>  line 114, in populate
> 
>     app_config.import_models()
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/apps/config.py",
>  line 211, in import_models
> 
>     self.models_module = import_module(models_module_name)
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/importlib/__init__.py", 
> line 127, in import_module
> 
>     return _bootstrap._gcd_import(name[level:], package, level)
> 
>   File "", line 1006, in _gcd_import
> 
>   File "", line 983, in _find_and_load
> 
>   File "", line 967, in _find_and_load_unlocked
> 
>   File "", line 677, in _load_unlocked
> 
>   File "", line 728, in exec_module
> 
>   File "", line 219, in _call_with_frames_removed
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/contrib/auth/models.py",
>  line 2, in 
> 
>     from django.contrib.auth.base_user import AbstractBaseUser, 
> BaseUserManager
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/contrib/auth/base_user.py",
>  line 47, in 
> 
>     class AbstractBaseUser(models.Model):
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/models/base.py",
>  line 117, in __new__
> 
>     new_class.add_to_class('_meta', Options(meta, app_label))
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/models/base.py",
>  line 321, in add_to_class
> 
>     value.contribute_to_class(cls, name)
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/models/options.py",
>  line 204, in contribute_to_class
> 
>     self.db_table = truncate_name(self.db_table, 
> connection.ops.max_name_length())
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/__init__.py",
>  line 28, in __getattr__
> 
>     return getattr(connections[DEFAULT_DB_ALIAS], item)
> 
>   File 
> 

Re: Django authentication best practice

2019-11-20 Thread Yoo
Whenever I deploy an app, I always use cookiecutter-django. I’m pretty sure 
there is an option lying somewhere in the settings that let you disable 
username. If not, I believe the BaseUser model has the option of the unique 
identifier or username be set to the email itself.

Otherwise, you can do what you said, which is abstractbaseuser model. Or you 
can setup a manager class. Check the Django source code for a little more 
insight.

On Wednesday, November 20, 2019 at 6:50:01 AM UTC-5, mmk mmk wrote:
> I want to replace django default username and password authentication with 
> email and password authentication,
> i have many solution like extends Abstractbaseuser or using 3rd part like 
> django-allauth .
> My question now which is best practice to using 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e9dbd28e-3fc0-4954-bdd4-12938f80e24d%40googlegroups.com.


Re: Knowing when cache expires or DurationField is done

2019-08-24 Thread Yoo
Just to clarify the first point: celery is "updating" the cache with new 
info once the cache expires; hence the need for the cache to expire. I 
thought about using a DB table, but also thought about how wasteful it 
would be to keep a DurationField (which I still don't know how to use) to 
log when celery should execute a task.

On Saturday, August 24, 2019 at 5:12:12 PM UTC-4, Yoo wrote:
>
> 1. Using celery to make a replacement cache when that specific expires, 
> but not sure how to do it.
> 2. Along the same lines, I need to also know when a DurationField is at 
> "zero." Not sure how a DurationField works though. Again, need celery to be 
> able to execute something when a specific record has its attribute hit the 
> "zero" on its "timer."
>
> If there are other ways, lemme know!
>
> 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9a902c69-72db-404c-b76e-a42fbbdbbb1e%40googlegroups.com.


Knowing when cache expires or DurationField is done

2019-08-24 Thread Yoo
1. Using celery to make a replacement cache when that specific expires, but 
not sure how to do it.
2. Along the same lines, I need to also know when a DurationField is at 
"zero." Not sure how a DurationField works though. Again, need celery to be 
able to execute something when a specific record has its attribute hit the 
"zero" on its "timer."

If there are other ways, lemme know!

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/083c6de8-cc15-4400-999d-efff949a76ba%40googlegroups.com.


Re: DRF with Rich Text

2019-08-21 Thread Yoo
Hi,
Thanks for the prompt response (and sorry for such a late one). I suppose 
I'm simply asking about JSON in general and DRF validation. Using the 
general serializer (serializer.Serializers), DRF validates the JSON itself, 
right? So, if some malicious person sent Python code via the JSON using 
some kind of escape char, then DRF responds with an error, right?

Otherwise, is there some Django util that can deal with this? Because the 
API is just an endpoint. All someone has to do (at least in this project) 
is send a JWT Access token alongside some throttling. Can you point out 
some Headers that I can use? Is it possible to use some kind of app (i.e. 
android + iOS) signature?

Thank you! 

On Tuesday, August 20, 2019 at 11:46:24 PM UTC-4, Aditya Singh wrote:
>
> Hi,
> Hope you are good.
> Django ships with top of the line CSRF protection first of all, Secondly, 
> you may specify domain specific headers and strictly restrict the expected 
> type of data, cookies timeout, response data type from the server to the 
> client. Also, you may leverage several robust django compatible packages 
> which relate to security and prevent any requests to the API whiah are 
> unauthorized. From unauthorized, I feel obliged to mention that you must 
> make sure that all the endpoints in your api are well defined and that all 
> the methods being executed on those corresponding endpoints need strong 
> authentication.
> Hope, I could be of some help,
> Kind regards,
> Aditya
>
> On Wed, Aug 21, 2019, 9:11 AM Yoo > 
> wrote:
>
>> Hi, I'm gonna be using Django Rest Framework for API with a Postgres 
>> stack and not developing with website. Coding apps in Swift and Androidx 
>> Java. Users can POST rich text, or text that uses HTML, to the server, and 
>> then other users can GET that HTML and view it in (ui)TextView.
>>
>> Based on previous experience, it seemed like Android's TextView wouldn't 
>> have any trouble with XSS or the like. Not sure about Swift, so can someone 
>> tell me if I should worry on the iOS side? 
>>
>> Last thing. Because this is just an API, how does DRF protect my server 
>> against some malicious JSON POST request? A request that isn't sent from 
>> the designated app or is hand-crafted. If DRF doesn't somehow serialize 
>> correctly, then there would be some server issues, right? Gah worrying.
>>
>> TL;DR. Programming mobile with DRF. Should I worry about Rich Text (HTML 
>> Editing) on client and/or server side?
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/6c6b92e2-7e49-42f8-abe5-d05b1d0f4619%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/6c6b92e2-7e49-42f8-abe5-d05b1d0f4619%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a6ea2741-061c-4392-af73-6e9ff4dc5a16%40googlegroups.com.


DRF with Rich Text

2019-08-20 Thread Yoo
Hi, I'm gonna be using Django Rest Framework for API with a Postgres stack 
and not developing with website. Coding apps in Swift and Androidx Java. 
Users can POST rich text, or text that uses HTML, to the server, and then 
other users can GET that HTML and view it in (ui)TextView.

Based on previous experience, it seemed like Android's TextView wouldn't 
have any trouble with XSS or the like. Not sure about Swift, so can someone 
tell me if I should worry on the iOS side? 

Last thing. Because this is just an API, how does DRF protect my server 
against some malicious JSON POST request? A request that isn't sent from 
the designated app or is hand-crafted. If DRF doesn't somehow serialize 
correctly, then there would be some server issues, right? Gah worrying.

TL;DR. Programming mobile with DRF. Should I worry about Rich Text (HTML 
Editing) on client and/or server side?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6c6b92e2-7e49-42f8-abe5-d05b1d0f4619%40googlegroups.com.


Horizontal Partition. How affect other indexes?

2019-07-17 Thread Yoo
Err so no one responded to my post, so I suppose here's a more general 
Database question:
Let's say there is a table with two indexes. I horizontally partition by 
one of the indexes. How does this affect the other one? I need to utilize 
BOTH indexes and there is no way I'm able to vertically partition. 
Horizontal partition is basically a BRIN index, right? Gah, please help xD 
Dying... But thank you in advance!

This was my original question on here and on Reddit: 
https://www.reddit.com/r/django/comments/ce7olj/question_votes_table_with_partitions_brin_btree/

-- 
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/890d341c-c00a-4fdc-9aa5-2fd692a43a80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Make an Heroku connect model my app's custom user model

2019-07-17 Thread Yoo
Hi! I'm not fully acquainted with Heroku connect, but here's the pdf docs: 
https://buildmedia.readthedocs.org/media/pdf/django-heroku-connect/stable/django-heroku-connect.pdf
 on 
page 9 you can find:
heroku_connect.E006 The Salesforce object name must be unique since an 
object can only mapped to a PostgreSQL table once. 

Probably need to check the docs and see that two TABLES do NOT have the 
same name, according to the error. You might also want to check your other 
tables to make sure their attributes/columns are not the same. That's just 
theory, since I'm not too sure.

On Wednesday, July 17, 2019 at 11:26:04 AM UTC-4, Elia Gandolfi wrote:
>
> # I want this Heroku-Connect model to be my app's custom user model.
> # That means, vendors registered in my Salesforce database should be able 
> to login with their vendor_code__c as username
> class Vendor(hc_models.HerokuConnectModel):
> sf_object_name = 'Vendor__c'
>
> vendor_code = hc_models.ExternalID(sf_field_name='Vendor_Code__c', unique=
> True, upsert=False) # this should be the username
> sf_id = hc_models.fields.ID(db_column='sfid', db_index=True, editable=
> False, max_length=18, sf_field_name='ID', unique=True, upsert=False)
> name = hc_models.Text(sf_field_name='Name', max_length=80)
> email = hc_models.Text(sf_field_name='Email__c', max_length=80)
>
> # I've tried to replicate the vendor model with multi-table inheritance, 
> found here
> # 
> https://django-heroku-connect.readthedocs.io/en/latest/models.html#multi-table-inheritance
> class vendoruser(Vendor):
> hc_model = models.OneToOneField(Vendor, on_delete=models.CASCADE, to_field
> ='vendor_code', parent_link=True, db_constraint=False)
>
> # the idea is to extend the model from here. I do as in the example, but I 
> get blocked right away with the following error
>
> """
> salesforce.vendoruser: (heroku_connect.E006) 
> salesforce.vendoruser.sf_object_name 'Vendor__c' clashes with another model.
> HINT: Make sure your 'sf_object_name' is correct.
> """
>
> # I've also tried to use hc_models.OneToOneField or hc_models.ForeignKey 
> but it's not supported
> # Any suggestion on how to work around 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/531f0d35-b323-4c27-9d34-5680bde513ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can Django fill in a template based on a custom URL, if the contents of the URL match an item in the database?

2019-07-17 Thread Yoo
Hmm. So is diamondscompany.com/ going to be static? As in that is 
permanent? If so, then your custom button can simply be a custom URL. I'm 
not sure if a listing on eBay can automatically be done (not acquainted 
with it, sorry), but I imagine editing the admin.py with some custom stuff. 
Maybe read the docs here: 
https://docs.djangoproject.com/en/2.2/ref/contrib/admin/ See if that helps. 
Maybe you could also dig in and add a custom HTML line like so: Click here for 
pre-filled eBay listing.

For your second bullet point, there are a couple of things with Django's 
url stuff to which you can ignore. Here's an example of a blog post: 
myblog.com/posts/?q=123
In a VIEW in views.py, you can do this:

def posts(request):
postID = request.GET.get('q')
post = Post.objects.get(id=postID)
context = {
   "post": post,
}
return render(request, "posts.html", context=context)

this is assuming a URLPATTERN like so (in Django 2.2 at least):
path("posts/", views.posts)
And that's it!

For your last point, regarding saving pages, Django does have a caching 
mechanism JUST for pages! But I've never tested it. Here's the link: 
https://docs.djangoproject.com/en/2.2/topics/cache/ (use their table of 
contents or CTRL + F "template"). Again, I've never tried this, and you may 
have to ask again if the caches can remain alive forever (maybe use a 
filebased cache).

I hope that helps. Cheers!
Yoom

On Wednesday, July 17, 2019 at 11:26:04 AM UTC-4, Matvey Kostukovsky wrote:
>
> Hi everyone,
>
> This might be a noob question, but I've been searching everywhere for 
> almost half a year now, I've read through a huge chunk of the docs, I've 
> gone through many tutorials, read many stack questions & answers, and I 
> still don't feel like I'm any closer to the solution. I did manage to 
> figure out a few basics and some more complicated set-up type things in the 
> process: I've figure out how to connect Django to an MS SQL Server database 
> on a mac (using the sql_server.pyodbc engine, Docker, Kitematic, and with 
> the help of Azure Data Studio) and to display items from the database by 
> filling in a template using model data. So far so good.
>
> This is a for a diamonds business by the way, and the functionality I'm 
> looking for would allow their team to quickly create eBay listing 
> description HTML from items in the database. I have the HTML template ready 
> to go, and just need to be able to easily send it some data. The admin page 
> is showing the inventory, allowing me to add, delete, and edit items in the 
> database. My goal is the following:
>
>- create a button on the admin inventory page that would open the 
>custom URL with a ready-to-go eBay listing (which they can copy-paste into 
>eBay when listing an item).. the url would be something like 
>diamondscompany.com/ebay/item123, where item123 is the item's 
>catalogue number
>- (optional) allow their team to navigate to a listing simply by 
>typing that URL in the address bar -- can the template get filled in with 
>all the appropriate data on the spot?
>- it would be nice to save each page as a separate html file for later 
>reference, however this is not required.
>
> I have a feeling that this is some of the most basic functionality of 
> Django, and like one of the main reasons people would use it, however I 
> can't seem to find the right combination of keywords to find documentation 
> on how to set this up, or perhaps I'm just having trouble piecing together 
> everything I've learned so far about views, models, urls, etc.
>
> Any help would be deeply appreciated!
>
> Thanks,
>
> Matvey
>

-- 
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/341367d4-9417-4e9b-9954-66abcb9f51e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Running Django 2.2.3 in Apache2

2019-07-17 Thread Yoo
https://www.sysadmin.md/deploy-django-in-production-using-apache-nginx-and-mod-wsgi.html
https://stackoverflow.com/questions/18048318/apache-mod-wsgi-vs-nginx-gunicorn
There are several fantastic tutorials online regarding apache2 and 
mod_wsgi. A simple google search with the keywords apache2 and mod_wsgi 
should grant you a couple. What I did when I deployed on nginx and gunicorn 
(which I highly recommend over apache combinations. Read SO post) was I 
compared two tutorials and made sure they were pretty similar.

Besides preference in performance and how requests are served etc. etc., I 
just found nginx + gunicorn much easier to setup. Good luck!

(Now my tangent recommendation. Hope the above helped!)

If you get stuck somewhere with apache2 and mod_wsgi, try out nginx and 
gunicorn with these links:
(BEFORE YOU GO ON. There is an error in the SECOND tutorial (the 
digitalocean one. When doing gunicorn --bind 0.0.0.0:8000 myproject.wsgi, 
make sure you type in gunicorn --bind 0.0.0.0:8000 
myproject.wsgi:application).

http://www.oneclicksimplify.com/jessie.html (simple and works for most 
Linux-based systems)

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-14-04

(Has a conclusion which'll help you debug stuff. If you get stuck or you 
don't see a symlink being created, do sudo systemctl stop gunicorn && sudo 
systemctl disable gunicorn && sudo systemctl enable gunicorn && sudo 
systemctl start gunicorn .  Or you you can switch gunicorn with nginx.)
They both use postgres for database, but you can skip those steps if you'd 
like. No harm.

On Wednesday, July 17, 2019 at 11:26:04 AM UTC-4, Block QAI wrote:
>
> Group,
>
> We have been working for days attempting to get Django to run under 
> apache2 on a Ubuntu 18.04 server.  Are there ANY clear documentation with 
> steps we ,could leverage to ensure a successful, simple, direct install.
>
> Very much appreciate the assistance.
>
>
>

-- 
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/667ffa0b-26e1-4596-a792-613a408dd77f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue i18n django_language in session

2019-07-17 Thread Yoo
I'm not sure, either. Usually, whenever I'm testing, I open a 
private/incognito browser in case there is caching or cookies are being 
saved (cookies could be related to session authentication and other stuff). 
What I would try first is clearing your cookies if you've been using a 
regular browser tab. Otherwise, I'll also look into it.
Cheers!

On Wednesday, July 17, 2019 at 12:44:57 PM UTC-4, Oscar Rovira wrote:
>
> Hi there,
> I have a Django site with multi-language support through i18n. 
> The default user's language is set based on the browser headers but users 
> can change it via the regular set_language view. 
> Recently I noticed that the UI is shown in a different language than the 
> one my user is supposed to have set and this happens, apparently, without 
> changing my browser language preferences or calling the set_language view.
> I've been looking around the code, checking every statement that makes 
> reference to the language setting of the user in session with no luck on 
> anything that could be causing the issue. I have no clue about what is 
> going on.
> Does the issue rings the bell to someone? Something I could review at?
>
> I appreciate any help or advice. Thanks!
> Oscar
>

-- 
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/c3206781-380a-4a70-a9fa-e896fd997e44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: sqlite update on CentOS 7 for latest django version

2019-07-17 Thread Yoo
Hm did you first do ./manage.py migrate? Maybe your db.sqlite file doesn't 
exist... Check!
Additionally, if there IS a file that is similar to a db name, like 
blah.db, make sure in your "database" settings in settings.py points to 
that file. Sqlite3 isn't old; it's not going away, either. With the link 
you provided, it seems like you still have sqlite3...
Again, try to make sure of the following: 
1. Are you in a virtual environment?
2. Have you applied migrations with python manage.py migrate?
3. Check your database settings in settings.py has the same name as any 
existing sqlite3 or db file extension.

On Wednesday, July 17, 2019 at 2:14:54 PM UTC-4, Tal wrote:
>
> When using the latest django from PyPI in CentOS 7, running "./manage.py 
> runserver" gives an error about sqlite being too old.
> Since there's no newer sqlite version in the CentOS repos, I tried 
> building sqlite from scratch:
>
> curl -L https://www.sqlite.org/2019/sqlite-amalgamation-329.tar.gz 
> 
>  
> > sqlite-amalgamation-329.tar.gz
> tar -xvf sqlite-amalgamation-329.tar.gzcd sqlite-autoconf-329
> ./configure
> make
> make install
>
>
> This sets up the latest sqlite3 to /usr/local/bin/.
> Since /usr/local/bin is ahead of /usr/bin in my PATH, just running 
> "sqlite3" in the terminal runs the latest sqlite.
> It runs without issues, and shows that it's the latest version:
>
> my_hostname# sqlite3
>
> SQLite version 3.29.0 2019-07-10 17:32:03 
> Enter ".help" for usage hints. 
> Connected to a transient in-memory database. 
> Use ".open FILENAME" to reopen on a persistent database. 
> sqlite>
>
>
> Running "./manage.py runserver" again, it still tries to use the old 
> version in /usr/bin, and fails.
> My django is running in a pipenv virtual environment, where PATH still has 
> /usr/local/bin/ ahead of /usr/bin, and running "sqlite3" in terminal still 
> shows the latest version.
>
> I followed the traceback django gives me to the dbapi2.py module, where to 
> figure out the sqlite version it does this:
>
> import _sqlite3
> _sqlite3.sqlite_version
>
>
> If I run "python" in my virtualenv, and type those 2 lines, it shows the 
> old version of sqlite too.
> _sqlite3 is not written in python - it's a compiled binary, so I can't 
> examine it to see where it looks.
>
> Am I missing something?
> How can I tell _sqlite3 that there's a newer version of sqlite available 
> on the system?
> Does _sqlite3 even care about /usr/local/bin/sqlite3? Or is there some 
> sqlite library it's looking for?
>

-- 
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/4f49cd72-86b2-4229-9a5f-446d3b23939b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Query questions. Please help me.

2019-07-17 Thread Yoo
Take a look at Q objects: 
https://docs.djangoproject.com/en/2.2/topics/db/queries/#complex-lookups-with-q-objects

On Wednesday, July 17, 2019 at 4:04:16 PM UTC-4, 나르엔 wrote:
>
> Hello, I am studying django.
>
> When I use objects.filter, I want to search various columns. 
>
> Columns to search for are unknown and have been receiving columns to 
> search through checkbox in html.
>
> What should I do? Please teach me.
> It's blocked from below.
> selectoptions is name in checkbox.
>
>
> ---
> def get_queryset(self):
> context = super(SearchListView, self).get_queryset()
> query = self.request.GET.get('q')
> selectOptions = self.request.GET.getlist('selectoptions')
>

-- 
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/bc0ae786-7b3c-49dd-80de-afa61fa7356f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issues while creating virtual environment before installing Django

2019-07-17 Thread Yoo
Isn't Python 3.x automatically installed with virtualenv and pip?
Try this: 

virtualenv venv

Then, do: cd venv\scripts && activate
Then you can start installing packages like this: pip install django
On Wednesday, July 17, 2019 at 11:26:04 AM UTC-4, Mahesh Kumar wrote:
>
> Hi all,
> I tried to install the Django software in my Laptop command prompt, I have 
> to create(mkvirtualenv myproject) virtual evironment. But as soon as I have 
> entered mkvirtualenv myproject, error is looping on and showling below 
> error. Please try to help me, how to create vritual environment. My laptop 
> configuration is Windows 10, 8gb Ram, 1TB hard disk.
>
> Regards,
> Mahesh
> mahico...@gmail.com 
>

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


Question: Votes Table with Partitions, BRIN & B-Tree indexes

2019-07-17 Thread Yoo
Hi! For context, I have a votes table that is like a through model of 
Many-to-many (M2M). I’m using Postgres because BRIN and other stuff. Here’s 
the table:

class UpVote(models.Model):
id = models.UUIDField(primary_key=True, default=uuid4, editable=False)
post = models.ForeignKey(Post, on_delete=models.CASCADE, db_index = 
False)
user = models.ForeignKey(User, on_delete=models.CASCADE)

class Meta: 
indexes = [BrinIndex(fields=(‘post’))]

I have this table for 2 reasons but they’re also questions:

1. When a user grabs a “post” instance, a query will go out to count. Por 
ejemplo, UpVote.objects.filter(post=self.request.GET.get(‘postID’)).count() 
But question: will this improve performance compared to a B-Tree index? 
Plus, there are many... MANY issues with counting in Postgres, but I only 
need an estimate. To me, BRIN makes sense, right?

2. Users are able to see the posts they’ve upvoted. The catch? I mentioned 
partitioning... I’m planning on horizontally partitioning the tables based 
on the BRIN Index on the “post” attribute. How will this affect the index 
on the “user” attribute? (Index on “user” attribute meant for filtering so 
user is able to see all posts previously upvoted). Note: I stumbled upon 
partitioning awhile ago and never bothered to learn much of it since Django 
docs never mentioned. Implicitly, I’ve done vertical, but horizontal seems 
confusing with the context/situation I have. Apparently, Architect is a 
package that can do partitioning, and so I’ve finally come full-circle.

Thanks for your help (or teachings if I totally got this wrong...)

-- 
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/48b6ce51-d956-4e2c-996d-4d115edd2299%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Internal Ranking System Application

2019-06-25 Thread Yoo
So serializers basically convert python native objects into json objects. 
Your viewset should be the one utilizing serializers. What you need to have 
is:

serializers.py:
class ProfileSerializer(serializer.ModelSerializer):
class Meta:
model = Profile
fields = '__all__'

Basically, you don't need anything else in that serializer.

On Tuesday, June 25, 2019 at 7:46:42 PM UTC-4, Derek Dong wrote:
>
> I've been working more on this and have encountered the following issue 
> extending the User model into a Profile model:
>
> models.py:
>
> class Profile(models.Model):
> user = models.OneToOneField(User, on_delete=models.CASCADE, 
> primary_key=True)
> grade = models.PositiveSmallIntegerField()
>
>
> serializers.py:
>
> class UserSerializer(serializers.HyperlinkedModelSerializer):
> class Meta:
> model = User
> fields = ('id', 'username')
>
>
>
> class ProfileSerializer(serializers.ModelSerializer):
> user = UserSerializer()
> scores = ContestScoresSerializer(many=True)
> indices = ContestIndexSerializer(many=True)
>
> class Meta:
> model = Profile
> fields = ('user', 'grade', 'scores', 'indices')
>
>
> views.py:
>
> class UserViewSet(viewsets.ModelViewSet):
> queryset = User.objects.all()
> serializer_class = UserSerializer
>
>
> class ProfileViewSet(viewsets.ModelViewSet):
> """
> API endpoint that allows users to be viewed or edited.
> """
> queryset = Profile.objects.all()
> serializer_class = ProfileSerializer
>
>
> What am I doing wrong and how do I fix it? The problem is the Profile and 
> User models aren't linked; creating one doesn't create the other, nor does 
> updating or removing one affect the other.
>
> On Monday, June 24, 2019 at 10:00:21 PM UTC-4, Yoo wrote:
>>
>> Np!
>>
>> https://docs.djangoproject.com/en/2.2/ref/models/fields/#floatfield
>>
>> Just refer to the docs. There’s FloatField and DecimalField for models. 
>> When you show the numbers in views, just use python to round the numbers. 
>> There are plenty of tutorials and SO (stackoverflow) questions that’ll 
>> help. People on stack who like Django and want more rep points answer 
>> Django tagged questions, so questions are quickly answered. Like matter of 
>> minutes.
>>
>> Yea, I think all those details are confusing me, but veerrry logical in 
>> your mind since it’s your project. Here’re some things to keep in mind:
>>
>> Queries: Use them efficiently. Using that one table, ContestScores, we 
>> can find some scores for specific contests. We can write something like:
>>
>> from .models import ContestScores
>>
>> avar= ContestScores.objects.filter(contest=2)
>> thisvar = ContestScores.objects.filter(user=‘derek’)
>>
>> Using this, we have a queryset. Any records/rows with contest ID 2 in the 
>> ContestScores table will be in avar. In thisvar, any record that has a user 
>> named derek will be stored. 
>>
>> When making a queryset needs to be ordered by some system (I think it was 
>> descending scores), you can do this using the variables above: 
>> avar.order_by(‘-scores’) 
>>
>> Signals: something I avoided for awhile, but got the hang of pretty 
>> quickly. They have some cool little things like pre_save.
>>
>> from .signals import my_func
>> pre_save.connect(my_func, sender=ContestScores)
>>
>> #in signals.py in the apps directory
>>
>> def my_func(sender, instance, **kwargs):
>> if instance.contest == 1:
>> print(‘hello, you should probably do something with this 
>> function’)
>> else:
>>  print(‘The contest for this record is Contest 1’)
>> if sender == ContestID:
>> print(‘the sender is a table, which in this case was ContestID’)
>> else:
>> print(‘hi’)
>>
>>
>> So, say someone created a new row in ContestScores. What’ll happen is, 
>> before the object is saved in the database, it’ll go through that function 
>> first. So if a user created a row setting the contest to be Contest 1, then 
>> you should see “Hello, you should...” and “hi”
>>
>> I imagine you could use signals for the Index(overall score. There’s 
>> something in databases called indexes). When showing the ranks of 
>> individuals, that’ll be done per request using the order_by method shown 
>> above.
>>
>> Regarding the semesters, I’d say just add another column to ContestScores 
>> called semesters, then use the filter(semesters=1, user=derek)

Re: Minimum Hardware requirement - reg

2019-06-25 Thread Yoo
8 app modules? That's a little clumsy. Something that would require that 
many app modules would be like docs.google.com and drive.google.com. Google 
has a LOT of different platforms which, if programmed in Django, would need 
several app modules. I'm 90% sure you'll only need one app.

Hardware requirement is not something you need to consider based off 
Django. It's more about the transaction costs (writes and reads and etc.). 
Since it's only 30 clients, I imagine self hosting wouldn't be a problem at 
all. You could probably buy a Raspberry Pi 4 and host on there without a 
problem for the next 5 years.

For cron jobs, check out this: 
https://stackoverflow.com/questions/573618/django-set-up-a-scheduled-job . 
You can also use the Advanced Python Scheduler (APS) for scheduled tasks.

Several users logging into the system isn't a problem. Django has session 
authentication, so users can do whatever they want, concurrently. If you're 
looking into setting up a Chatroom package, you can check out python's 
asyncio and django-channels package for asynchronous tasks.

Again, hardware with the conditions you listed should be the least of your 
worries. Just make sure that everything works and is secure. You could 
utilize Django-registration and Django-pwned-passwords. Make sure your 
setting's important information, like the secret key and database 
passwords, are stored in environment variables.

On Tuesday, June 25, 2019 at 2:19:18 PM UTC-4, Raja Sekar Sampath wrote:
>
> Hi,
>
> What are the facts to be considered while determine the server 
> configuration for a Django Application?
>
> My Client preferring self hosting, the project having 8 different (apps) 
> modules and we expect 20 to 30 users concurrently login into the system and 
> Its having automated cron jobs 
>
> Thanks & Regards,
> Raja Sekar Sampath
>
>

-- 
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/a8e59b16-7a6e-43fc-8ffe-63d0e77ab19e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Social media management

2019-06-25 Thread Yoo
Management platform? How so? Are you talking about authenticating users 
with OAuth? Like "sign up with Google" or "Sign up with Facebook"

If so, you can check out:
https://github.com/RealmTeam/django-rest-framework-social-oauth2

Otherwise, if you're talking about building an API like a Twitter bot, then 
I'm not aware of any "packages" that'll help you. I feel like that's more 
on the social media platform's own end's documentation and a little bit of 
Django views.
On Tuesday, June 25, 2019 at 11:05:24 AM UTC-4, Django Dojo wrote:
>
> Are there any packages that will allow me to build a social media 
> management platform?

-- 
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/44131d6f-3280-4260-840f-cbc41451e852%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django create username and password, please help!

2019-06-25 Thread Yoo
Go to settings. Go to "Project: myproject" or whatever it says for 
myproject. Then press Project Interpreter and makes sure that Django is pip 
installed in that virtual environment. If it's not installed, do: 

pip install django

If that's done, you can use the PyCharm terminal to do this:

python manage.py makemigrations && python manage.py migrate && python 
manage.py createsuperuser

You probably forgot to migrate the Django automatically-created tables 
first. Good luck!

On Tuesday, June 25, 2019 at 11:05:24 AM UTC-4, Jackeline Peña Alejandro 
wrote:
>
> Hello everyone, I have a query, well is the first time I'm using django to 
> create web pages, I would like help in that sense, I have to create a 
> username and password, I would like guidance on it, there are tutorials on 
> youtube, but do not help me, because the course of following the steps, 
> there is always an error, and I get confused.
>
> I'm using pycharm which allowed me to create a virtual environment, to 
> install django
>
> I look forward to your prompt response, 
>
> Translated with www.DeepL.com/Translator
>

-- 
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/7aea6b09-f892-45eb-97ad-5b0c97a0ae7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to talk to API via HTTP on Django

2019-06-25 Thread Yoo
Use Django REST Framework and django-filters. Easy set-up. 
For something you're trying to do, you can send a request like: 
http://127.0.0.1:8000/api/testtable/?format=json=science/
Basically, this goes to the table Testtable, filters the queryset by some 
column category that returns all categories of science. The returned data 
would be in the form of json.

You can also do http://127.0.0.1:8000/api/?category=science=1/

That'll filter by multiple columns. It's kinda like 
Testtable.objects.filter(category='science', user=1)

If you're doing something with username and password, use headers. If it's 
something for mobile, try using JWTAuthentication. 

On Tuesday, June 25, 2019 at 6:31:11 PM UTC-4, Dejan Batic wrote:
>
> I'm newbie of course. I have this API documentation and I'm trying to 
> figure out how to make this http request works. 
>
> For example here is the reques that client sends:
>
> GET 
> {URL}/api/{USER}:{PASS}/plaint/play_create*{PARAM1}*{SEQUENCE}*{GROUP}*{PARAM2}
>
> That line is from client and the server is a Django with a database (MySQL 
> or PostgreSQL).
>
> I want to know how to make this http requ
>

-- 
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/eb402d53-8ab0-40ef-81b3-a772f776e290%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Signals with update()

2019-06-25 Thread Yoo
If what I said is confusing, let me know where. I've been stuck on this for 
a looonngg time. 

On Tuesday, June 25, 2019 at 10:34:25 AM UTC-4, Yoo wrote:
>
> Hi, I have a problem with updating in Django signals regarding a specific 
> use-case hierarchy:
>
> https://gist.github.com/andrewcw825/90375d77578afea23ec4886f18e063b4
>
> Hi, so here's the problem: once the objects for Public1 are created, I 
> need to update each object in the queryset of Private1 of a1 to have their 
> publicized_id be equal to the new object's id. Like a ForeignKey. So for 
> Object 1 of a1, a new record in Public1 should be made that have the exact 
> same fields as Object 1; this new record will be called NewObj 1. So, once 
> the new record is saved, I need to update Object 1's publicized_id to be 
> equal to the id of NewObj1. This goes on forever with Object 2 having 
> publicized_id equal to NewObj 2's id. Maybe, instead of publicized_id being 
> a CharField, it can be a ForeignKey?
>
>
> How would I implement this update() into the signal?
>

-- 
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/ff6f61f1-f1cb-4c2d-ac64-7bb28e3f5df5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Signals with update()

2019-06-25 Thread Yoo
Hi, I have a problem with updating in Django signals regarding a specific 
use-case hierarchy:

https://gist.github.com/andrewcw825/90375d77578afea23ec4886f18e063b4

Hi, so here's the problem: once the objects for Public1 are created, I need 
to update each object in the queryset of Private1 of a1 to have their 
publicized_id be equal to the new object's id. Like a ForeignKey. So for 
Object 1 of a1, a new record in Public1 should be made that have the exact 
same fields as Object 1; this new record will be called NewObj 1. So, once 
the new record is saved, I need to update Object 1's publicized_id to be 
equal to the id of NewObj1. This goes on forever with Object 2 having 
publicized_id equal to NewObj 2's id. Maybe, instead of publicized_id being 
a CharField, it can be a ForeignKey?


How would I implement this update() into the signal?

-- 
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/7628b6cc-9c1e-49cf-aee9-12211c99ae6b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Need help transferring large amounts of data between models

2019-06-20 Thread Yoo
https://stackoverflow.com/questions/56695636/large-transfer-of-data-between-several-django-models
Please take a look. I don't have a good grasp over my situation...

-- 
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/eb1556b1-34b3-4b0b-9fdc-3148045e7617%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


API Root doesn't have has_permissions with JWT_Authentication

2019-06-19 Thread Yoo
https://stackoverflow.com/questions/56673987/api-root-doesnt-have-has-permissions-with-jwt-authentication
Someone please help. I have a feeling that because of this error, in 
production, there'll be a security flaw because of this attribute error...

-- 
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/cbc20126-ec4c-46e1-a6a8-47bccce08a3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Internal Ranking System Application

2019-06-16 Thread Yoo
Based off the context:
https://simpleisbetterthancomplex.com/tutorial/2016/11/23/how-to-add-user-profile-to-django-admin.html

I'm somewhat confused regarding where this is supposed to go, so here're 
some random ideas which hopefully might help you start off with some Google 
searches:

The above link is implementing a Profile model, which kinda extends the 
User model if that can help based off the context. Once you finish the 
tutorial above, runserver and access the admin at 127.0.0.1:8000/admin and 
enter the user model to see all the fields you added to the Profile model.

When processing the numbers, you can define a function based on PUT 
(update) requests. Or, whenever an object is created, a Django signal can 
be sent out to do some action like updating another table. (Unfortunately, 
I'm not too well-educated on signals...). 

Indexes will have everything ordered based off your liking for improved 
querying; otherwise, ordering will do the trick when using a queryset 
(basically when you query for several tables, the server returns an 
ordering you specify e.g. ordered dates, numbers, letters, etc.). 

Regarding authenticating users, you''ll have token authentication and some 
Django decorators that'll allow you to specify when an Authenticated User 
is allowed to do action X, Y, or Z. Unauthenticated users would be blocked 
from certain pages by utilizing the templates/html's with tags {% if 
user.is_authenticated %} then your HTML then another tag {% else %} with 
other tags. There are plenty of other ways such as redirecting a user in 
the views.py and yada yada if the user is NOT authenticated.

Something I think would help you is to utilize Django-rest-framework. It's 
designed as an API, but I think you'll understand Django much better 
through it. It's well-documented and there are plenty of tutorials 
(including those with Token authentication which I think you're seeking).

On Sunday, June 16, 2019 at 8:13:05 PM UTC-4, Derek Dong wrote:
>
> How can I integrate OAuth with a ranking system in a Django application?
> I'm not too familiar with Django design philosophy, which is why I'm 
> asking these questions.
> The way I understand it, OAuth doesn't let you manipulate information on 
> the server authenticating a user, so I would still need a User model with 
> information like "name." Is this right?
> Some quick context:
> Each user has float scores for each event (of which there are multiple); 
> the average (or possibly total if that's easier) of these scores composes 
> their overall score. Overall scores are used to rank all the users.
> Should I have separate models for things like "score," "ranking," and/or 
> "event?" 
> Where should processing the numbers go? I assume I should make a form to 
> input scores for each event, possibly with an overall "update" button on 
> the admin page, but would that go in the model.py, admin.py, views.py, or 
> something else?
> Sorry for these questions possibly sounding strange, I'm used to 
> object-oriented programming and have implemented a way to compute this in 
> that way, but am confused by web applications' use of databases, views, and 
> HTML for displays.
>

-- 
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/fb131034-faf6-4882-b661-f2d3532715fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Signals

2019-06-16 Thread Yoo
Hi. the following code is kinda wonky, so here's the context. I have two 
models:
https://gist.github.com/andrewcw825/f88aa2084e373480f3e63991af7d6c4b

The url_id field is supposed to be an auto increment field; however, since 
it's not the primary key, I can't. Obviously, I could make a function that 
autoincrements for me, but I suppose I simply need this use-case. 

Thus, with the model StuffIDTable, the id is supposed to be the table names 
(i.e. Stuff1 and Stuff2) and the last_number is supposed to be the latest 
number that a url_id used (as in the highest number used by a record of a 
certain table with url_id).

I'm not sure where to go with this. I was thinking of using signals to find 
the latest number used, then update it by incrementing last_number by one, 
then sending another signal back for Stuff1 or Stuff2 to save in url_id. 
Not only that, but what would the signal code look like? How do I even code 
a signal code? 

In the models, do I need a def save(self, *args, **kwargs): 
then some kind of "signals" code provided by Django? Post_save, pre_save? 
Just... confusing...

The previous paragraphs might not have made much sense, so if clarification 
of a certain part (or all of it) is needed, don't hesitate to immediately 
bash on 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b4d09db8-1224-4ef9-adb6-bb4f376eb826%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Model Forms Dynamic

2019-05-28 Thread Yoo
https://docs.djangoproject.com/en/2.2/topics/forms/modelforms/

In the example of model form, they say
model = Author
Is it possible to set a variable to set the model? Like could I make a variable 
and set it to whatever model I’d like, then say model = var?

-- 
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/918196f4-0ab8-45e8-803d-d62a38a1e396%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Right method for url mapping

2019-05-26 Thread Yoo
Are you in your application's urls.py or your project's urls.py? You need 
to be in your APPLICATION'S urls.py for this to work. Your application's 
folder has admin.py, apps.py, forms.py, etc. 

In your views.py, do you have "show" defined? Like:
def show(request):
   context = {}
   render(request, 'index.html', context=context)

*Here's the explanation:*

I still recommend you do something like this in your urls.py:
from django.urls import path
from . import views
path('', views.index, name='index'),
This is just to make everything less confusing. The name, 'index,' is used 
in your templates. For example, if you have:
Home Page
This is a  hyperlink to the home page called "index." 
The views.index means "use this view called index" like so: 
def index(request):
   context ={}
   render(request, 'index.html', context=context)
I'm assuming you're using a template called "index.html" to load everything 
in.
I'd recommend you go to Mozilla's Django tutorial to learn a bit. They have 
some good explanations with phenomenal tutorials.

Does that make sense?

On Sunday, May 26, 2019 at 6:41:03 AM UTC-4, Saeed Pooladzadeh wrote:
>
> Can you please explain. But I have seen in one of my app it works with 
> just second one!!
>
> در یکشنبه 26 مهٔ 2019، ساعت 3:49:59 (UTC+4:30)، Yoo نوشته:
>>
>> First one. Usually I'd have it be views.index. Otherwise, the first one 
>> is perfectly fine. Need explanation?
>>
>> On Saturday, May 25, 2019 at 7:14:18 PM UTC-4, Saeed Pooladzadeh wrote:
>>>
>>> Hello
>>>
>>> Wich of them is the right method for url mapping:
>>>
>>>   path('', views.show, name='index'),
>>>
>>> or
>>>
>>> path('index', views.show),
>>>
>>> Regards,
>>>
>>> Saeed
>>>
>>

-- 
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/f702f59f-752b-49b8-8193-0bfe25b91d72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Create a real small business website with Django as soon as possible!!

2019-05-26 Thread Yoo
For #3, Django documentation helpfully describes a method. 3) 
https://docs.djangoproject.com/en/2.2/topics/i18n/translation/#how-django-discovers-language-preference
 Not 
sure of sample project, but a simple Google serach on for a GitHub page is 
enough
For #2, Built-In admin is still possible in production. When deploying, you 
need to make sure that in your URLConf, you change the path from admin/ to 
something really strange like iuh494vnun2ijnuhj-2ejv02ijv4-/ so that users 
don't know that you're using Django and so they can't guess whatever your 
superuser password is.
For #1, Django is supposed to be an easy web framework. I'm not sure if 
there's an open-source project anywhere else that is alike your idea since 
most are totally unique from each other. I'd suggest that you simply get on 
Django and try it out. 
The issue with Django is mostly the deployment part. It's wildly not fun, 
there aren't that many tutorials (or at least those that are good), and 
there can be a lot of difficulties with them. I mean, there is "python 
manage.py check --deploy", but the true deployment is difficult, and there 
is no GitHub project that makes it simple.

All in all, views aren't that difficult to understand. Learn a bit of 
models and views and the Django way of template building, and you'll get 
the hang of it real quick. Additionally, with templates, it's simple HTML. 
You can download a website builder, like Google's, and copy-paste the code 
to a Django application.

Good luck and don't sweat it.

On Friday, May 24, 2019 at 3:30:56 PM UTC-4, Siavash Siavashi wrote:
>
> I am new to Django and I want to create a personal business site using 
> this platform. I should say that i have some experience working with python 
> and html.
> In general in my business , customers on home page click on the type of 
> services that they want.Next, they should register some information about 
> the  service interesting.The content of my site should be display as the 
> language that is  selected. Then , I would study the registered requests 
> and response them by email.If a costumer want to check her/his request, it 
> will be informed on website by a tracking number and a note that I write 
> down after processing that request(only a small note about the request 
> checking situation and that the result is emailed to the costumer email).
>
> I could design and create model and database for my website,but my main 
> problem is views and templates.So i have some questions:
> 1- Is there a sample project to use its views and templates for my website 
> ?
> 2- is it possible to use built-in admin app views and templates in my 
> website? how ?
> 2- how to change the language of my website content? is there a sample 
> project?
>
> Thanks alot
>

-- 
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/3f1a63a1-4e8c-4506-a8ae-93b73ea60480%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to get object id from database?

2019-05-25 Thread Yoo
Maybe try album__id (two underscores)? Or try album_title as defined in the 
Album model. I also advise not to expose your primary key in the URL. If 
the above did not work, check Django  documentation: 
https://docs.djangoproject.com/en/2.2/topics/http/urls/

On Saturday, May 25, 2019 at 2:46:58 PM UTC-4, Anchal Agarwal wrote:
>
> I am currently working on a django project in which there is a music app. 
> The models of this app contains Albums and Songs. I want to return the http 
> response when the django receives a url as /music/712 , here 712 is the 
> object id.
> Please help me out in resolving the issue.Thanks in advance.
>
> Here are my files. Here album_id will be the id of the object.
> models.py
> from django.db import models
>
> class Album(models.Model):
> artist = models.CharField(max_length=250)
> album_title = models.CharField(max_length=500)
> genre=models.CharField(max_length=100)
> album_logo = models.CharField(max_length=1000)
>
> def __str__(self):
> return self.album_title 
>
> class Song(models.Model):
> album= models.ForeignKey(Album, on_delete=models.CASCADE)
> file_type= models.CharField(max_length=10)
> song_title = models.CharField(max_length=250)
>
> views.py
> from django.shortcuts import render
> from django.http import HttpResponse
>
> def homepage(request):
> return HttpResponse("You are looking music!!")
>
> def detail(request, album_id):
> return HttpResponse("Details for Album id:"+ str(album_id)+ "")
>
> urls.py
>  
> from django.urls import path
> from . import views 
>
> app_name="music"
>
> urlpatterns=[
> #/music/
> path('',views.homepage,name='homepage'),
>
> # /music/712
> path('[0-9]+/',views.detail,name='detail'),
> ]
>

-- 
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/848dc27b-9d4c-42a1-a691-c74ac4112e41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Right method for url mapping

2019-05-25 Thread Yoo
First one. Usually I'd have it be views.index. Otherwise, the first one is 
perfectly fine. Need explanation?

On Saturday, May 25, 2019 at 7:14:18 PM UTC-4, Saeed Pooladzadeh wrote:
>
> Hello
>
> Wich of them is the right method for url mapping:
>
>   path('', views.show, name='index'),
>
> or
>
> path('index', views.show),
>
> Regards,
>
> Saeed
>

-- 
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/2a7fc8e5-cd5a-42e4-bb38-9fb816e0463d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Too many tables with 10 columns each?

2019-05-25 Thread Yoo
There are 200 tables with 11 columns, including 4 foreign keys. Is 200 
tables too many tables? This is the error I'm getting:

Operations to perform:
  Apply all migrations: admin, auth, contenttypes, public, sessionsRunning 
migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying public.0001_initial... OK
  Applying public.0002_auto_20190525_1519... OK
  Applying public.0003_auto_20190525_1519... OKFatal Python error: Cannot 
recover from stack overflow.
Current thread 0x0f70 (most recent call first):
  File 
"c:\users\yoom\appdata\local\programs\python\python37-32\Lib\contextlib.py", 
line 130 in __exit__
  File 
"C:\Users\yoom\Code\test\testvenv\lib\site-packages\django\db\migrations\state.py",
 line 318 in render_multiple
  File 
"C:\Users\yoom\Code\test\testvenv\lib\site-packages\django\db\migrations\state.py",
 line 191 in _reload
  File 
"C:\Users\yoom\Code\test\testvenv\lib\site-packages\django\db\migrations\state.py",
 line 158 in reload_model
  File 
"C:\Users\yoom\Code\test\testvenv\lib\site-packages\django\db\migrations\operations\models.py",
 line 739 in state_forwards
  File 
"C:\Users\yoom\Code\test\testvenv\lib\site-packages\django\db\migrations\migration.py",
 line 114 in apply
  File 
"C:\Users\yoom\Code\test\testvenv\lib\site-packages\django\db\migrations\executor.py",
 line 245 in apply_migration
  File 
"C:\Users\yoom\Code\test\testvenv\lib\site-packages\django\db\migrations\executor.py",
 line 147 in _migrate_all_forwards
  File 
"C:\Users\yoom\Code\test\testvenv\lib\site-packages\django\db\migrations\executor.py",
 line 117 in migrate
  File 
"C:\Users\yoom\Code\test\testvenv\lib\site-packages\django\core\management\commands\migrate.py",
 line 234 in handle
  File 
"C:\Users\yoom\Code\test\testvenv\lib\site-packages\django\core\management\base.py",
 line 83 in wrapped
  File 
"C:\Users\yoom\Code\test\testvenv\lib\site-packages\django\core\management\base.py",
 line 364 in execute
  File 
"C:\Users\yoom\Code\test\testvenv\lib\site-packages\django\core\management\base.py",
 line 323 in run_from_argv
  File 
"C:\Users\yoom\Code\test\testvenv\lib\site-packages\django\core\management\__init__.py",
 line 375 in execute
  File 
"C:\Users\yoom\Code\test\testvenv\lib\site-packages\django\core\management\__init__.py",
 line 381 in execute_from_command_line
  File "manage.py", line 17 in main
  File "manage.py", line 21 in 

-- 
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/564f9c83-2192-4864-8afd-980cd5c5f865%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Migrations File too Large preventing Migrate

2019-05-21 Thread Yoo
https://stackoverflow.com/q/56213264/10973829
Originally, I posted this in StackOverflow. Not getting any responses. I looked 
over all my migration files, and it seems like they get continuously larger.
There are more “Test” tables than what you see in the migration files; what 
I’ve done was split the models.py files into multiple “apps” inside a model 
directory.
I’m using Django-Tagulous, and I’ve made 3 custom Tagulous tables. Some of the 
99 x3 tables are connected to 1 and up to 3 tag fields. The each 99 are 
different in attribution, but on average they have 8 fields. I first migrated 
99 tables. The next 99 would not migrate. 

-- 
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/6f69324c-d5db-4430-95a6-71742cb817b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Migrations File too Large preventing Migrate

2019-05-19 Thread Yoo


In Django 2.2, I run makemigrations then migrate. I wait approx. 5-7 
minutes and then I get "Fatal Python error: Cannot recover from stack 
overflow." "Current thread 0x0002094 (most recent call first):" yada yada 
"File "manage.py", line 17 in main "File manage.py line 21 in "


End. I check the migrations file and the file is 4000 lines of code large. 
What do I do in this case? Should I make my own migration files, and if so, 
how?

-- 
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/2f2f6361-6061-48bd-8b7f-f5297a25f8b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.